2 # Written by Uwe Hermann <uwe@hermann-uwe.de>, released as public domain.
3 # Modified by Piotr Esden-Tempski <piotr@esden.net>, released as public domain.
6 # Requirements (example is for Debian, replace package names as needed):
8 # apt-get install flex bison libgmp3-dev libmpfr-dev libncurses5-dev \
9 # libmpc-dev autoconf texinfo build-essential
12 # Stop if any command fails
15 TARGET=arm-none-eabi # Or: TARGET=arm-elf
16 PREFIX=${HOME}/arm-none-eabi # Install location of your final toolchain
17 PARALLEL= # Or: PARALLEL="-j 5" for 4 CPUs
18 DARWIN_OPT_PATH=/opt/local # Path in which MacPorts or Fink is installed
20 BINUTILS=binutils-2.20
33 SOURCES=${SUMMON_DIR}/sources
34 STAMPS=${SUMMON_DIR}/stamps
36 export PATH="${PREFIX}/bin:${PATH}"
42 # Fetch a versioned file from a URL
44 if [ ! -e ${STAMPS}/$1.fetch ]; then
45 echo "Downloading $1 sources..."
46 wget -c --no-passive-ftp $2
47 touch ${STAMPS}/$1.fetch
51 # Log a message out to the console
53 echo "******************************************************************"
55 echo "******************************************************************"
61 # Use 'auto' mode decompression. Replace with a switch if tar doesn't support -a
62 tar xvaf ${SOURCES}/$1.tar.*
68 ${SUDO} make ${PARALLEL} $2 $3 $4 $5 $6 $7 $8
73 echo "Found Linux OS."
76 echo "Found Darwin OS."
77 GCCFLAGS="${GCCFLAGS} \
78 --with-gmp=${DARWIN_OPT_PATH} \
79 --with-mpfr=${DARWIN_OPT_PATH} \
80 --with-mpc=${DARWIN_OPT_PATH} \
81 -with-libiconv-prefix=${DARWIN_OPT_PATH}"
84 echo "Found unknown OS. Aborting!"
89 mkdir -p ${STAMPS} ${SOURCES}
93 fetch ${BINUTILS} http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.bz2
94 fetch ${GCC} http://ftp.gnu.org/gnu/gcc/${GCC}/${GCC}.tar.gz
95 fetch ${NEWLIB} ftp://sources.redhat.com/pub/newlib/${NEWLIB}.tar.gz
96 fetch ${GDB} http://ftp.gnu.org/gnu/gdb/${GDB}.tar.bz2
98 if [ ${LIBSTM32_EN} != 0 ]; then
99 if [ ! -e libcmsis-${LIBCMSIS}.tar.bz2 ]; then
100 echo "Cloning libcmsis sources..."
101 git clone git://git.open-bldc.org/libcmsis.git
103 git archive --format=tar --prefix=libcmsis-${LIBCMSIS}/ ${LIBCMSIS} | \
104 bzip2 --stdout > ../libcmsis-${LIBCMSIS}.tar.bz2
109 if [ ! -e libstm32-${LIBSTM32}.tar.bz2 ]; then
110 echo "Cloning libstm32 sources..."
111 git clone git://git.open-bldc.org/libstm32.git
113 git archive --format=tar --prefix=libstm32-${LIBSTM32}/ ${LIBSTM32} | \
114 bzip2 --stdout > ../libstm32-${LIBSTM32}.tar.bz2
119 if [ ! -e libstm32usb-${LIBSTM32USB}.tar.bz2 ]; then
120 echo "Cloning libstm32usb sources..."
121 git clone git://git.open-bldc.org/libstm32usb.git
123 git archive --format=tar --prefix=libstm32usb-${LIBSTM32USB}/ ${LIBSTM32USB} | \
124 bzip2 --stdout > ../libstm32usb-${LIBSTM32USB}.tar.bz2
130 if [ ${LIBOPENSTM32_EN} != 0 ]; then
131 if [ ! -e libopenstm32-${LIBOPENSTM32}.tar.bz2 ]; then
132 echo "Cloning libopenstm32 sources..."
133 git clone git://libopenstm32.git.sourceforge.net/gitroot/libopenstm32/libopenstm32
135 git archive --format=tar --prefix=libopenstm32-${LIBOPENSTM32}/ ${LIBOPENSTM32} | \
136 bzip2 --stdout > ../libopenstm32-${LIBOPENSTM32}.tar.bz2
144 if [ ! -e build ]; then
148 if [ ! -e ${STAMPS}/${BINUTILS}.build ]; then
151 log "Configuring ${BINUTILS}"
152 ../${BINUTILS}/configure --target=${TARGET} \
161 log "Building ${BINUTILS}"
163 install ${BINUTILS} install
165 log "Cleaning up ${BINUTILS}"
166 touch ${STAMPS}/${BINUTILS}.build
167 rm -rf build/* ${BINUTILS}
170 if [ ! -e ${STAMPS}/${GCC}-boot.build ]; then
173 log "Configuring ${GCC}-boot"
174 ../${GCC}/configure --target=${TARGET} \
178 --enable-languages="c" \
187 log "Building ${GCC}-boot"
188 make ${PARALLEL} all-gcc
189 install ${GCC}-boot install-gcc
191 log "Cleaning up ${GCC}-boot"
192 touch ${STAMPS}/${GCC}-boot.build
193 rm -rf build/* ${GCC}
196 if [ ! -e ${STAMPS}/${NEWLIB}.build ]; then
199 log "Configuring ${NEWLIB}"
200 ../${NEWLIB}/configure --target=${TARGET} \
208 --disable-newlib-supplied-syscalls
209 log "Building ${NEWLIB}"
211 install ${NEWLIB} install
213 log "Cleaning up ${NEWLIB}"
214 touch ${STAMPS}/${NEWLIB}.build
215 rm -rf build/* ${NEWLIB}
218 # Yes, you need to build gcc again!
219 if [ ! -e ${STAMPS}/${GCC}.build ]; then
222 log "Configuring ${GCC}"
223 ../${GCC}/configure --target=${TARGET} \
227 --enable-languages="c,c++" \
235 log "Building ${GCC}"
237 install ${GCC} install
239 log "Cleaning up ${GCC}"
240 touch ${STAMPS}/${GCC}.build
241 rm -rf build/* ${GCC}
244 if [ ! -e ${STAMPS}/${GDB}.build ]; then
247 log "Configuring ${GDB}"
248 ../${GDB}/configure --target=${TARGET} \
254 log "Building ${GDB}"
256 install ${GDB} install
258 log "Cleaning up ${GDB}"
259 touch ${STAMPS}/${GDB}.build
260 rm -rf build/* ${GDB}
263 if [ ${LIBSTM32_EN} != 0 ]; then
264 if [ ! -e .libcmsis-${LIBCMSIS}.build ]; then
265 unpack libcmsis-${LIBCMSIS}
266 cd libcmsis-${LIBCMSIS}
267 log "Building libcmsis-${LIBCMSIS}"
268 make arch_prefix=${TARGET} prefix=${PREFIX}
269 install libcmsis-${LIBCMSIS} arch_prefix=${TARGET} prefix=${PREFIX} install
271 log "Cleaning up libcmsis-${LIBCMSIS}"
272 touch .libcmsis-${LIBCMSIS}.build
273 rm -rf libcmsis-${LIBCMSIS}
276 if [ ! -e .libstm32-${LIBSTM32}.build ]; then
277 unpack libstm32-${LIBSTM32}
278 cd libstm32-${LIBSTM32}
279 log "Building libstm32-${LIBSTM32}"
280 make arch_prefix=${TARGET} prefix=${PREFIX}
281 install libstm32-${LIBSTM32} arch_prefix=${TARGET} prefix=${PREFIX} install
283 log "Cleaning up libstm32-${LIBSTM32}"
284 touch .libstm32-${LIBSTM32}.build
285 rm -rf libstm32-${LIBSTM32}
288 if [ ! -e .libstm32usb-${LIBSTM32USB}.build ]; then
289 unpack libstm32usb-${LIBSTM32USB}
290 cd libstm32usb-${LIBSTM32USB}
291 log "Building libstm32usb-${LIBSTM32USB}"
292 make arch_prefix=${TARGET} prefix=${PREFIX}
293 install libstm32usb-${LIBSTM32USB} arch_prefix=${TARGET} prefix=${PREFIX} install
295 log "Cleaning up libstm32usb-${LIBSTM32USB}"
296 touch .libstm32usb-${LIBSTM32USB}.build
297 rm -rf libstm32usb-${LIBSTM32USB}
301 if [ $LIBOPENSTM32_EN != 0 ]; then
302 unpack libopenstm32-${LIBOPENSTM32}
303 cd libopenstm32-${LIBOPENSTM32}
304 log "Building libopenstm32-${LIBOPENSTM32}"
305 make PREFIX=${TARGET} DESTDIR=${PREFIX}
306 install libopenstm32-${LIBOPENSTM32} PREFIX=${TARGET} DESTDIR=${PREFIX} install
308 log "Cleaning up libopenstm32-${LIBOPENSTM32}"
309 touch .libopenstm32-${LIBOPENSTM32}.build
310 rm -rf libopenstm32-${LIBOPENSTM32}