buildgcc: Fix colors for dash
[coreboot.git] / util / crossgcc / buildgcc
1 #!/bin/sh
2 #
3 # Copyright (C) 2008-2010 by coresystems GmbH
4 # written by Patrick Georgi <patrick.georgi@coresystems.de> and
5 #            Stefan Reinauer <stefan.reinauer@coresystems.de>
6 #
7 # Copyright (C) 2011 by Sage Electronic Engineering
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; version 2 of the License.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
21 #
22
23 CROSSGCC_DATE="October 10th, 2011"
24 CROSSGCC_VERSION="1.05"
25
26 # default settings
27 TARGETDIR=`pwd`/xgcc
28 TARGETARCH=i386-elf
29 DESTDIR=
30
31 # version numbers
32 GMP_VERSION=5.0.2
33 MPFR_VERSION=3.1.0
34 MPC_VERSION=0.9
35 LIBELF_VERSION=0.8.13
36 GCC_VERSION=4.6.1
37 GCC_AUTOCONF_VERSION=2.64
38 BINUTILS_VERSION=2.21.1
39 GDB_VERSION=7.3.1
40 W32API_VERSION=3.17-2
41 W32API_VERSION_SHORT=3.17
42 MINGWRT_VERSION=3.18
43 IASL_VERSION=20110922
44
45 # archive locations
46 GMP_ARCHIVE="ftp://ftp.gmplib.org/pub/gmp-${GMP_VERSION}/gmp-${GMP_VERSION}.tar.bz2"
47 MPFR_ARCHIVE="http://www.mpfr.org/mpfr-${MPFR_VERSION}/mpfr-${MPFR_VERSION}.tar.bz2"
48 MPC_ARCHIVE="http://www.multiprecision.org/mpc/download/mpc-${MPC_VERSION}.tar.gz"
49 LIBELF_ARCHIVE="http://www.mr511.de/software/libelf-${LIBELF_VERSION}.tar.gz"
50 GCC_ARCHIVE="ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-${GCC_VERSION}/gcc-core-${GCC_VERSION}.tar.bz2"
51 BINUTILS_ARCHIVE="http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.bz2"
52 GDB_ARCHIVE="http://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.bz2"
53 W32API_ARCHIVE="http://downloads.sourceforge.net/project/mingw/MinGW/BaseSystem/RuntimeLibrary/Win32-API/w32api-${W32API_VERSION_SHORT}/w32api-${W32API_VERSION}-mingw32-src.tar.lzma"
54 MINGWRT_ARCHIVE="http://downloads.sourceforge.net/project/mingw/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-${MINGWRT_VERSION}/mingwrt-${MINGWRT_VERSION}-mingw32-src.tar.gz"
55 IASL_ARCHIVE="http://www.acpica.org/download/acpica-unix-${IASL_VERSION}.tar.gz"
56
57 GMP_DIR="gmp-${GMP_VERSION}"
58 MPFR_DIR="mpfr-${MPFR_VERSION}"
59 MPC_DIR="mpc-${MPC_VERSION}"
60 LIBELF_DIR="libelf-${LIBELF_VERSION}"
61 GCC_DIR="gcc-${GCC_VERSION}"
62 BINUTILS_DIR="binutils-${BINUTILS_VERSION}"
63 GDB_DIR="gdb-${GDB_VERSION}"
64 W32API_DIR="w32api-${W32API_VERSION}-mingw32"
65 MINGWRT_DIR="mingwrt-${MINGWRT_VERSION}-mingw32"
66 IASL_DIR="acpica-unix-${IASL_VERSION}"
67
68 SAVETEMPS=0
69 SKIPGDB=0
70
71 red='\033[0;31m'
72 RED='\033[1;31m'
73 green='\033[0;32m'
74 GREEN='\033[1;32m'
75 blue='\033[0;34m'
76 BLUE='\033[1;34m'
77 cyan='\033[0;36m'
78 CYAN='\033[1;36m'
79 NC='\033[0m' # No Color
80
81 searchgnu()
82 {
83         # $1 short name
84         # result: GNU version of that tool on stdout
85         #         or no output if no GNU version was found
86         for i in "$1" "g$1" "gnu$1"; do
87                 if test -x "`which $i 2>/dev/null`"; then
88                         if test `$i --version 2>/dev/null |grep -c GNU` -gt 0; then
89                                 echo $i
90                                 return
91                         fi
92                 fi
93         done
94         printf "${RED}ERROR:${red} Missing toolchain: $1${NC}\n" >&2
95         exit 1
96 }
97
98 TAR=`searchgnu tar` || exit $?
99 PATCH=`searchgnu patch` || exit $?
100 MAKE=`searchgnu make` || exit $?
101
102 cleanup()
103 {
104         printf "Cleaning up temporary files... "
105         rm -rf build-* combined gcc-* gmp-* mpfr-* mpc-* libelf-* binutils-* gdb-* w32api-* mingwrt-* acpica-*
106         printf "${green}ok${NC}\n"
107 }
108
109 myhelp()
110 {
111         printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-G]\n"
112         printf "       $0 [-V|--version]\n"
113         printf "       $0 [-h|--help]\n\n"
114
115         printf "Options:\n"
116         printf "    [-V|--version]                print version number and exit\n"
117         printf "    [-h|--help]                   print this help and exit\n"
118         printf "    [-c|--clean]                  remove temporary files before build\n"
119         printf "    [-t|--savetemps]              don't remove temporary files after build\n"
120         printf "    [-j|--jobs <num>]             run <num> jobs in parallel in make\n"
121         printf "    [-p|--platform <platform>]    target platform to build cross compiler for\n"
122         printf "                                  (defaults to $TARGETARCH)\n"
123         printf "    [-d|--directory <target dir>] target directory to install cross compiler to\n"
124         printf "                                  (defaults to $TARGETDIR)\n\n"
125         printf "    [-D|--destdir <dest dir>]     destination directory to install cross compiler to\n"
126         printf "                                  (for RPM builds, default unset)\n\n"
127         printf "    [-G|--skip-gdb]               don't build GNU debugger\n"
128 }
129
130 myversion()
131 {
132         # version tag is always printed, so just print the license here
133
134         cat << EOF
135 Copyright (C) 2008-2010 by coresystems GmbH
136 Copyright (C) 2011 by Sage Electronic Engineering
137
138 This program is free software; you can redistribute it and/or modify
139 it under the terms of the GNU General Public License as published by
140 the Free Software Foundation; version 2 of the License.
141
142 This program is distributed in the hope that it will be useful,
143 but WITHOUT ANY WARRANTY; without even the implied warranty of
144 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
145 GNU General Public License for more details.
146
147 EOF
148 }
149
150 printf "${blue}Welcome to the ${red}coreboot${blue} cross toolchain builder v$CROSSGCC_VERSION ($CROSSGCC_DATE)${NC}\n\n"
151
152 # Look if we have getopt. If not, build it.
153 export PATH=$PATH:.
154 getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
155
156 # parse parameters.. try to find out whether we're running GNU getopt
157 getoptbrand="`getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,'`"
158 if [ "${getoptbrand}" = "getopt" ]; then
159         # Detected GNU getopt that supports long options.
160         args=`getopt -l version,help,clean,directory:,platform:,jobs:,destdir:,savetemps,skip-gdb Vhcd:p:j:D:tG -- "$@"`
161         eval set "$args"
162 else
163         # Detected non-GNU getopt
164         args=`getopt Vhcd:p:j:D:tG $*`
165         set -- $args
166 fi
167
168 if [ $? != 0 ]; then
169         myhelp
170         exit 1
171 fi
172
173 while true ; do
174         case "$1" in
175                 -V|--version)   shift; myversion; exit 0;;
176                 -h|--help)      shift; myhelp; exit 0;;
177                 -c|--clean)     shift; cleanup;;
178                 -t|--savetemps) shift; SAVETEMPS=1;;
179                 -d|--directory) shift; TARGETDIR="$1"; shift;;
180                 -p|--platform)  shift; TARGETARCH="$1"; shift;;
181                 -D|--destdir)   shift; DESTDIR="$1"; shift;;
182                 -j|--jobs)      shift; JOBS="-j $1"; shift;;
183                 -G|--skip-gdb)  shift; SKIPGDB=1;;
184                 --)             shift; break;;
185                 -*)             printf "Invalid option\n\n"; myhelp; exit 1;;
186                 *)              break;;
187         esac
188 done
189
190 GDB_PACKAGE="GDB"
191 if [ $SKIPGDB -eq 1 ]; then
192         printf "Will skip GDB ... ${green}ok${NC}\n"
193         GDB_ARCHIVE=""
194         GDB_PACKAGE=""
195 fi
196
197 MINGW_ARCHIVES=""
198 if [ "$TARGETARCH" = "i386-mingw32" ]; then
199         MINGW_ARCHIVES="$W32API_ARCHIVE $MINGWRT_ARCHIVE"
200 fi
201
202 # coreboot does not like the GOLD linker
203 # USE_GOLD="--enable-gold"
204 USE_GOLD=""
205 GCC_OPTIONS="--enable-lto"
206
207 if [ ${GCC_VERSION} = "4.6.2" ]; then
208   if [ ! -r tarballs/gcc-core-${GCC_VERSION}.tar.bz2 ]; then
209     printf "Pre-Release GCC ${GCC_VERSION}, checking out subversion trunk\n"
210     mkdir -p tarballs/.tmp
211     cd tarballs/.tmp
212     rm -rf gcc-${GCC_VERSION}
213     svn export -q svn://gcc.gnu.org/svn/gcc/trunk gcc-${GCC_VERSION}
214     printf "done. Now creating tar ball...\n"
215     tar cjf ../gcc-core-${GCC_VERSION}.tar.bz2 gcc-${GCC_VERSION}
216     printf "done. Now cleaning up...\n"
217     cd ..
218     rm -rf .tmp
219     cd ..
220     printf "done.\n"
221   fi
222 fi
223
224 printf "Downloading tar balls ... \n"
225 mkdir -p tarballs
226 for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE $MINGW_ARCHIVES $IASL_ARCHIVE; do
227         FILE=`basename $ARCHIVE`
228         printf " * $FILE "
229         test -f tarballs/$FILE && printf "(cached)" || (
230                 printf "(downloading)"
231                 cd tarballs
232                 wget -q $ARCHIVE
233         )
234         test -f tarballs/$FILE || printf "\n${RED}Failed to download $FILE.${red}\n"
235         test -f tarballs/$FILE || exit 1
236         printf "\n"
237 done
238 printf "Downloaded tar balls ... "
239 printf "${green}ok${NC}\n"
240
241 MINGW_PACKAGES=""
242 if [ "$TARGETARCH" = "i386-mingw32" ]; then
243         MINGW_PACKAGES="W32API MINGWRT"
244 fi
245
246 printf "Unpacking and patching ... \n"
247 for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS $GDB_PACKAGE $MINGW_PACKAGES IASL; do
248         archive=$PACKAGE"_ARCHIVE"
249         archive="`eval echo '$'$archive`"
250         dir=$PACKAGE"_DIR"
251         dir="`eval echo '$'${dir}`"
252         test -d ${dir} || (
253                 printf " * `basename $archive`\n"
254                 FLAGS=zxf
255                 suffix=`echo $archive | sed 's,.*\.,,'`
256                 test "$suffix" = "gz" && FLAGS=zxf
257                 test "$suffix" = "bz2" && FLAGS=jxf
258                 test "$suffix" = "lzma" && FLAGS="--lzma -xf"
259                 $TAR $FLAGS tarballs/`basename $archive`
260                 for patch in patches/${dir}_*.patch; do
261                         test -r $patch || continue
262                         printf "   o `basename $patch`\n"
263                         $PATCH -s -N -p0 < `echo $patch`
264                 done
265         )
266 done
267 printf "Unpacked and patched ... "
268 printf "${green}ok${NC}\n"
269
270 if [ "$TARGETARCH" = "i386-mingw32" ]; then
271         mkdir -p $TARGETDIR/i386-mingw32/sys-include
272         mv $MINGWRT_DIR/include/* $W32API_DIR/include/* $TARGETDIR/i386-mingw32/sys-include
273 fi
274
275 CC=cc
276 if [ `uname` = "Darwin" ]; then
277         #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix"
278
279         # generally the OS X compiler can create x64 binaries.
280         # Per default it generated i386 binaries in 10.5 and x64
281         # binaries in 10.6 (even if the kernel is 32bit)
282         # For some weird reason, 10.5 autodetects an ABI=64 though
283         # so we're setting the ABI explicitly here.
284         if [ `sysctl -n hw.optional.x86_64` -eq 1 ]; then
285                 OPTIONS="ABI=64"
286         else
287                 OPTIONS="ABI=32"
288         fi
289
290         # In Xcode 4 the default compiler was switched to gcc-llvm.
291         # However, this compiler fails to compile gcc 4.6.x. As a
292         # workaround it's possible to compile gcc with gcc-4.2 or
293         # clang.
294         if $CC -v 2>&1 | grep -q LLVM; then
295                 CC=clang
296         fi
297 fi
298
299 mkdir -p build-gmp build-mpfr build-mpc build-libelf build-binutils build-gcc
300 if [ $SKIPGDB -eq 0 ]; then
301         mkdir -p build-gdb
302 fi
303 if [ -f build-gmp/.success ]; then
304         printf "Skipping GMP as it is already built\n"
305 else
306 printf "Building GMP ${GMP_VERSION} ... "
307 (
308         cd build-gmp
309         rm -f .failed
310         ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \
311                 || touch .failed
312         $MAKE $JOBS || touch .failed
313         $MAKE install DESTDIR=$DESTDIR || touch .failed
314         if [ ! -f .failed ]; then touch .success; fi
315 ) > build-gmp/crossgcc-build.log 2>&1
316 test -r build-gmp/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
317 test -r build-gmp/.failed && exit 1
318 fi
319
320 #if [ "$DESTDIR" != "" -a ! -x $TARGETDIR ]; then
321 #       # create compat link
322 #       ln -s $DESTDIR$TARGETDIR $TARGETDIR
323 #fi
324
325 # Now set CFLAGS to match GMP CFLAGS but strip out -pedantic
326 # as GCC 4.6.x fails if it's there.
327 HOSTCFLAGS=`grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2 |\
328             sed s,-pedantic,,`
329
330 if [ -f build-mpfr/.success ]; then
331         printf "Skipping MPFR as it is already built\n"
332 else
333 printf "Building MPFR ${MPFR_VERSION} ... "
334 (
335         test `uname` = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
336         cd build-mpfr
337         rm -f .failed
338         ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \
339                 --infodir=$TARGETDIR/info \
340                 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || touch .failed
341         $MAKE $JOBS || touch .failed
342         $MAKE install DESTDIR=$DESTDIR || touch .failed
343
344         # work around build problem of libgmp.la
345         if [ "$DESTDIR" != "" ]; then
346             perl -pi -e "s,$DESTDIR,," $DESTDIR$TARGETDIR/libgmp.la
347         fi
348
349         if [ ! -f .failed ]; then touch .success; fi
350 ) > build-mpfr/crossgcc-build.log 2>&1
351 test -r build-mpfr/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
352 test -r build-mpfr/.failed && exit 1
353 fi
354
355 if [ -f build-mpc/.success ]; then
356         printf "Skipping MPC as it is already built\n"
357 else
358 printf "Building MPC ${MPC_VERSION} ... "
359 (
360         #test `uname` = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
361         cd build-mpc
362         rm -f .failed
363         ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \
364                 --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \
365                 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || touch .failed
366         $MAKE $JOBS || touch .failed
367         $MAKE install DESTDIR=$DESTDIR || touch .failed
368
369         if [ ! -f .failed ]; then touch .success; fi
370 ) > build-mpc/crossgcc-build.log 2>&1
371 test -r build-mpc/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
372 test -r build-mpc/.failed && exit 1
373 fi
374
375 if [ -f build-libelf/.success ]; then
376         printf "Skipping libelf as it is already built\n"
377 else
378 printf "Building libelf ${LIBELF_VERSION} ... "
379 (
380         cd build-libelf
381         rm -f .failed
382         echo "$HOSTCFLAGS"
383         CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \
384                 --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed
385         $MAKE $JOBS || touch .failed
386         $MAKE install DESTDIR=$DESTDIR || touch .failed
387
388         if [ ! -f .failed ]; then touch .success; fi
389 ) > build-libelf/crossgcc-build.log 2>&1
390 test -r build-libelf/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
391 test -r build-libelf/.failed && exit 1
392 fi
393
394 if [ -f build-binutils/.success ]; then
395         printf "Skipping binutils as it is already built\n"
396 else
397 printf "Building binutils ${BINUTILS_VERSION} ... "
398 (
399         # What a pain: binutils don't come with configure
400         # script anymore. Create it:
401         cd binutils-${BINUTILS_VERSION}/
402         autoconf
403         cd ..
404         # Now build binutils
405         cd build-binutils
406         rm -f .failed
407         ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR --target=${TARGETARCH} \
408                 --disable-werror --disable-nls $USE_GOLD \
409                 CFLAGS="$HOSTCFLAGS" || touch .failed
410         $MAKE $JOBS || touch .failed
411         $MAKE install DESTDIR=$DESTDIR || touch .failed
412         if [ ! -f .failed ]; then touch .success; fi
413 ) > build-binutils/crossgcc-build.log 2>&1
414 test -r build-binutils/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
415 test -r build-binutils/.failed && exit 1
416 fi
417
418 if [ -f build-gcc/.success ]; then
419         printf "Skipping GCC as it is already built\n"
420 else
421 printf "Building GCC ${GCC_VERSION} ... "
422 (
423         # Even worse than binutils: GCC does not come with configure
424         # script anymore, but also enforces an obsolete autoconf version
425         # to create it. This is a poster child of how autotools help make
426         # software portable.
427         cd gcc-${GCC_VERSION}
428         sed '/dnl Ensure exactly this Autoconf version is used/d' \
429                 config/override.m4 > config/override.m4.new
430         autoconf_version=`autoconf -V | grep "autoconf" | tr ' ' '\n' | tail -1`
431         sed "s/${GCC_AUTOCONF_VERSION}/${autoconf_version}/g" \
432                 config/override.m4.new > config/override.m4
433         autoconf
434         cd ..
435         # Now, finally, we can build gcc:
436         cd build-gcc
437         export PATH=$PATH:$DESTDIR$TARGETDIR/bin
438         rm -f .failed
439         # GCC does not honour HOSTCFLAGS at all. CFLAGS are used for
440         # both target and host object files. This is pretty misdesigned.
441         # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET
442         # but it does not seem to work properly. At least the host library
443         # libiberty is not compiled with CFLAGS_FOR_BUILD.
444         CC="$CC" CFLAGS_FOR_TARGET="-O2" CFLAGS="$HOSTCFLAGS" \
445                 CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \
446                 --prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \
447                 --target=${TARGETARCH} --disable-werror --disable-shared \
448                 --disable-libssp --disable-bootstrap --disable-nls \
449                 --disable-libquadmath \
450                 $GCC_OPTIONS --enable-languages="c" $USE_GOLD \
451                 --with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \
452                 --with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \
453                 --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION $CROSSGCC_DATE" \
454                 || touch .failed
455         $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" || touch .failed
456         $MAKE install DESTDIR=$DESTDIR || touch .failed
457         if [ ! -f .failed ]; then touch .success; fi
458 ) > build-gcc/crossgcc-build.log 2>&1
459 test -r build-gcc/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
460 test -r build-gcc/.failed && exit 1
461 fi
462
463 if [ -f build-gdb/.success ]; then
464         printf "Skipping GDB as it is already built\n"
465 elif [ $SKIPGDB -eq 1 ]; then
466         printf "Skipping GDB as requested by command line\n"
467 else
468 printf "Building GDB ${GDB_VERSION} ... "
469 (
470         cd build-gdb
471         export PATH=$PATH:$DESTDIR$TARGETDIR/bin
472         rm -f .failed
473         CFLAGS="$HOSTCFLAGS" ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR --target=${TARGETARCH} \
474                 --without-python --disable-werror --disable-nls
475         $MAKE $JOBS || touch .failed
476         $MAKE install DESTDIR=$DESTDIR || touch .failed
477         if [ ! -f .failed ]; then touch .success; fi
478 ) > build-gdb/crossgcc-build.log 2>&1
479 test -r build-gdb/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
480 test -r build-gdb/.failed && exit 1
481 fi
482
483 if [ -f $IASL_DIR/compiler/.success ]; then
484         printf "Skipping IASL as it is already built\n"
485 else
486 printf "Building IASL ${IASL_VERSION} ... "
487 (
488         cd $IASL_DIR/compiler
489         export PATH=$PATH:$DESTDIR$TARGETDIR/bin
490         rm -f .failed
491         CFLAGS="$HOSTCFLAGS"
492         $MAKE || touch .failed
493         rm -f $DESTDIR$TARGETDIR/bin/iasl || touch .failed
494         cp iasl $DESTDIR$TARGETDIR/bin || touch .failed
495         if [ ! -f .failed ]; then touch .success; fi
496 ) > $IASL_DIR/compiler/crossgcc-build.log 2>&1
497 test -r $IASL_DIR/compiler/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n"
498 test -r $IASL_DIR/compiler/.failed && exit 1
499 fi
500
501 if [ $SAVETEMPS -eq 0 ]; then
502         printf "Cleaning up... "
503         rm -rf ${GMP_DIR} build-gmp
504         rm -rf ${MPFR_DIR} build-mpfr
505         rm -rf ${MPC_DIR} build-mpc
506         rm -rf ${LIBELF_DIR} build-libelf
507         rm -rf ${BINUTILS_DIR} build-binutils
508         rm -rf ${GCC_DIR} build-gcc
509         rm -rf ${GDB_DIR} build-gdb
510         rm -rf ${IASL_DIR}
511         printf "${green}ok${NC}\n"
512 else
513         printf "Leaving temporary files around... ${green}ok${NC}\n"
514 fi
515
516 printf "\n${green}You can now run your $TARGETARCH cross toolchain from $TARGETDIR.${NC}\n"
517
518