]> git.zerfleddert.de Git - proxmark3-svn/blame - tools/install-gnuarm4.sh
- Added new Makefile.linux in bootrom directory
[proxmark3-svn] / tools / install-gnuarm4.sh
CommitLineData
aa4d9d9b 1#!/bin/bash
2
3# Some things for you to configure
4
5# Where you want to install the tools
6DESTDIR=/usr/local/gnuarm-4.3.0
7
8# Where do you want to build the tools. This is where the log files
9# will be written (which you can monitor with 'tail' during compilation).
10# You can delete this directory after everything is done.
11SRCDIR="/home/lafargue/Documents/Hobbies/RFID/Toolchain/linux"
12
13# Where to get each of the toolchain components
14BINUTILS=ftp://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2
15GCCCORE=ftp://ftp.gnu.org/gnu/gcc/gcc-4.3.0/gcc-core-4.3.0.tar.bz2
16GPP=ftp://ftp.gnu.org/gnu/gcc/gcc-4.3.0/gcc-g++-4.3.0.tar.bz2
17NEWLIB=ftp://sources.redhat.com/pub/newlib/newlib-1.16.0.tar.gz
18#INSIGHT=ftp://sourceware.org/pub/insight/releases/insight-6.8.tar.bz2
19INSIGHT=http://mirrors.kernel.org/sources.redhat.com/insight/releases/insight-6.8.tar.bz2
20#INSIGHT=http://www.mirrorservice.org/sites/sources.redhat.com/pub/insight/releases/insight-6.8.tar.bz2
21
22# Common configuration options (i.e., things to pass to 'configure')
23COMMON_CFG="--enable-interwork --target=arm-elf --program-prefix=arm-elf- --prefix=${DESTDIR} --disable-werror --enable-languages=c,c++ --enable-multilib --disable-shared"
24
25# Extra configuration options for each toolchain component
26BINUTILS_CFG=
27GCCCORE_CFG="--disable-libssp --disable-threads --with-newlib" # Not sure about these last 2 options...there to try to make C++ support work
28NEWLIB_CFG=
29INSIGHT_CFG=
30
31# Compiler flags for compiling Newlib (-O2 is already hard-coded)
32NEWLIB_FLAGS="-march=armv4t -mcpu=arm7tdmi -g"
33
34############################################################################
35# End of configuration section. You shouldn't have to modify anything below.
36############################################################################
37
38if [[ `whoami` != "root" ]]; then
39 echo You must be root to run this script
40 exit 1
41fi
42
43mkdir -p ${SRCDIR}
44cd ${SRCDIR}
45
46if [[ -f `basename ${BINUTILS}` ]]; then
47 echo Looks like BINUTILS has already been downloaded.
48else
49 echo Now downloading BINUTILS...
50 # -nv: non-verbose but not too quiet (still print errors/warnings)
51 # -nc: no-clobber, do not download a file that already exists
52 # -t 0: retry indefinitely
53 # -a wget.log: append errors/warnings to wget.log file
54 wget -nv -nc -t 0 -a wget.log ${BINUTILS}
55fi
56
57if [[ -f `basename ${GCCCORE}` ]]; then
58 echo Looks like GCC has already been downloaded.
59else
60 echo Now downloading GCC...
61 wget -nv -nc -t 0 -a wget.log ${GCCCORE}
62fi
63
64if [[ -f `basename ${GPP}` ]]; then
65 echo Looks like G++ has already been downloaded.
66else
67 echo Now downloading G++...
68 wget -nv -nc -t 0 -a wget.log ${GPP}
69fi
70
71if [[ -f `basename ${NEWLIB}` ]]; then
72 echo Looks like NEWLIB has already been downloaded.
73else
74 echo Now downloading NEWLIB...
75 wget -nv -nc -t 0 -a wget.log ${NEWLIB}
76fi
77
78if [[ -f `basename ${INSIGHT}` ]]; then
79 echo Looks like INSIGHT has already been downloaded.
80else
81 echo Now downloading INSIGHT...
82 wget -nv -nc -t 0 -a wget.log ${INSIGHT}
83fi
84
85if [[ -f binutils.built ]]; then
86 echo Looks like BINUTILS was already built.
87else
88 echo Building BINUTILS...
89 tar -xjf `basename ${BINUTILS}`
90 echo ___________________ > make.log
91 echo Building binutils... >> make.log
92 cd `find . -maxdepth 1 -type d -name 'binutils*'`
93 mkdir gnuarm
94 cd gnuarm
95 ../configure ${COMMON_CFG} ${BINUTILS_CFG} >> ../../make.log 2>&1
96 make MAKEINFO=`which makeinfo` >> ../../make.log 2>&1
97 make install >> ../../make.log 2>&1
98 cd ../..
99 touch binutils.built
100fi
101
102 echo ___________________ >> make.log
103 echo Adding ${DESTDIR}/bin to PATH >> make.log
104export PATH; PATH=${DESTDIR}/bin:$PATH
105 echo ___________________ >> make.log
106
107if [[ -f gcc.built ]]; then
108 echo Looks like GCC was already built.
109else
110 echo Building GCC...
111 tar -xjf `basename ${GCCCORE}`
112 tar -xjf `basename ${GPP}`
113 echo ___________________ >> make.log
114
115cat << EOF > gcc.patch
116--- gcc-4.2.2.orig/gcc/config/arm/t-arm-elf 2006-11-06 13:13:53.000000000 +0100
117+++ gcc-4.2.2.mod/gcc/config/arm/t-arm-elf 2007-10-05 12:13:00.000000000 +0200
118@@ -23,8 +23,8 @@
119 # MULTILIB_DIRNAMES += fpu soft
120 # MULTILIB_EXCEPTIONS += *mthumb/*mhard-float*
121 #
122-# MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
123-# MULTILIB_DIRNAMES += normal interwork
124+MULTILIB_OPTIONS += mno-thumb-interwork/mthumb-interwork
125+MULTILIB_DIRNAMES += normal interwork
126 #
127 # MULTILIB_OPTIONS += fno-leading-underscore/fleading-underscore
128 # MULTILIB_DIRNAMES += elf under
129EOF
130
131 echo Patching GCC >> make.log
132 cd `find . -maxdepth 1 -type d -name 'gcc*'`
133 patch -p1 < ../gcc.patch
134 echo Building gcc... >> make.log
135 mkdir gnuarm
136 cd gnuarm
137 ../configure ${COMMON_CFG} ${GCCCORE_CFG} >> ../../make.log 2>&1
138 make >> ../../make.log 2>&1
139 make install >> ../../make.log 2>&1
140 cd ../..
141 touch gcc.built
142fi
143
144if [[ -f newlib.built ]]; then
145 echo Looks like NEWLIB was already built.
146else
147 echo Building NEWLIB...
148 tar -xzf `basename ${NEWLIB}`
149 echo ___________________ >> make.log
150 echo Building newlib... >> make.log
151 cd `find . -maxdepth 1 -type d -name 'newlib*'`
152 mkdir gnuarm
153 cd gnuarm
154 ../configure ${COMMON_CFG} ${NEWLIB_CFG} >> ../../make.log 2>&1
155
156 # This line adds our NEWLIB_CFLAGS to the configure.host file in the
157 # newlib subdirectory. This is the only way I could find to tell Newlib to
158 # compile itself with the -mmarch=armv4t and -mcpu=arm7tdmi flags.
159 sed -i "/^newlib_cflags=/s/=.*\$/=\"${NEWLIB_FLAGS}\"/" ../newlib/configure.host
160 make >> ../../make.log 2>&1
161 make install >> ../../make.log 2>&1
162 cd ../..
163 touch newlib.built
164fi
165
166 echo ___________________ >> make.log
167 echo "Now that newlib is built, second pass for GCC..." >> make.log
168 cd `find . -maxdepth 1 -type d -name 'gcc*'`
169 cd gnuarm
170 make >> ../../make.log 2>&1
171 make install >> ../../make.log 2>&1
172 cd ../..
173
174
175if [[ -f insight.built ]]; then
176 echo Looks like INSIGHT was already built.
177else
178 echo Building INSIGHT...
179 tar -xjf `basename ${INSIGHT}`
180 echo ___________________ >> make.log
181 echo Building insight... >> make.log
182 cd `find . -maxdepth 1 -type d -name 'insight*'`
183 mkdir gnuarm
184 cd gnuarm
185 ../configure ${COMMON_CFG} ${INSIGHT_CFG} >> ../../make.log 2>&1
186 make >> ../../make.log 2>&1
187 make install >> ../../make.log 2>&1
188 cd ../..
189 touch insight.built
190fi
191
192echo ___________________ >> make.log
193echo Build complete. >> make.log
194
195cd ${DESTDIR}
196chmod -R a+rX .
197
198exit 0
Impressum, Datenschutz