forked from esden/summon-arm-toolchain
/
summon-arm-toolchain
executable file
·333 lines (311 loc) · 13.4 KB
/
summon-arm-toolchain
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#!/bin/bash
# Written by Uwe Hermann <uwe@hermann-uwe.de>, released as public domain.
# Modified by Piot Esden-Tempski <piotr@esden.net>, released as public domain.
TARGET=arm-none-eabi # Or: TARGET=arm-none-eabi
PREFIX=${HOME}/arm-none-eabi # Install location of your final toolchain
PARALLEL="" # Or: PARALLEL="-j 5" for 4 CPU's
DARWIN_OPT_PATH=/opt/local # Path in which MacPorts or Fink is installed
BINUTILS=binutils-2.19.1
GCC=gcc-4.4.0
NEWLIB=newlib-1.17.0
GDB=gdb-6.8
LIBCMSIS=v1.10-2
LIBSTM32=v3.0.0-1
LIBSTM32USB=v3.0.1-1
export PATH="${PREFIX}/bin:${PATH}"
case "$(uname)" in
Linux)
echo "Found Linux OS."
GCCFLAGS=
GDBFLAGS=
;;
Darwin)
echo "Found Darwin OS."
GCCFLAGS="--with-gmp=${DARWIN_OPT_PATH} \
--with-mpfr=${DARWIN_OPT_PATH} \
-with-libiconv-prefix=${DARWIN_OPT_PATH}"
GDBFLAGS="--disable-werror"
;;
*)
echo "Found Unknown OS. Aborting!"
exit 1
;;
esac
if [ ! -e sources ]; then
mkdir sources
fi
cd sources
if [ ! -e ${BINUTILS}.tar.bz2 ]; then
echo "Downloading binutils sources..."
wget -c http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.bz2
fi
if [ ! -e ${GCC}.tar.bz2 ]; then
echo "Downloading gcc sources..."
wget -c ftp://ftp.gnu.org/gnu/gcc/${GCC}/${GCC}.tar.bz2
fi
if [ ! -e ${NEWLIB}.tar.gz ]; then
echo "Downloading newlib sources..."
wget -c ftp://sources.redhat.com/pub/newlib/${NEWLIB}.tar.gz
fi
if [ ! -e ${GDB}.tar.bz2 ]; then
echo "Downloading gdb sources..."
wget -c ftp://ftp.gnu.org/gnu/gdb/${GDB}.tar.bz2
fi
if [ ! -e libcmsis-${LIBCMSIS}.tar.bz2 ]; then
echo "Cloning libcmsis sources..."
git clone git://git.open-bldc.org/libcmsis.git
cd libcmsis
git archive --format=tar --prefix=libcmsis-${LIBCMSIS}/ ${LIBCMSIS} | \
bzip2 --stdout > ../libcmsis-${LIBCMSIS}.tar.bz2
cd ..
rm -rf libcmsis
fi
if [ ! -e libstm32-${LIBSTM32}.tar.bz2 ]; then
echo "Cloning libstm32 sources..."
git clone git://git.open-bldc.org/libstm32.git
cd libstm32
git archive --format=tar --prefix=libstm32-${LIBSTM32}/ ${LIBSTM32} | \
bzip2 --stdout > ../libstm32-${LIBSTM32}.tar.bz2
cd ..
rm -rf libstm32
fi
if [ ! -e libstm32usb-${LIBSTM32USB}.tar.bz2 ]; then
echo "Cloning libstm32usb sources..."
git clone git://git.open-bldc.org/libstm32usb.git
cd libstm32usb
git archive --format=tar --prefix=libstm32usb-${LIBSTM32USB}/ ${LIBSTM32USB} | \
bzip2 --stdout > ../libstm32usb-${LIBSTM32USB}.tar.bz2
cd ..
rm -rf libstm32usb
fi
cd ..
if [ ! -e build ]; then
mkdir build
fi
if [ ! -e .${BINUTILS}.build ]; then
echo "******************************************************************"
echo "* Unpacking ${BINUTILS}"
echo "******************************************************************"
tar xfvj sources/${BINUTILS}.tar.bz2
cd build
echo "******************************************************************"
echo "* Configuring ${BINUTILS}"
echo "******************************************************************"
../${BINUTILS}/configure --target=${TARGET} \
--prefix=${PREFIX} \
--enable-interwork \
--enable-multilib \
--with-gnu-as \
--with-gnu-ld \
--disable-nls || exit
echo "******************************************************************"
echo "* Building ${BINUTILS}"
echo "******************************************************************"
make ${PARALLEL} || exit
echo "******************************************************************"
echo "* Installing ${BINUTILS}"
echo "******************************************************************"
make install || exit
cd ..
echo "******************************************************************"
echo "* Cleaning up ${BINUTILS}"
echo "******************************************************************"
touch .${BINUTILS}.build
rm -rf build/* ${BINUTILS}
fi
if [ ! -e .${GCC}-boot.build ]; then
echo "******************************************************************"
echo "* Unpacking ${GCC}-boot"
echo "******************************************************************"
tar xfvj sources/${GCC}.tar.bz2
cd build
echo "******************************************************************"
echo "* Configuring ${GCC}-boot"
echo "******************************************************************"
../${GCC}/configure --target=${TARGET} \
--prefix=${PREFIX} \
--enable-interwork \
--enable-multilib \
--enable-languages="c" \
--with-newlib \
--without-headers \
--disable-shared \
--with-gnu-as \
--with-gnu-ld \
--disable-nls \
${GCCFLAGS} || exit
echo "******************************************************************"
echo "* Building ${GCC}-boot"
echo "******************************************************************"
make ${PARALLEL} all-gcc || exit
echo "******************************************************************"
echo "* Installing ${GCC}-boot"
echo "******************************************************************"
make install-gcc || exit
cd ..
echo "******************************************************************"
echo "* Cleaning up ${GCC}-boot"
echo "******************************************************************"
touch .${GCC}-boot.build
rm -rf build/* ${GCC}
fi
if [ ! -e .${NEWLIB}.build ]; then
echo "******************************************************************"
echo "* Unpacking ${NEWLIB}"
echo "******************************************************************"
tar xfvz sources/${NEWLIB}.tar.gz
cd build
echo "******************************************************************"
echo "* Configuring ${NEWLIB}"
echo "******************************************************************"
../${NEWLIB}/configure --target=${TARGET} \
--prefix=${PREFIX} \
--enable-interwork \
--enable-multilib \
--with-gnu-as \
--with-gnu-ld \
--disable-nls \
--disable-newlib-supplied-syscalls || exit
echo "******************************************************************"
echo "* Building ${NEWLIB}"
echo "******************************************************************"
make ${PARALLEL} || exit
echo "******************************************************************"
echo "* Installing ${NEWLIB}"
echo "******************************************************************"
make install || exit
cd ..
echo "******************************************************************"
echo "* Cleaning up ${NEWLIB}"
echo "******************************************************************"
touch .${NEWLIB}.build
rm -rf build/* ${NEWLIB}
fi
# Yes, you need to build gcc again!
if [ ! -e .${GCC}.build ]; then
echo "******************************************************************"
echo "* Unpacking ${GCC}"
echo "******************************************************************"
tar xfvj sources/${GCC}.tar.bz2
cd build
echo "******************************************************************"
echo "* Configuring ${GCC}"
echo "******************************************************************"
../${GCC}/configure --target=${TARGET} \
--prefix=${PREFIX} \
--enable-interwork \
--enable-multilib \
--enable-languages="c,c++" \
--with-newlib \
--disable-shared \
--with-gnu-as \
--with-gnu-ld \
--disable-nls \
${GCCFLAGS} || exit
echo "******************************************************************"
echo "* Building ${GCC}"
echo "******************************************************************"
make ${PARALLEL} || exit
echo "******************************************************************"
echo "* Installing ${GCC}"
echo "******************************************************************"
make install || exit
cd ..
echo "******************************************************************"
echo "* Cleaning up ${GCC}"
echo "******************************************************************"
touch .${GCC}.build
rm -rf build/* ${GCC}
fi
if [ ! -e .${GDB}.build ]; then
echo "******************************************************************"
echo "* Unpacking ${GDB}"
echo "******************************************************************"
tar xfvj sources/${GDB}.tar.bz2
cd build
echo "******************************************************************"
echo "* Configuring ${GDB}"
echo "******************************************************************"
../${GDB}/configure --target=${TARGET} \
--prefix=${PREFIX} \
--enable-interwork \
--enable-multilib \
${GDBFLAGS} || exit
echo "******************************************************************"
echo "* Building ${GDB}"
echo "******************************************************************"
make ${PARALLEL} || exit
echo "******************************************************************"
echo "* Installing ${GDB}"
echo "******************************************************************"
make install || exit
cd ..
echo "******************************************************************"
echo "* Cleaning up ${GDB}"
echo "******************************************************************"
touch .${GDB}.build
rm -rf build/* ${GDB}
fi
if [ ! -e .libcmsis-${LIBCMSIS}.build ]; then
echo "******************************************************************"
echo "* Unpacking libcmsis-${LIBCMSIS}"
echo "******************************************************************"
tar xfvj sources/libcmsis-${LIBCMSIS}.tar.bz2
cd libcmsis-${LIBCMSIS}
echo "******************************************************************"
echo "* Building libcmsis-${LIBCMSIS}"
echo "******************************************************************"
make arch_prefix=${TARGET} prefix=${PREFIX} || exit
echo "******************************************************************"
echo "* Installing libcmsis-${LIBCMSIS}"
echo "******************************************************************"
make arch_prefix=${TARGET} prefix=${PREFIX} install || exit
cd ..
echo "******************************************************************"
echo "* Cleaning up libcmsis-${LIBCMSIS}"
echo "******************************************************************"
touch .libcmsis-${LIBCMSIS}.build
rm -rf libcmsis-${LIBCMSIS}
fi
if [ ! -e .libstm32-${LIBSTM32}.build ]; then
echo "******************************************************************"
echo "* Unpacking libstm32-${LIBSTM32}"
echo "******************************************************************"
tar xfvj sources/libstm32-${LIBSTM32}.tar.bz2
cd libstm32-${LIBSTM32}
echo "******************************************************************"
echo "* Building libstm32-${LIBSTM32}"
echo "******************************************************************"
make arch_prefix=${TARGET} prefix=${PREFIX} || exit
echo "******************************************************************"
echo "* Installing libstm32-${LIBSTM32}"
echo "******************************************************************"
make arch_prefix=${TARGET} prefix=${PREFIX} install || exit
cd ..
echo "******************************************************************"
echo "* Cleaning up libstm32-${LIBSTM32}"
echo "******************************************************************"
touch .libstm32-${LIBSTM32}.build
rm -rf libstm32-${LIBSTM32}
fi
if [ ! -e .libstm32usb-${LIBSTM32USB}.build ]; then
echo "******************************************************************"
echo "* Unpacking libstm32usb-${LIBSTM32USB}"
echo "******************************************************************"
tar xfvj sources/libstm32usb-${LIBSTM32USB}.tar.bz2
cd libstm32usb-${LIBSTM32USB}
echo "******************************************************************"
echo "* Building libstm32usb-${LIBSTM32USB}"
echo "******************************************************************"
make arch_prefix=${TARGET} prefix=${PREFIX} || exit
echo "******************************************************************"
echo "* Installing libstm32usb-${LIBSTM32USB}"
echo "******************************************************************"
make arch_prefix=${TARGET} prefix=${PREFIX} install || exit
cd ..
echo "******************************************************************"
echo "* Cleaning up libstm32usb-${LIBSTM32USB}"
echo "******************************************************************"
touch .libstm32usb-${LIBSTM32USB}.build
rm -rf libstm32usb-${LIBSTM32USB}
fi