]> git.zerfleddert.de Git - proxmark3-svn/blame - tools/install-gnuarm4.sh
There is no proof this fix anything. This could just be out of randomness or subtle...
[proxmark3-svn] / tools / install-gnuarm4.sh
CommitLineData
aa4d9d9b 1#!/bin/bash
2
3# Some things for you to configure
bb06be43 4BINUTILS_VER="2.19.1"
5GCC_VER="4.3.3"
6GDB_VER="6.8"
7NEWLIB_VER="1.17.0"
8GMP_VER="4.2.4"
ead75193 9MPFR_VER="2.4.2"
bb06be43 10INSIGHT_VER="6.8"
aa4d9d9b 11
12# Where you want to install the tools
bb06be43 13if [ "${1}" = "" ]; then
14 echo "Syntax: ${0} </installation/target/directory> [download & build directory (default ${PWD})]"
15 exit 1
16else
17 DESTDIR="${1}"
18fi
aa4d9d9b 19
20# Where do you want to build the tools. This is where the log files
21# will be written (which you can monitor with 'tail' during compilation).
22# You can delete this directory after everything is done.
bb06be43 23if [ ! "${2}" = "" ]; then
24 SRCDIR="${2}"
25else
26 SRCDIR="${PWD}"
27fi
28BUILDDIR=${SRCDIR}/build-gnuarm4
aa4d9d9b 29
30# Where to get each of the toolchain components
d6e91bf0 31BINUTILS=http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VER}.tar.bz2
32GCCCORE=http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-core-${GCC_VER}.tar.bz2
33GPP=http://ftp.gnu.org/gnu/gcc/gcc-${GCC_VER}/gcc-g++-${GCC_VER}.tar.bz2
bb06be43 34NEWLIB=ftp://sources.redhat.com/pub/newlib/newlib-${NEWLIB_VER}.tar.gz
35#INSIGHT=ftp://sourceware.org/pub/insight/releases/insight-${INSIGHT_VER}.tar.bz2
36INSIGHT=http://mirrors.kernel.org/sources.redhat.com/insight/releases/insight-${INSIGHT_VER}.tar.bz2
37#INSIGHT=http://www.mirrorservice.org/sites/sources.redhat.com/pub/insight/releases/insight-${INSIGHT_VER}.tar.bz2
38GDB=ftp://sourceware.org/pub/gdb/releases/gdb-${GDB_VER}.tar.bz2
39GMP=http://ftp.sunet.se/pub/gnu/gmp/gmp-${GMP_VER}.tar.bz2
258a9f38 40MPFR=http://mpfr.loria.fr/mpfr-current/mpfr-${MPFR_VER}.tar.bz2
aa4d9d9b 41
42# Common configuration options (i.e., things to pass to 'configure')
43COMMON_CFG="--enable-interwork --target=arm-elf --program-prefix=arm-elf- --prefix=${DESTDIR} --disable-werror --enable-languages=c,c++ --enable-multilib --disable-shared"
44
45# Extra configuration options for each toolchain component
46BINUTILS_CFG=
c3adc9fd 47GCCCORE_CFG="--disable-nls --disable-threads --with-gcc --with-gnu-ld --with-gnu-as --with-dwarf2 --with-newlib --with-headers=${BUILDDIR}/newlib-${NEWLIB_VER}/newlib/libc/include --disable-libssp --disable-libstdcxx-pch --disable-libmudflap --disable-libgomp -v"
aa4d9d9b 48NEWLIB_CFG=
49INSIGHT_CFG=
bb06be43 50GDB_CFG=
51
52# Make flags
53MAKEFLAGS="-j 4"
54
55# wget options
56# -nv: non-verbose but not too quiet (still print errors/warnings)
57# -nc: no-clobber, do not download a file that already exists
58# -t 0: retry indefinitely
59# -a wget.log: append errors/warnings to wget.log file
60# -c continue
61#WGET_OPTS="-nv -nc -t 0 -a wget.log"
62WGET_OPTS="-c -t 0"
aa4d9d9b 63
64# Compiler flags for compiling Newlib (-O2 is already hard-coded)
65NEWLIB_FLAGS="-march=armv4t -mcpu=arm7tdmi -g"
66
67############################################################################
68# End of configuration section. You shouldn't have to modify anything below.
69############################################################################
70
71if [[ `whoami` != "root" ]]; then
bb06be43 72 echo "*** Warning! Not running as root!"
73 echo "Installation may fail if you do not have appropriate permissions!"
aa4d9d9b 74fi
75
bb06be43 76mkdir -p ${BUILDDIR}
aa4d9d9b 77cd ${SRCDIR}
78
c3adc9fd 79if [[ -f all.downloaded ]]; then
80 echo Looks like all downloads are complete, skipping downloads
81else
82 echo Now downloading BINUTILS...
83 wget ${WGET_OPTS} ${BINUTILS}
84
85 echo Now downloading GCC...
86 wget ${WGET_OPTS} ${GCCCORE}
aa4d9d9b 87
c3adc9fd 88 echo Now downloading G++...
89 wget ${WGET_OPTS} ${GPP}
aa4d9d9b 90
c3adc9fd 91 echo Now downloading NEWLIB...
92 wget ${WGET_OPTS} ${NEWLIB}
aa4d9d9b 93
c3adc9fd 94 echo Now downloading INSIGHT...
95 wget ${WGET_OPTS} ${INSIGHT}
aa4d9d9b 96
c3adc9fd 97 echo Now downloading GDB...
98 wget ${WGET_OPTS} ${GDB}
bb06be43 99
c3adc9fd 100 echo Now downloading GMP...
101 wget ${WGET_OPTS} ${GMP}
bb06be43 102
c3adc9fd 103 echo Now downloading MPFR...
104 wget ${WGET_OPTS} ${MPFR}
bb06be43 105
c3adc9fd 106 touch all.downloaded
107fi
aa4d9d9b 108
bb06be43 109cd ${BUILDDIR}
aa4d9d9b 110if [[ -f binutils.built ]]; then
111 echo Looks like BINUTILS was already built.
112else
113 echo Building BINUTILS...
bb06be43 114 tar -xjf ../`basename ${BINUTILS}`
aa4d9d9b 115 echo ___________________ > make.log
116 echo Building binutils... >> make.log
117 cd `find . -maxdepth 1 -type d -name 'binutils*'`
118 mkdir gnuarm
119 cd gnuarm
120 ../configure ${COMMON_CFG} ${BINUTILS_CFG} >> ../../make.log 2>&1
bb06be43 121 make ${MAKEFLAGS} MAKEINFO=`which makeinfo` >> ../../make.log 2>&1
aa4d9d9b 122 make install >> ../../make.log 2>&1
123 cd ../..
124 touch binutils.built
125fi
126
127 echo ___________________ >> make.log
128 echo Adding ${DESTDIR}/bin to PATH >> make.log
129export PATH; PATH=${DESTDIR}/bin:$PATH
130 echo ___________________ >> make.log
131
132if [[ -f gcc.built ]]; then
133 echo Looks like GCC was already built.
134else
135 echo Building GCC...
bb06be43 136 tar -xjf ../`basename ${GCCCORE}`
137 tar -xjf ../`basename ${GPP}`
138 tar -xjf ../`basename ${GMP}`
139 ln -s "${BUILDDIR}/gmp-${GMP_VER}" "${BUILDDIR}/gcc-${GCC_VER}/gmp"
140 tar -xjf ../`basename ${MPFR}`
141 ln -s "${BUILDDIR}/mpfr-${MPFR_VER}" "${BUILDDIR}/gcc-${GCC_VER}/mpfr"
c3adc9fd 142 tar -xzf ../`basename ${NEWLIB}`
bb06be43 143
aa4d9d9b 144 echo ___________________ >> make.log
145
146cat << EOF > gcc.patch
bb06be43 147--- gcc-4.3.3.orig/gcc/config/arm/t-arm-elf
148+++ gcc-4.3.3.mod/gcc/config/arm/t-arm-elf
149@@ -33,8 +33,8 @@
aa4d9d9b 150 # MULTILIB_DIRNAMES += fpu soft
151 # MULTILIB_EXCEPTIONS += *mthumb/*mhard-float*
152 #
153-# MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
154-# MULTILIB_DIRNAMES += normal interwork
155+MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
156+MULTILIB_DIRNAMES += normal interwork
157 #
158 # MULTILIB_OPTIONS += fno-leading-underscore/fleading-underscore
159 # MULTILIB_DIRNAMES += elf under
160EOF
161
162 echo Patching GCC >> make.log
163 cd `find . -maxdepth 1 -type d -name 'gcc*'`
164 patch -p1 < ../gcc.patch
165 echo Building gcc... >> make.log
166 mkdir gnuarm
167 cd gnuarm
168 ../configure ${COMMON_CFG} ${GCCCORE_CFG} >> ../../make.log 2>&1
bb06be43 169 make ${MAKEFLAGS} all-gcc >> ../../make.log 2>&1
aa4d9d9b 170 make install >> ../../make.log 2>&1
171 cd ../..
172 touch gcc.built
173fi
174
175if [[ -f newlib.built ]]; then
176 echo Looks like NEWLIB was already built.
177else
178 echo Building NEWLIB...
aa4d9d9b 179 echo ___________________ >> make.log
180 echo Building newlib... >> make.log
181 cd `find . -maxdepth 1 -type d -name 'newlib*'`
182 mkdir gnuarm
183 cd gnuarm
184 ../configure ${COMMON_CFG} ${NEWLIB_CFG} >> ../../make.log 2>&1
185
186 # This line adds our NEWLIB_CFLAGS to the configure.host file in the
187 # newlib subdirectory. This is the only way I could find to tell Newlib to
188 # compile itself with the -mmarch=armv4t and -mcpu=arm7tdmi flags.
bb06be43 189# sed -i "/^newlib_cflags=/s/=.*\$/=\"${NEWLIB_FLAGS}\"/" ../newlib/configure.host
190 make ${MAKEFLAGS} >> ../../make.log 2>&1
aa4d9d9b 191 make install >> ../../make.log 2>&1
192 cd ../..
193 touch newlib.built
194fi
195
196 echo ___________________ >> make.log
197 echo "Now that newlib is built, second pass for GCC..." >> make.log
198 cd `find . -maxdepth 1 -type d -name 'gcc*'`
199 cd gnuarm
bb06be43 200 make ${MAKEFLAGS} >> ../../make.log 2>&1
aa4d9d9b 201 make install >> ../../make.log 2>&1
202 cd ../..
203
204
205if [[ -f insight.built ]]; then
206 echo Looks like INSIGHT was already built.
207else
208 echo Building INSIGHT...
bb06be43 209 tar -xjf ../`basename ${INSIGHT}`
aa4d9d9b 210 echo ___________________ >> make.log
211 echo Building insight... >> make.log
212 cd `find . -maxdepth 1 -type d -name 'insight*'`
213 mkdir gnuarm
214 cd gnuarm
215 ../configure ${COMMON_CFG} ${INSIGHT_CFG} >> ../../make.log 2>&1
bb06be43 216 make ${MAKEFLAGS} >> ../../make.log 2>&1
aa4d9d9b 217 make install >> ../../make.log 2>&1
218 cd ../..
219 touch insight.built
220fi
221
bb06be43 222if [[ -f gdb.built ]]; then
223 echo Looks like GDB was already built.
224else
225 echo Building GDB...
226 tar -xjf ../`basename ${GDB}`
227 echo ___________________ >> make.log
228 echo Building insight... >> make.log
229 cd `find . -maxdepth 1 -type d -name 'gdb*'`
230 mkdir gnuarm
231 cd gnuarm
232 ../configure ${COMMON_CFG} ${GDB_CFG} >> ../../make.log 2>&1
233 make ${MAKEFLAGS} >> ../../make.log 2>&1
234 make install >> ../../make.log 2>&1
235 cd ../..
236 touch gdb.built
237fi
238
aa4d9d9b 239echo ___________________ >> make.log
240echo Build complete. >> make.log
241
242cd ${DESTDIR}
243chmod -R a+rX .
244
bb06be43 245echo Downloaded archives are in ${SRCDIR}
246echo build driectory: ${BUILDDIR}
247echo set environment variable ARMLIB to ${DESTDIR}/lib/gcc/arm-elf/4.3.3/interwork for Makefile.linux
aa4d9d9b 248exit 0
Impressum, Datenschutz