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