-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
180 lines (158 loc) · 5.89 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# directory to save source files into
TMP ?= /tmp
INSTALL_DIR ?= ${HOME}/.local
BIN_DIR ?= ${INSTALL_DIR}/bin
SREC_VER ?= 151
SREC_BUILD ?= ${HOME}/.srec
srec-install:
$(if $(shell which unzip), echo "unzip found", $(error "please install unzip"))
@wget http://www.goffart.co.uk/s-record/download/srec_${SREC_VER}_src.zip -O ${TMP}/srec.zip
@mkdir -p ${SREC_BUILD}
@unzip ${TMP}/srec.zip -d ${SREC_BUILD}
${MAKE} -C ${SREC_BUILD}
@mkdir -p ${BIN_DIR}
mv ${SREC_BUILD}/bin2srec ${BIN_DIR}/
mv ${SREC_BUILD}/srec2bin ${BIN_DIR}/
mv ${SREC_BUILD}/binsplit ${BIN_DIR}/
rm ${TMP}/srec.zip
rm -r ${SREC_BUILD}
@echo You can now use "bin2srec", "srec2bin" and "binsplit" if ${BIN_DIR}
srec-uninstall:
@$(if $(shell ls ${BIN_DIR} | grep bin2srec), echo "removing srec binaries", $(error "srec binaries not found in ${BIN_DIR}"))
rm ${BIN_DIR}/bin2srec
rm ${BIN_DIR}/srec2bin
rm ${BIN_DIR}/binsplit
SRECORD_VER ?= "1.64"
SRECORD_BUILD ?= ${HOME}/.srecord
srecord-install:
@wget http://srecord.sourceforge.net/srecord-${SRECORD_VER}.tar.gz -O ${TMP}/srecord.tar.gz
@mkdir -p ${SRECORD_BUILD}
@tar xzf ${TMP}/srecord.tar.gz --directory ${SRECORD_BUILD}
@rm ${TMP}/srecord.tar.gz
@cd ${SRECORD_BUILD}/srecord-${SRECORD_VER} && \
./configure \
--prefix=${INSTALL_DIR} \
--without-gcrypt
${MAKE} -C ${SRECORD_BUILD}/srecord-${SRECORD_VER}
${MAKE} install -C ${SRECORD_BUILD}/srecord-${SRECORD_VER}
@echo "Checking correct installation"
srec_cat --version
srecord-uninstall:
@$(if $(shell ls ${BIN_DIR} | grep srec_cat), echo "removing SRecord", $(error "SRecord binaries not found in ${BIN_DIR}"))
${MAKE} uninstall -C ${SRECORD_BUILD}/srecord-${SRECORD_VER}
@rm -r ${SRECORD_BUILD}/srecord-${SRECORD_VER}
BINUTILS_VER ?= 2.35
BINUTILS_SRC := ${TMP}/binutils-${BINUTILS_VER}
GCC_VER ?= 5.4.0
GCC_SRC := ${TMP}/gcc-${GCC_VER}
GCC_BUILD := ${HOME}/.gcc-build
GCC_LANGUAGES ?= "c"
gcc-install:
@# Cross-compiler binutils phase
@echo "Installing cross-compiler binutils first, gcc is of little use without it"
wget https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VER}.tar.gz -O ${TMP}/binutils.tar.gz
@echo "*** Extracting binutils source ***"
tar xzf ${TMP}/binutils.tar.gz --directory ${TMP}
@echo "*** Removing downloaded archive ***"
rm -r ${TMP}/binutils.tar.gz
cd ${BINUTILS_SRC} && ./configure \
--prefix=${INSTALL_DIR} \
--target=m68k-elf \
--with-newlib \
--disable-plugins \
--disable-werror \
--enable-tui \
--disable-nls
${MAKE} -C ${BINUTILS_SRC}
${MAKE} install -C ${BINUTILS_SRC}
rm -rf ${BINUTILS_SRC}
@# GCC install phase
wget https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-${GCC_VER}.tar.gz -O ${TMP}/gcc.tar.gz
@echo "*** Extracting gcc source ***"
tar xzf ${TMP}/gcc.tar.gz --directory ${TMP}
@echo "*** Downloading compile dependencies ***"
cd ${GCC_SRC} && contrib/download_prerequisites
@echo "*** Configuring gcc ***"
mkdir -p ${GCC_BUILD}
cd ${GCC_BUILD} && ${GCC_SRC}/configure \
-q \
--prefix=${INSTALL_DIR} \
--enable-libgcc-rebuild \
--target=m68k-elf \
--enable-languages=${GCC_LANGUAGES} \
--disable-libssp \
--disable-nls \
--disable-multilib
@echo "*** Building gcc ***"
${MAKE} all-gcc -s -j4 -C ${GCC_BUILD}
@echo "*** Installing gcc ***"
${MAKE} install-gcc -C ${GCC_BUILD}
@echo "*** Installing libgcc ***"
${MAKE} all-target-libgcc -C ${GCC_BUILD}
${MAKE} install-target-libgcc -C ${GCC_BUILD}
@echo "*** Run cross-compilation test ***"
${MAKE} demo.run -C ../c_example
${MAKE} clean -C ../c_example
@echo "*** Cleaning up source files ***"
rm -r ${GCC_SRC}
rm -r ${TMP}/gcc.tar.gz
@echo "*** Done ***"
gcc-uninstall:
@$(if $(shell which m68k-elf-gcc), echo "Removing gcc cross compiler", $(error "gcc cross-compiler not found"))
@echo "Removing binutils"
rm -r ${INSTALL_DIR}/m68k-elf
@echo "Removing gcc"
@echo "*** Removing build directory ***"
rm -rf ${GCC_BUILD}
@echo "*** Removing binary executables ***"
rm ${INSTALL_DIR}/bin/m68k-elf-*
rm -r ${INSTALL_DIR}/lib/gcc
rm -r ${INSTALL_DIR}/libexec/gcc
rm ${INSTALL_DIR}/share/man/man1/m68k-elf-cpp.1
rm ${INSTALL_DIR}/share/man/man1/m68k-elf-gcc.1
rm ${INSTALL_DIR}/share/man/man1/m68k-elf-gcov.1
@echo "*** Done ***"
NEWLIB_VER ?= 2.5.0
newlib-install:
${MAKE} -C newlib/ && ${MAKE} install -C newlib/
newlib-uninstall:
${MAKE} uninstall -C newlib/
MINIPRO_VER ?= 0.5
MINIPRO_DIR ?= ~/.local/minipro
minipro-install:
wget https://gitlab.com/DavidGriffith/minipro/-/archive/${MINIPRO_VER}/minipro-${MINIPRO_VER}.tar.gz -O ${TMP}/minipro.tar.gz
mkdir -p ${MINIPRO_DIR}
tar xzf ${TMP}/minipro.tar.gz --directory ${MINIPRO_DIR}
${MAKE} -C ${MINIPRO_DIR}/minipro-${MINIPRO_VER}
@echo Minipro requires a priviledged install to have proper access to the USB ports and the supported chip list
sudo ${MAKE} install
minipro --version
sudo udevadm trigger
sudo usermod -a -G plugdev ${USER}
@echo "*** Done ***"
@echo "You need to log out and in again for the rules for user access to the programmer over USB to take effect. \
Or: you can run the make recipes for burning the ROMs as root with sudo: e.g. sudo make rom-odd"
# Minor versions are separated using underscores for downloads, so version 1.8i becomes 1_8i
VASM_VER ?= 1_8i
BUILD_DIR ?= ~/.local/vasm
vasm-install:
@echo " *** Installing VASM ***"
mkdir -p ${BUILD_DIR}
wget http://phoenix.owl.de/tags/vasm${VASM_VER}.tar.gz -O ${BUILD_DIR}/vasm.tar.gz
tar xzf ${BUILD_DIR}/vasm.tar.gz --directory ${BUILD_DIR}/..
make -C ${BUILD_DIR} CPU=m68k SYNTAX=mot
cp ${BUILD_DIR}/vasmm68k_mot ${BIN_DIR}/
@echo "*** Done ***"
@echo "Vasm m68k assembler successfully installed, you can call it using 'vasmm68k_mot'"
vasm-uninstall:
@echo " *** Uninstalling VASM assembler ***"
rm -r ${BUILD_DIR}
rm ${BIN_DIR}/vasmm68k_mot
disasm-install:
@echo " *** Installing Disassembler ***"
${MAKE} install -C disasm/
@echo "*** Done ***"
disasm-uninstall:
@echo " *** Uninstalling Disassembler ***"
${MAKE} uninstall -C disasm/
@echo "*** Done ***"