blob: 3d8818a80563db4880f4aaf1315bc7ba6ff00d0e [file] [log] [blame]
Stefan Reinauer074d9132009-09-26 16:43:17 +00001#!/bin/bash
2#
Stefan Reinauer5f1ad892010-05-17 11:02:25 +00003# Copyright (C) 2008-2010 by coresystems GmbH
Stefan Reinauer074d9132009-09-26 16:43:17 +00004# written by Patrick Georgi <patrick.georgi@coresystems.de> and
5# Stefan Reinauer <stefan.reinauer@coresystems.de>
Stefan Reinauer14e22772010-04-27 06:56:47 +00006#
Stefan Reinauer074d9132009-09-26 16:43:17 +00007# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; version 2 of the License.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19#
20
Marc Jones36932662010-12-03 00:45:56 +000021CROSSGCC_DATE="November 16th, 2010"
22CROSSGCC_VERSION="1.02"
Stefan Reinauer074d9132009-09-26 16:43:17 +000023
24# default settings
25TARGETDIR=`pwd`/xgcc
26TARGETARCH=i386-elf
27DESTDIR=
28
29# version numbers
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000030GMP_VERSION=5.0.1
Marc Jones36932662010-12-03 00:45:56 +000031MPFR_VERSION=3.0.0
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000032MPC_VERSION=0.8.2
33LIBELF_VERSION=0.8.13
Marc Jones36932662010-12-03 00:45:56 +000034GCC_VERSION=4.5.1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000035BINUTILS_VERSION=2.20.1
Marc Jones36932662010-12-03 00:45:56 +000036GDB_VERSION=7.2
37W32API_VERSION=3.15
Patrick Georgi73166c72010-04-14 20:42:42 +000038MINGWRT_VERSION=3.18
Stefan Reinauer074d9132009-09-26 16:43:17 +000039
40# archive locations
41GMP_ARCHIVE="ftp://ftp.gmplib.org/pub/gmp-${GMP_VERSION}/gmp-${GMP_VERSION}.tar.bz2"
Peter Stuge85e68702009-12-13 13:39:01 +000042MPFR_ARCHIVE="http://www.mpfr.org/mpfr-${MPFR_VERSION}/mpfr-${MPFR_VERSION}.tar.bz2"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000043MPC_ARCHIVE="http://www.multiprecision.org/mpc/download/mpc-${MPC_VERSION}.tar.gz"
44LIBELF_ARCHIVE="http://www.mr511.de/software/libelf-${LIBELF_VERSION}.tar.gz"
Stefan Reinauer074d9132009-09-26 16:43:17 +000045GCC_ARCHIVE="ftp://ftp.gwdg.de/pub/gnu/ftp/gnu/gcc/gcc-${GCC_VERSION}/gcc-core-${GCC_VERSION}.tar.bz2"
46BINUTILS_ARCHIVE="http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.bz2"
47GDB_ARCHIVE="http://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.bz2"
Marc Jones36932662010-12-03 00:45:56 +000048W32API_ARCHIVE="http://downloads.sourceforge.net/project/mingw/MinGW/BaseSystem/RuntimeLibrary/Win32-API/w32api-${W32API_VERSION}/w32api-${W32API_VERSION}-mingw32-src.tar.gz"
49MINGWRT_ARCHIVE="http://downloads.sourceforge.net/project/mingw/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-${MINGWRT_VERSION}/mingwrt-${MINGWRT_VERSION}-mingw32-src.tar.gz"
Stefan Reinauer074d9132009-09-26 16:43:17 +000050
51GMP_DIR="gmp-${GMP_VERSION}"
52MPFR_DIR="mpfr-${MPFR_VERSION}"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000053MPC_DIR="mpc-${MPC_VERSION}"
54LIBELF_DIR="libelf-${LIBELF_VERSION}"
Stefan Reinauer074d9132009-09-26 16:43:17 +000055GCC_DIR="gcc-${GCC_VERSION}"
56BINUTILS_DIR="binutils-${BINUTILS_VERSION}"
57GDB_DIR="gdb-${GDB_VERSION}"
Stefan Reinauer6ade1612010-01-16 16:44:20 +000058W32API_DIR="w32api-${W32API_VERSION}-mingw32"
59MINGWRT_DIR="mingwrt-${MINGWRT_VERSION}-mingw32"
Stefan Reinauer074d9132009-09-26 16:43:17 +000060
61SAVETEMPS=0
62
63red='\e[0;31m'
64RED='\e[1;31m'
65green='\e[0;32m'
66GREEN='\e[1;32m'
67blue='\e[0;34m'
68BLUE='\e[1;34m'
69cyan='\e[0;36m'
70CYAN='\e[1;36m'
71NC='\e[0m' # No Color
72
73searchgnu()
74{
75 # $1 short name
76 # result: GNU version of that tool on stdout
77 # or no output if no GNU version was found
78 for i in "$1" "g$1" "gnu$1"; do
79 if test -x "`which $i 2>/dev/null`"; then
80 if test `$i --version 2>/dev/null |grep -c GNU` -gt 0; then
81 echo $i
82 return
83 fi
84 fi
85 done
86 printf "${RED}ERROR:${red} Missing toolchain: $1${NC}\n" >&2
87 exit 1
88}
89
90TAR=`searchgnu tar`
91PATCH=`searchgnu patch`
92MAKE=`searchgnu make`
93
94cleanup()
95{
96 printf "Cleaning up temporary files... "
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000097 rm -rf build-* combined gcc-* gmp-* mpfr-* mpc-* libelf-* binutils-* gdb-* w32api-* mingwrt-*
Stefan Reinauer074d9132009-09-26 16:43:17 +000098 printf "${green}ok${NC}\n"
99}
100
101myhelp()
102{
103 printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>]\n"
104 printf " $0 [-V|--version]\n"
105 printf " $0 [-h|--help]\n\n"
106
107 printf "Options:\n"
108 printf " [-V|--version] print version number and exit\n"
109 printf " [-h|--help] print this help and exit\n"
110 printf " [-c|--clean] remove temporary files before build\n"
111 printf " [-t|--savetemps] don't remove temporary files after build\n"
Patrick Georgi73166c72010-04-14 20:42:42 +0000112 printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000113 printf " [-p|--platform <platform>] target platform to build cross compiler for\n"
114 printf " (defaults to $TARGETARCH)\n"
115 printf " [-d|--directory <target dir>] target directory to install cross compiler to\n"
116 printf " (defaults to $TARGETDIR)\n\n"
117 printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n"
118 printf " (for RPM builds, default unset)\n\n"
119}
120
121myversion()
122{
123 # version tag is always printed, so just print the license here
124
125 cat << EOF
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000126Copyright (C) 2008-2010 by coresystems GmbH
Stefan Reinauer074d9132009-09-26 16:43:17 +0000127
128This program is free software; you can redistribute it and/or modify
129it under the terms of the GNU General Public License as published by
130the Free Software Foundation; version 2 of the License.
131
132This program is distributed in the hope that it will be useful,
133but WITHOUT ANY WARRANTY; without even the implied warranty of
134MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
135GNU General Public License for more details.
136
137EOF
138}
139
140printf "${blue}Welcome to the ${red}coresystems${blue} cross toolchain builder v$CROSSGCC_VERSION ($CROSSGCC_DATE)${NC}\n\n"
141
Patrick Georgi6bba29f2010-01-29 17:40:52 +0000142# Look if we have getopt. If not, build it.
143export PATH=$PATH:.
144getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
145
Stefan Reinauer074d9132009-09-26 16:43:17 +0000146# parse parameters.. try to find out whether we're running GNU getopt
147getoptbrand="`getopt -V`"
148if [ "${getoptbrand:0:6}" == "getopt" ]; then
149 # Detected GNU getopt that supports long options.
Patrick Georgi73166c72010-04-14 20:42:42 +0000150 args=`getopt -l version,help,clean,directory:,platform:,jobs:,destdir:,savetemps Vhcd:p:j:D:t -- "$@"`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000151 eval set "$args"
152else
153 # Detected non-GNU getopt
Patrick Georgi73166c72010-04-14 20:42:42 +0000154 args=`getopt Vhcd:p:j:D:t $*`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000155 set -- $args
156fi
157
158if [ $? != 0 ]; then
159 myhelp
160 exit 1
161fi
162
163while true ; do
164 case "$1" in
165 -V|--version) shift; myversion; exit 0;;
166 -h|--help) shift; myhelp; exit 0;;
167 -c|--clean) shift; cleanup;;
168 -t|--savetemps) shift; SAVETEMPS=1;;
169 -d|--directory) shift; TARGETDIR="$1"; shift;;
170 -p|--platform) shift; TARGETARCH="$1"; shift;;
171 -D|--destdir) shift; DESTDIR="$1"; shift;;
Patrick Georgi73166c72010-04-14 20:42:42 +0000172 -j|--jobs) shift; JOBS="-j $1"; shift;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000173 --) shift; break;;
174 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
175 *) break;;
176 esac
177done
178
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000179MINGW_ARCHIVES=""
180if [ "$TARGETARCH" = "i386-mingw32" ]; then
181 MINGW_ARCHIVES="$W32API_ARCHIVE $MINGWRT_ARCHIVE"
182fi
183
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000184if [ ${GCC_VERSION} == "4.5.0" -o ${GCC_VERSION} == "4.6.0" ]; then
185 # coreboot does not like the GOLD linker
186 # USE_GOLD="--enable-gold"
187 USE_GOLD=""
188 GCC_OPTIONS="--enable-lto"
189fi
190
191if [ ${GCC_VERSION} == "4.6.0" ]; then
192 if [ ! -r tarballs/gcc-core-${GCC_VERSION}.tar.bz2 ]; then
193 printf "Pre-Release GCC ${GCC_VERSION}, checking out subversion trunk\n"
194 mkdir -p tarballs/.tmp
195 cd tarballs/.tmp
196 rm -rf gcc-${GCC_VERSION}
197 svn export -q svn://gcc.gnu.org/svn/gcc/trunk gcc-${GCC_VERSION}
198 printf "done. Now creating tar ball...\n"
199 tar cjf ../gcc-core-${GCC_VERSION}.tar.bz2 gcc-${GCC_VERSION}
200 printf "done. Now cleaning up...\n"
201 cd ..
202 rm -rf .tmp
203 cd ..
204 printf "done.\n"
205 fi
206fi
207
Stefan Reinauer074d9132009-09-26 16:43:17 +0000208printf "Downloading tar balls ... \n"
209mkdir -p tarballs
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000210for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE $MINGW_ARCHIVES; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000211 FILE=`basename $ARCHIVE`
212 printf " * $FILE "
213 test -f tarballs/$FILE && printf "(cached)" || (
214 printf "(downloading)"
215 cd tarballs
216 wget -q $ARCHIVE
217 )
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000218 test -f tarballs/$FILE || printf "\n${RED}Failed to download $FILE.${red}\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000219 test -f tarballs/$FILE || exit 1
220 printf "\n"
221done
222printf "Downloaded tar balls ... "
223printf "${green}ok${NC}\n"
224
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000225MINGW_PACKAGES=""
226if [ "$TARGETARCH" = "i386-mingw32" ]; then
227 MINGW_PACKAGES="W32API MINGWRT"
228fi
229
Stefan Reinauer074d9132009-09-26 16:43:17 +0000230printf "Unpacking and patching ... \n"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000231for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS GDB $MINGW_PACKAGES; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000232 archive=$PACKAGE"_ARCHIVE"
233 archive=${!archive}
234 dir=$PACKAGE"_DIR"
Stefan Reinauer14e22772010-04-27 06:56:47 +0000235 test -d ${!dir} || (
Stefan Reinauer074d9132009-09-26 16:43:17 +0000236 printf " * `basename $archive`\n"
237 FLAGS=zxf
238 test ${archive:${#archive}-2:2} = "gz" && FLAGS=zxf
239 test ${archive:${#archive}-3:3} = "bz2" && FLAGS=jxf
240 $TAR $FLAGS tarballs/`basename $archive`
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000241 for patch in patches/${!dir}_*.patch; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000242 test -r $patch || continue
243 printf " o `basename $patch`\n"
Patrick Georgi6bba29f2010-01-29 17:40:52 +0000244 $PATCH -s -N -p0 < `echo $patch`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000245 done
246 )
247done
248printf "Unpacked and patched ... "
249printf "${green}ok${NC}\n"
250
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000251if [ "$TARGETARCH" = "i386-mingw32" ]; then
252 mkdir -p $TARGETDIR/i386-mingw32/sys-include
253 mv $MINGWRT_DIR/include/* $W32API_DIR/include/* $TARGETDIR/i386-mingw32/sys-include
254fi
255
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000256if [ `uname` = "Darwin" ]; then
257 #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix"
258
259 # generally the OS X compiler can create x64 binaries.
260 # Per default it generated i386 binaries in 10.5 and x64
261 # binaries in 10.6 (even if the kernel is 32bit)
262 # For some weird reason, 10.5 autodetects an ABI=64 though
263 # so we're setting the ABI explicitly here.
264 if [ `sysctl -n hw.optional.x86_64` -eq 1 ]; then
265 OPTIONS="ABI=64"
266 else
267 OPTIONS="ABI=32"
268 fi
269 # old check:
270 #OPTIONS="ABI=32"
271 #touch .architecture_check.c
272 #gcc .architecture_check.c -c -o .architecture_check.o
273 #ARCH=`file .architecture_check.o |cut -f5 -d\ `
274 #test "$ARCH" = "x86_64" && OPTIONS="ABI=64"
275 #rm .architecture_check.c .architecture_check.o
276fi
277
278mkdir -p build-gmp build-mpfr build-mpc build-libelf build-binutils build-gcc build-gdb
Stefan Reinauer074d9132009-09-26 16:43:17 +0000279if [ -f build-gmp/.success ]; then
280 printf "Skipping GMP as it is already built\n"
281else
282printf "Building GMP ${GMP_VERSION} ... "
283(
284 cd build-gmp
285 rm -f .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000286 ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \
287 || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000288 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000289 $MAKE install DESTDIR=$DESTDIR || touch .failed
290 if [ ! -f .failed ]; then touch .success; fi
291) &> build-gmp/crossgcc-build.log
292test -r build-gmp/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
293test -r build-gmp/.failed && exit 1
294fi
295
296#if [ "$DESTDIR" != "" -a ! -x $TARGETDIR ]; then
297# # create compat link
298# ln -s $DESTDIR$TARGETDIR $TARGETDIR
299#fi
300
301# Now set CFLAGS to match GMP CFLAGS.
302HOSTCFLAGS=`grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2`
303
304if [ -f build-mpfr/.success ]; then
305 printf "Skipping MPFR as it is already built\n"
306else
307printf "Building MPFR ${MPFR_VERSION} ... "
308(
309 test `uname` = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
310 cd build-mpfr
311 rm -f .failed
312 ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \
313 --infodir=$TARGETDIR/info \
314 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000315 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000316 $MAKE install DESTDIR=$DESTDIR || touch .failed
317
318 # work around build problem of libgmp.la
319 if [ "$DESTDIR" != "" ]; then
320 perl -pi -e "s,$DESTDIR,," $DESTDIR$TARGETDIR/libgmp.la
321 fi
322
323 if [ ! -f .failed ]; then touch .success; fi
324) &> build-mpfr/crossgcc-build.log
325test -r build-mpfr/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
326test -r build-mpfr/.failed && exit 1
327fi
328
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000329if [ -f build-mpc/.success ]; then
330 printf "Skipping MPC as it is already built\n"
331else
332printf "Building MPC ${MPC_VERSION} ... "
333(
334 #test `uname` = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
335 cd build-mpc
336 rm -f .failed
337 ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \
338 --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \
339 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || touch .failed
340 $MAKE $JOBS || touch .failed
341 $MAKE install DESTDIR=$DESTDIR || touch .failed
342
343 if [ ! -f .failed ]; then touch .success; fi
344) &> build-mpc/crossgcc-build.log
345test -r build-mpc/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
346test -r build-mpc/.failed && exit 1
347fi
348
349if [ -f build-libelf/.success ]; then
350 printf "Skipping libelf as it is already built\n"
351else
352printf "Building libelf ${LIBELF_VERSION} ... "
353(
354 cd build-libelf
355 rm -f .failed
356 echo "$HOSTCFLAGS"
Marc Jones36932662010-12-03 00:45:56 +0000357 CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000358 --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed
359 $MAKE $JOBS || touch .failed
360 $MAKE install DESTDIR=$DESTDIR || touch .failed
361
362 if [ ! -f .failed ]; then touch .success; fi
363) &> build-libelf/crossgcc-build.log
364test -r build-libelf/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
365test -r build-libelf/.failed && exit 1
366fi
367
Stefan Reinauer074d9132009-09-26 16:43:17 +0000368if [ -f build-binutils/.success ]; then
369 printf "Skipping binutils as it is already built\n"
370else
371printf "Building binutils ${BINUTILS_VERSION} ... "
372(
373 cd build-binutils
374 rm -f .failed
375 ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR --target=${TARGETARCH} \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000376 --disable-werror --disable-nls $USE_GOLD \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000377 CFLAGS="$HOSTCFLAGS" || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000378 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000379 $MAKE install DESTDIR=$DESTDIR || touch .failed
380 if [ ! -f .failed ]; then touch .success; fi
381) &> build-binutils/crossgcc-build.log
382test -r build-binutils/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
383test -r build-binutils/.failed && exit 1
384fi
385
386if [ -f build-gcc/.success ]; then
387 printf "Skipping GCC as it is already built\n"
388else
389printf "Building GCC ${GCC_VERSION} ... "
390(
391 cd build-gcc
Patrick Georgiba3b0eb2010-09-03 08:53:06 +0000392 export PATH=$PATH:$DESTDIR$TARGETDIR/bin
Stefan Reinauer074d9132009-09-26 16:43:17 +0000393 rm -f .failed
394 # GCC does not honour HOSTCFLAGS at all. CFLAGS are used for
395 # both target and host object files. This is pretty misdesigned.
396 # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET
397 # but it does not seem to work properly. At least the host library
398 # libiberty is not compiled with CFLAGS_FOR_BUILD.
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000399 CFLAGS_FOR_TARGET="-O2" CFLAGS="$HOSTCFLAGS" CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000400 --prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000401 --target=${TARGETARCH} --disable-werror --disable-shared \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000402 --disable-libssp --disable-bootstrap --disable-nls \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000403 $GCC_OPTIONS --enable-languages="c" $USE_GOLD \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000404 --with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000405 --with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \
406 --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION $CROSSGCC_DATE" \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000407 || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000408 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000409 $MAKE install DESTDIR=$DESTDIR || touch .failed
410 if [ ! -f .failed ]; then touch .success; fi
411) &> build-gcc/crossgcc-build.log
412test -r build-gcc/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
413test -r build-gcc/.failed && exit 1
414fi
415
416if [ -f build-gdb/.success ]; then
417 printf "Skipping GDB as it is already built\n"
418else
419printf "Building GDB ${GDB_VERSION} ... "
420(
421 cd build-gdb
Patrick Georgiba3b0eb2010-09-03 08:53:06 +0000422 export PATH=$PATH:$DESTDIR$TARGETDIR/bin
Stefan Reinauer074d9132009-09-26 16:43:17 +0000423 rm -f .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000424 CFLAGS="$HOSTCFLAGS" ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR --target=${TARGETARCH} \
425 --without-python --disable-werror --disable-nls
Patrick Georgi73166c72010-04-14 20:42:42 +0000426 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000427 $MAKE install DESTDIR=$DESTDIR || touch .failed
428 if [ ! -f .failed ]; then touch .success; fi
429) &> build-gdb/crossgcc-build.log
430test -r build-gdb/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
431test -r build-gdb/.failed && exit 1
432fi
433
434if [ $SAVETEMPS -eq 0 ]; then
435 printf "Cleaning up... "
436 rm -rf ${GMP_DIR} build-gmp
437 rm -rf ${MPFR_DIR} build-mpfr
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000438 rm -rf ${MPC_DIR} build-mpc
439 rm -rf ${LIBELF_DIR} build-libelf
Stefan Reinauer074d9132009-09-26 16:43:17 +0000440 rm -rf ${BINUTILS_DIR} build-binutils
441 rm -rf ${GCC_DIR} build-gcc
442 rm -rf ${GDB_DIR} build-gdb
443 printf "${green}ok${NC}\n"
444else
445 printf "Leaving temporary files around... ${green}ok${NC}\n"
446fi
447
448printf "\n${green}You can now run your $TARGETARCH cross toolchain from $TARGETDIR.${NC}\n"
449
450