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
19 # Set to 'sudo' if you need superuser privileges while installing
21 # Set to 1 to be quieter while running
27 GCCURL=http://ftp.gnu.org/gnu/gcc/${GCC}/${GCC}.tar.gz
30 # GCCVERSION=4.5-2010.08-1
31 # GCC=gcc-linaro-${GCCVERSION}
32 # GCCURL=http://launchpad.net/gcc-linaro/4.5/${GCCVERSION}/+download/${GCC}.tar.gz
34 BINUTILS=binutils-2.20
45 SOURCES=${SUMMON_DIR}/sources
46 STAMPS=${SUMMON_DIR}/stamps
48 export PATH="${PREFIX}/bin:${PATH}"
54 # To default to the Cortex-M3:
55 # GCCFLAGS="--with-arch=armv7-m --with-mode=thumb"
57 # Pull in the local configuration, if any
58 if [ -f local.sh ]; then
65 if [ ${QUIET} != 0 ]; then
67 MAKEFLAGS="${MAKEFLAGS} -s"
70 # Fetch a versioned file from a URL
72 if [ ! -e ${STAMPS}/$1.fetch ]; then
73 log "Downloading $1 sources..."
74 wget -c --no-passive-ftp $2
75 touch ${STAMPS}/$1.fetch
79 # Log a message out to the console
81 echo "******************************************************************"
83 echo "******************************************************************"
89 # Use 'auto' mode decompression. Replace with a switch if tar doesn't support -a
90 tar xaf${TARFLAGS} ${SOURCES}/$1.tar.*
96 ${SUDO} make ${MAKEFLAGS} $2 $3 $4 $5 $6 $7 $8
101 echo "Found Linux OS."
104 echo "Found Darwin OS."
105 GCCFLAGS="${GCCFLAGS} \
106 --with-gmp=${DARWIN_OPT_PATH} \
107 --with-mpfr=${DARWIN_OPT_PATH} \
108 --with-mpc=${DARWIN_OPT_PATH} \
109 -with-libiconv-prefix=${DARWIN_OPT_PATH}"
112 echo "Found unknown OS. Aborting!"
117 mkdir -p ${STAMPS} ${SOURCES}
121 fetch ${BINUTILS} http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.bz2
122 fetch ${GCC} ${GCCURL}
123 fetch ${NEWLIB} ftp://sources.redhat.com/pub/newlib/${NEWLIB}.tar.gz
124 fetch ${GDB} http://ftp.gnu.org/gnu/gdb/${GDB}.tar.bz2
126 if [ ${LIBSTM32_EN} != 0 ]; then
127 if [ ! -e libcmsis-${LIBCMSIS}.tar.bz2 ]; then
128 log "Cloning libcmsis sources..."
129 git clone git://git.open-bldc.org/libcmsis.git
131 git archive --format=tar --prefix=libcmsis-${LIBCMSIS}/ ${LIBCMSIS} | \
132 bzip2 --stdout > ../libcmsis-${LIBCMSIS}.tar.bz2
137 if [ ! -e libstm32-${LIBSTM32}.tar.bz2 ]; then
138 log "Cloning libstm32 sources..."
139 git clone git://git.open-bldc.org/libstm32.git
141 git archive --format=tar --prefix=libstm32-${LIBSTM32}/ ${LIBSTM32} | \
142 bzip2 --stdout > ../libstm32-${LIBSTM32}.tar.bz2
147 if [ ! -e libstm32usb-${LIBSTM32USB}.tar.bz2 ]; then
148 log "Cloning libstm32usb sources..."
149 git clone git://git.open-bldc.org/libstm32usb.git
151 git archive --format=tar --prefix=libstm32usb-${LIBSTM32USB}/ ${LIBSTM32USB} | \
152 bzip2 --stdout > ../libstm32usb-${LIBSTM32USB}.tar.bz2
158 if [ ${LIBOPENSTM32_EN} != 0 ]; then
159 if [ ! -e libopenstm32-${LIBOPENSTM32}.tar.bz2 ]; then
160 log "Cloning libopenstm32 sources..."
161 git clone git://libopenstm32.git.sourceforge.net/gitroot/libopenstm32/libopenstm32
163 git archive --format=tar --prefix=libopenstm32-${LIBOPENSTM32}/ ${LIBOPENSTM32} | \
164 bzip2 --stdout > ../libopenstm32-${LIBOPENSTM32}.tar.bz2
172 if [ ! -e build ]; then
176 if [ ! -e ${STAMPS}/${BINUTILS}.build ]; then
179 log "Configuring ${BINUTILS}"
180 ../${BINUTILS}/configure --target=${TARGET} \
189 log "Building ${BINUTILS}"
191 install ${BINUTILS} install
193 log "Cleaning up ${BINUTILS}"
194 touch ${STAMPS}/${BINUTILS}.build
195 rm -rf build/* ${BINUTILS}
198 if [ ! -e ${STAMPS}/${GCC}-boot.build ]; then
201 log "Configuring ${GCC}-boot"
202 ../${GCC}/configure --target=${TARGET} \
206 --enable-languages="c" \
215 log "Building ${GCC}-boot"
216 make ${MAKEFLAGS} all-gcc
217 install ${GCC}-boot install-gcc
219 log "Cleaning up ${GCC}-boot"
220 touch ${STAMPS}/${GCC}-boot.build
221 rm -rf build/* ${GCC}
224 if [ ! -e ${STAMPS}/${NEWLIB}.build ]; then
227 log "Configuring ${NEWLIB}"
228 ../${NEWLIB}/configure --target=${TARGET} \
236 --disable-newlib-supplied-syscalls
237 log "Building ${NEWLIB}"
239 install ${NEWLIB} install
241 log "Cleaning up ${NEWLIB}"
242 touch ${STAMPS}/${NEWLIB}.build
243 rm -rf build/* ${NEWLIB}
246 # Yes, you need to build gcc again!
247 if [ ! -e ${STAMPS}/${GCC}.build ]; then
250 log "Configuring ${GCC}"
251 ../${GCC}/configure --target=${TARGET} \
255 --enable-languages="c,c++" \
263 log "Building ${GCC}"
265 install ${GCC} install
267 log "Cleaning up ${GCC}"
268 touch ${STAMPS}/${GCC}.build
269 rm -rf build/* ${GCC}
272 if [ ! -e ${STAMPS}/${GDB}.build ]; then
275 log "Configuring ${GDB}"
276 ../${GDB}/configure --target=${TARGET} \
282 log "Building ${GDB}"
284 install ${GDB} install
286 log "Cleaning up ${GDB}"
287 touch ${STAMPS}/${GDB}.build
288 rm -rf build/* ${GDB}
291 if [ ${LIBSTM32_EN} != 0 ]; then
292 if [ ! -e .libcmsis-${LIBCMSIS}.build ]; then
293 unpack libcmsis-${LIBCMSIS}
294 cd libcmsis-${LIBCMSIS}
295 log "Building libcmsis-${LIBCMSIS}"
296 make arch_prefix=${TARGET} prefix=${PREFIX}
297 install libcmsis-${LIBCMSIS} arch_prefix=${TARGET} prefix=${PREFIX} install
299 log "Cleaning up libcmsis-${LIBCMSIS}"
300 touch .libcmsis-${LIBCMSIS}.build
301 rm -rf libcmsis-${LIBCMSIS}
304 if [ ! -e .libstm32-${LIBSTM32}.build ]; then
305 unpack libstm32-${LIBSTM32}
306 cd libstm32-${LIBSTM32}
307 log "Building libstm32-${LIBSTM32}"
308 make arch_prefix=${TARGET} prefix=${PREFIX}
309 install libstm32-${LIBSTM32} arch_prefix=${TARGET} prefix=${PREFIX} install
311 log "Cleaning up libstm32-${LIBSTM32}"
312 touch .libstm32-${LIBSTM32}.build
313 rm -rf libstm32-${LIBSTM32}
316 if [ ! -e .libstm32usb-${LIBSTM32USB}.build ]; then
317 unpack libstm32usb-${LIBSTM32USB}
318 cd libstm32usb-${LIBSTM32USB}
319 log "Building libstm32usb-${LIBSTM32USB}"
320 make arch_prefix=${TARGET} prefix=${PREFIX}
321 install libstm32usb-${LIBSTM32USB} arch_prefix=${TARGET} prefix=${PREFIX} install
323 log "Cleaning up libstm32usb-${LIBSTM32USB}"
324 touch .libstm32usb-${LIBSTM32USB}.build
325 rm -rf libstm32usb-${LIBSTM32USB}
329 if [ $LIBOPENSTM32_EN != 0 ]; then
330 unpack libopenstm32-${LIBOPENSTM32}
331 cd libopenstm32-${LIBOPENSTM32}
332 log "Building libopenstm32-${LIBOPENSTM32}"
333 make PREFIX=${TARGET} DESTDIR=${PREFIX}
334 install libopenstm32-${LIBOPENSTM32} PREFIX=${TARGET} DESTDIR=${PREFIX} install
336 log "Cleaning up libopenstm32-${LIBOPENSTM32}"
337 touch .libopenstm32-${LIBOPENSTM32}.build
338 rm -rf libopenstm32-${LIBOPENSTM32}