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