blob: c6d7183a3760632982a5cc6123b3750df46259f4 [file] [log] [blame]
Peter Stuge09377b72011-08-21 06:24:55 +02001#!/bin/sh
Stefan Reinauer074d9132009-09-26 16:43:17 +00002#
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#
Marc Jones2aac3f62011-08-08 16:07:50 -06007# Copyright (C) 2011 by Sage Electronic Engineering
8#
Stefan Reinauer074d9132009-09-26 16:43:17 +00009# 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
Paul Menzela46a7122013-02-23 18:37:27 +010020# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
Stefan Reinauer074d9132009-09-26 16:43:17 +000021#
22
Alexandru Gagniuc87cc49b2014-02-04 10:46:51 -060023CROSSGCC_DATE="February 10th, 2014"
24CROSSGCC_VERSION="1.24"
Stefan Reinauer074d9132009-09-26 16:43:17 +000025
26# default settings
27TARGETDIR=`pwd`/xgcc
28TARGETARCH=i386-elf
29DESTDIR=
30
31# version numbers
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070032GMP_VERSION=5.1.2
33MPFR_VERSION=3.1.2
Idwer Vollering7962fc72012-10-25 02:14:09 +020034MPC_VERSION=1.0.1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000035LIBELF_VERSION=0.8.13
Patrick Georgic8883262013-09-19 10:57:58 +020036GCC_VERSION=4.7.3
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070037GCC_AUTOCONF_VERSION=2.69
38BINUTILS_VERSION=2.23.2
39GDB_VERSION=7.6
Alexandru Gagniuc87cc49b2014-02-04 10:46:51 -060040IASL_VERSION=20140114
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070041PYTHON_VERSION=3.3.2
Idwer Vollering296a0152012-10-26 01:48:04 +020042EXPAT_VERSION=2.1.0
Stefan Reinauer074d9132009-09-26 16:43:17 +000043
44# archive locations
Patrick Georgi6e61ad32012-05-12 23:19:30 +020045GMP_ARCHIVE="http://ftpmirror.gnu.org/gmp/gmp-${GMP_VERSION}.tar.bz2"
46MPFR_ARCHIVE="http://ftpmirror.gnu.org/mpfr/mpfr-${MPFR_VERSION}.tar.bz2"
Idwer Vollering7962fc72012-10-25 02:14:09 +020047MPC_ARCHIVE="http://ftpmirror.gnu.org/mpc/mpc-${MPC_VERSION}.tar.gz"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000048LIBELF_ARCHIVE="http://www.mr511.de/software/libelf-${LIBELF_VERSION}.tar.gz"
Idwer Vollering1cfee0b2012-10-25 02:03:53 +020049GCC_ARCHIVE="http://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2"
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070050BINUTILS_ARCHIVE="http://ftpmirror.gnu.org/binutils/binutils-${BINUTILS_VERSION}.tar.bz2"
Patrick Georgi6e61ad32012-05-12 23:19:30 +020051GDB_ARCHIVE="http://ftpmirror.gnu.org/gdb/gdb-${GDB_VERSION}.tar.bz2"
Idwer Volleringe76d8d72013-04-11 12:01:19 +020052IASL_ARCHIVE="http://www.acpica.org/sites/acpica/files/acpica-unix-${IASL_VERSION}.tar.gz"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +010053PYTHON_ARCHIVE="http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.bz2"
54EXPAT_ARCHIVE="http://downloads.sourceforge.net/sourceforge/expat/expat-${EXPAT_VERSION}.tar.gz"
Stefan Reinauer074d9132009-09-26 16:43:17 +000055
56GMP_DIR="gmp-${GMP_VERSION}"
57MPFR_DIR="mpfr-${MPFR_VERSION}"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000058MPC_DIR="mpc-${MPC_VERSION}"
59LIBELF_DIR="libelf-${LIBELF_VERSION}"
Stefan Reinauer074d9132009-09-26 16:43:17 +000060GCC_DIR="gcc-${GCC_VERSION}"
61BINUTILS_DIR="binutils-${BINUTILS_VERSION}"
62GDB_DIR="gdb-${GDB_VERSION}"
Marc Jones2aac3f62011-08-08 16:07:50 -060063IASL_DIR="acpica-unix-${IASL_VERSION}"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +010064PYTHON_DIR="Python-${PYTHON_VERSION}"
65EXPAT_DIR="expat-${EXPAT_VERSION}"
Stefan Reinauer074d9132009-09-26 16:43:17 +000066
67SAVETEMPS=0
Stefan Reinauer2c3cd122011-11-01 21:43:50 +010068SKIPGDB=1
69SKIPPYTHON=1
Stefan Reinauer074d9132009-09-26 16:43:17 +000070
Patrick Georgi1861ff72011-10-31 12:15:55 +010071red='\033[0;31m'
72RED='\033[1;31m'
73green='\033[0;32m'
74GREEN='\033[1;32m'
75blue='\033[0;34m'
76BLUE='\033[1;34m'
77cyan='\033[0;36m'
78CYAN='\033[1;36m'
79NC='\033[0m' # No Color
Stefan Reinauer074d9132009-09-26 16:43:17 +000080
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070081UNAME=`uname`
82
Patrick Georgi198d23c2012-12-08 08:02:44 +010083normalize_dirs()
84{
85 mkdir -p $DESTDIR$TARGETDIR/lib
86 test -d $DESTDIR$TARGETDIR/lib32 && mv $DESTDIR$TARGETDIR/lib32/* $DESTDIR$TARGETDIR/lib
87 test -d $DESTDIR$TARGETDIR/lib64 && mv $DESTDIR$TARGETDIR/lib64/* $DESTDIR$TARGETDIR/lib
88 rmdir -p $DESTDIR$TARGETDIR/lib32 $DESTDIR$TARGETDIR/lib64
89
90 perl -pi -e "s,/lib32,/lib," $DESTDIR$TARGETDIR/lib/*.la
91 perl -pi -e "s,/lib64,/lib," $DESTDIR$TARGETDIR/lib/*.la
92}
93
Stefan Reinauer074d9132009-09-26 16:43:17 +000094searchgnu()
95{
96 # $1 short name
97 # result: GNU version of that tool on stdout
98 # or no output if no GNU version was found
99 for i in "$1" "g$1" "gnu$1"; do
100 if test -x "`which $i 2>/dev/null`"; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100101 if test `$i --version 2>/dev/null |grep -c GNU` \
102 -gt 0; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000103 echo $i
104 return
105 fi
106 fi
107 done
Zheng Bao36156ff2012-09-28 16:18:58 +0800108 # A workaround for XxxBSD, whose nongnu patch and tar also work.
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700109 if [ $UNAME = "FreeBSD" -o $UNAME = "NetBSD" ]; then
Zheng Bao36156ff2012-09-28 16:18:58 +0800110 if [ $1 != "make" ]; then
111 if test -x "`which $1 2>/dev/null`"; then
112 echo $1
113 return
114 fi
115 fi
116 fi
Stefan Reinauer074d9132009-09-26 16:43:17 +0000117 printf "${RED}ERROR:${red} Missing toolchain: $1${NC}\n" >&2
118 exit 1
119}
120
Patrick Georgi68df8042011-07-17 11:36:10 +0200121TAR=`searchgnu tar` || exit $?
122PATCH=`searchgnu patch` || exit $?
123MAKE=`searchgnu make` || exit $?
Stefan Reinauer074d9132009-09-26 16:43:17 +0000124
Patrick Georgi5fb2b5c2012-05-12 23:25:23 +0200125searchgnu m4 > /dev/null
126searchgnu bison > /dev/null
Patrick Georgi0a3f2392012-11-20 12:04:32 +0100127
128if ! flex --version > /dev/null 2> /dev/null; then
129 printf "${RED}ERROR:${red} Missing toolchain: flex${NC}\n" >&2
130 exit 1
131fi
Patrick Georgi5fb2b5c2012-05-12 23:25:23 +0200132
Stefan Reinauer074d9132009-09-26 16:43:17 +0000133cleanup()
134{
135 printf "Cleaning up temporary files... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200136 rm -rf ${BUILDDIRPREFIX}-* combined gcc-* gmp-* mpfr-* mpc-* libelf-* binutils-*
Patrick Georgi969cd932012-12-07 13:13:53 +0100137 rm -rf gdb-* acpica-* python-* expat-*
Stefan Reinauer074d9132009-09-26 16:43:17 +0000138 printf "${green}ok${NC}\n"
139}
140
141myhelp()
142{
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100143 printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-G] [-S]\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000144 printf " $0 [-V|--version]\n"
145 printf " $0 [-h|--help]\n\n"
146
147 printf "Options:\n"
148 printf " [-V|--version] print version number and exit\n"
149 printf " [-h|--help] print this help and exit\n"
150 printf " [-c|--clean] remove temporary files before build\n"
151 printf " [-t|--savetemps] don't remove temporary files after build\n"
Patrick Georgic1a75b12011-11-04 21:37:14 +0100152 printf " [-y|--ccache] Use ccache when building cross compiler\n"
Patrick Georgi73166c72010-04-14 20:42:42 +0000153 printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000154 printf " [-p|--platform <platform>] target platform to build cross compiler for\n"
155 printf " (defaults to $TARGETARCH)\n"
156 printf " [-d|--directory <target dir>] target directory to install cross compiler to\n"
157 printf " (defaults to $TARGETDIR)\n\n"
158 printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100159 printf " (for RPM builds, default unset)\n"
160 printf " [-G|--gdb] build GNU debugger\n"
161 printf " [-S|--scripting] build scripting support for GDB\n\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000162}
163
164myversion()
165{
166 # version tag is always printed, so just print the license here
167
168 cat << EOF
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000169Copyright (C) 2008-2010 by coresystems GmbH
Marc Jones2aac3f62011-08-08 16:07:50 -0600170Copyright (C) 2011 by Sage Electronic Engineering
Stefan Reinauer074d9132009-09-26 16:43:17 +0000171
172This program is free software; you can redistribute it and/or modify
173it under the terms of the GNU General Public License as published by
174the Free Software Foundation; version 2 of the License.
175
176This program is distributed in the hope that it will be useful,
177but WITHOUT ANY WARRANTY; without even the implied warranty of
178MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
179GNU General Public License for more details.
180
181EOF
182}
183
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700184printf "${blue}Welcome to the ${red}coreboot${blue} cross toolchain builder v$CROSSGCC_VERSION ($CROSSGCC_DATE)${NC}\n\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000185
Patrick Georgi6bba29f2010-01-29 17:40:52 +0000186# Look if we have getopt. If not, build it.
187export PATH=$PATH:.
188getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
189
Stefan Reinauer074d9132009-09-26 16:43:17 +0000190# parse parameters.. try to find out whether we're running GNU getopt
Peter Stuge09377b72011-08-21 06:24:55 +0200191getoptbrand="`getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,'`"
192if [ "${getoptbrand}" = "getopt" ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000193 # Detected GNU getopt that supports long options.
Patrick Georgic1a75b12011-11-04 21:37:14 +0100194 args=`getopt -l version,help,clean,directory:,platform:,jobs:,destdir:,savetemps,skip-gdb,ccache Vhcd:p:j:D:tGy -- "$@"`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000195 eval set "$args"
196else
197 # Detected non-GNU getopt
Patrick Georgic1a75b12011-11-04 21:37:14 +0100198 args=`getopt Vhcd:p:j:D:tGy $*`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000199 set -- $args
200fi
201
202if [ $? != 0 ]; then
203 myhelp
204 exit 1
205fi
206
207while true ; do
208 case "$1" in
209 -V|--version) shift; myversion; exit 0;;
210 -h|--help) shift; myhelp; exit 0;;
Patrick Georgi44af57a2013-12-19 22:06:22 +0100211 -c|--clean) shift; clean=1;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000212 -t|--savetemps) shift; SAVETEMPS=1;;
213 -d|--directory) shift; TARGETDIR="$1"; shift;;
214 -p|--platform) shift; TARGETARCH="$1"; shift;;
215 -D|--destdir) shift; DESTDIR="$1"; shift;;
Patrick Georgi73166c72010-04-14 20:42:42 +0000216 -j|--jobs) shift; JOBS="-j $1"; shift;;
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100217 -G|--gdb) shift; SKIPGDB=0;;
218 -S|--scripting) shift; SKIPPYTHON=0;;
Patrick Georgic1a75b12011-11-04 21:37:14 +0100219 -y|--ccache) shift; USECCACHE=1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200220 --) shift; break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000221 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200222 *) break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000223 esac
224done
225
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700226case "$TARGETARCH" in
David Hubbard5b0420a2013-05-28 16:33:15 -0600227 i386-elf) ;;
228 i386-mingw32) ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700229 i386*) TARGETARCH=i386-elf;;
Patrick Georgic8883262013-09-19 10:57:58 +0200230 arm*) TARGETARCH=armv7-a-eabi;;
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700231 aarch64*) TARGETARCH=aarch64-elf;;
232 *) printf "${red}WARNING: Unsupported architecture $TARGETARCH.${NC}\n\n"; ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700233esac
234
235echo "Target arch is now $TARGETARCH"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200236BUILDDIRPREFIX=build-${TARGETARCH}
237
Patrick Georgi44af57a2013-12-19 22:06:22 +0100238if [ "$clean" = "1" ]; then
239 cleanup
240fi
241
Peter Stugeceacd772011-06-09 04:54:16 +0200242GDB_PACKAGE="GDB"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100243PYTHON_PACKAGE="PYTHON"
244EXPAT_PACKAGE="EXPAT"
Peter Stugeceacd772011-06-09 04:54:16 +0200245if [ $SKIPGDB -eq 1 ]; then
246 printf "Will skip GDB ... ${green}ok${NC}\n"
Peter Stuge0e8ee812011-08-28 11:04:23 +0200247 GDB_ARCHIVE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200248 GDB_PACKAGE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100249 if [ $SKIPPYTHON -eq 0 ]; then
250 printf "Python scripting needs GDB ... disabling ... ${green}ok${NC}\n"
251 SKIPPYTHON=1
252 fi
253fi
254if [ $SKIPPYTHON -eq 1 ]; then
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600255 PYTHON_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100256 PYTHON_PACKAGE=""
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600257 EXPAT_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100258 EXPAT_PACKAGE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200259fi
260
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700261# coreboot does not like the GOLD linker
262# USE_GOLD="--enable-gold"
263USE_GOLD=""
264GCC_OPTIONS="--enable-lto"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000265
Stefan Reinauer074d9132009-09-26 16:43:17 +0000266printf "Downloading tar balls ... \n"
267mkdir -p tarballs
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100268for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100269 $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100270 $IASL_ARCHIVE $PYTHON_ARCHIVE $EXPAT_ARCHIVE; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000271 FILE=`basename $ARCHIVE`
272 printf " * $FILE "
273 test -f tarballs/$FILE && printf "(cached)" || (
274 printf "(downloading)"
275 cd tarballs
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200276 wget --no-check-certificate -q $ARCHIVE
Stefan Reinauer074d9132009-09-26 16:43:17 +0000277 )
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100278 test -f tarballs/$FILE || \
Zheng Bao5b209c02012-09-20 16:09:51 +0800279 printf "\n${RED}Failed to download $FILE.${NC}\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000280 test -f tarballs/$FILE || exit 1
281 printf "\n"
282done
283printf "Downloaded tar balls ... "
284printf "${green}ok${NC}\n"
285
286printf "Unpacking and patching ... \n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100287for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS $PYTHON_PACKAGE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100288 $EXPAT_PACKAGE $GDB_PACKAGE IASL; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000289 archive=$PACKAGE"_ARCHIVE"
Peter Stuge09377b72011-08-21 06:24:55 +0200290 archive="`eval echo '$'$archive`"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000291 dir=$PACKAGE"_DIR"
Peter Stuge09377b72011-08-21 06:24:55 +0200292 dir="`eval echo '$'${dir}`"
Zheng Baof95bb2d2013-12-13 12:30:46 +0800293 test -d ${dir} && test -f ${dir}/.unpack_success || (
Stefan Reinauer074d9132009-09-26 16:43:17 +0000294 printf " * `basename $archive`\n"
295 FLAGS=zxf
Peter Stuge09377b72011-08-21 06:24:55 +0200296 suffix=`echo $archive | sed 's,.*\.,,'`
297 test "$suffix" = "gz" && FLAGS=zxf
298 test "$suffix" = "bz2" && FLAGS=jxf
299 test "$suffix" = "lzma" && FLAGS="--lzma -xf"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000300 $TAR $FLAGS tarballs/`basename $archive`
Peter Stuge09377b72011-08-21 06:24:55 +0200301 for patch in patches/${dir}_*.patch; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000302 test -r $patch || continue
303 printf " o `basename $patch`\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100304 $PATCH -s -N -p0 < `echo $patch` || \
Zheng Bao5b209c02012-09-20 16:09:51 +0800305 printf "\n${RED}Failed $patch.${NC}\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000306 done
Zheng Bao691b313c2013-12-09 14:09:07 +0800307 touch ${dir}/.unpack_success
Stefan Reinauer074d9132009-09-26 16:43:17 +0000308 )
309done
310printf "Unpacked and patched ... "
311printf "${green}ok${NC}\n"
312
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700313CC=cc
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700314if [ $UNAME = "Darwin" ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000315 #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix"
316
317 # generally the OS X compiler can create x64 binaries.
318 # Per default it generated i386 binaries in 10.5 and x64
319 # binaries in 10.6 (even if the kernel is 32bit)
320 # For some weird reason, 10.5 autodetects an ABI=64 though
321 # so we're setting the ABI explicitly here.
Zheng Bao04ceed62012-10-23 19:41:25 +0800322 if [ `sysctl -n hw.optional.x86_64 2>/dev/null` -eq 1 ] 2>/dev/null; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000323 OPTIONS="ABI=64"
324 else
325 OPTIONS="ABI=32"
326 fi
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700327
Stefan Reinauer4266b922012-12-05 16:18:32 -0800328 # In Xcode 4.5.2 the default compiler is clang.
329 # However, this compiler fails to compile gcc 4.7.x. As a
330 # workaround it's possible to compile gcc with llvm-gcc.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700331 if $CC -v 2>&1 | grep -q LLVM; then
Stefan Reinauer4266b922012-12-05 16:18:32 -0800332 CC=llvm-gcc
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700333 fi
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000334fi
335
Patrick Georgic1a75b12011-11-04 21:37:14 +0100336if [ "$USECCACHE" = 1 ]; then
337 CC="ccache $CC"
338fi
339
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200340mkdir -p ${BUILDDIRPREFIX}-gmp ${BUILDDIRPREFIX}-mpfr ${BUILDDIRPREFIX}-mpc ${BUILDDIRPREFIX}-libelf ${BUILDDIRPREFIX}-binutils \
341 ${BUILDDIRPREFIX}-gcc ${BUILDDIRPREFIX}-python ${BUILDDIRPREFIX}-expat
Stefan Reinauer16bd7892012-12-07 23:57:01 +0100342
343mkdir -p $DESTDIR$TARGETDIR/bin
344export PATH=$DESTDIR$TARGETDIR/bin:$PATH
345
Peter Stugeceacd772011-06-09 04:54:16 +0200346if [ $SKIPGDB -eq 0 ]; then
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200347 mkdir -p ${BUILDDIRPREFIX}-gdb
Peter Stugeceacd772011-06-09 04:54:16 +0200348fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200349if [ -f ${BUILDDIRPREFIX}-gmp/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000350 printf "Skipping GMP as it is already built\n"
351else
352printf "Building GMP ${GMP_VERSION} ... "
353(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200354 cd ${BUILDDIRPREFIX}-gmp
Stefan Reinauer074d9132009-09-26 16:43:17 +0000355 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100356 CC="$CC" ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000357 || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000358 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000359 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100360
361 normalize_dirs
362
Stefan Reinauer074d9132009-09-26 16:43:17 +0000363 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200364) > ${BUILDDIRPREFIX}-gmp/crossgcc-build.log 2>&1
365test -r ${BUILDDIRPREFIX}-gmp/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100366 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200367test -r ${BUILDDIRPREFIX}-gmp/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000368fi
369
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700370# Now set CFLAGS to match GMP CFLAGS but strip out -pedantic
371# as GCC 4.6.x fails if it's there.
372HOSTCFLAGS=`grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2 |\
373 sed s,-pedantic,,`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000374
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200375if [ -f ${BUILDDIRPREFIX}-mpfr/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000376 printf "Skipping MPFR as it is already built\n"
377else
378printf "Building MPFR ${MPFR_VERSION} ... "
379(
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700380 test $UNAME = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200381 cd ${BUILDDIRPREFIX}-mpfr
Stefan Reinauer074d9132009-09-26 16:43:17 +0000382 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100383 CC="$CC" ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000384 --infodir=$TARGETDIR/info \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100385 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
386 touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000387 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000388 $MAKE install DESTDIR=$DESTDIR || touch .failed
389
Patrick Georgi198d23c2012-12-08 08:02:44 +0100390 normalize_dirs
391
Stefan Reinauer074d9132009-09-26 16:43:17 +0000392 # work around build problem of libgmp.la
393 if [ "$DESTDIR" != "" ]; then
394 perl -pi -e "s,$DESTDIR,," $DESTDIR$TARGETDIR/libgmp.la
395 fi
396
397 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200398) > ${BUILDDIRPREFIX}-mpfr/crossgcc-build.log 2>&1
399test -r ${BUILDDIRPREFIX}-mpfr/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100400 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200401test -r ${BUILDDIRPREFIX}-mpfr/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000402fi
403
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200404if [ -f ${BUILDDIRPREFIX}-mpc/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000405 printf "Skipping MPC as it is already built\n"
406else
407printf "Building MPC ${MPC_VERSION} ... "
408(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200409 cd ${BUILDDIRPREFIX}-mpc
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000410 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100411 CC="$CC" ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000412 --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100413 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
414 touch .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000415 $MAKE $JOBS || touch .failed
416 $MAKE install DESTDIR=$DESTDIR || touch .failed
417
Patrick Georgi198d23c2012-12-08 08:02:44 +0100418 normalize_dirs
419
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000420 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200421) > ${BUILDDIRPREFIX}-mpc/crossgcc-build.log 2>&1
422test -r ${BUILDDIRPREFIX}-mpc/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100423 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200424test -r ${BUILDDIRPREFIX}-mpc/.failed && exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000425fi
426
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200427if [ -f ${BUILDDIRPREFIX}-libelf/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000428 printf "Skipping libelf as it is already built\n"
429else
430printf "Building libelf ${LIBELF_VERSION} ... "
431(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200432 cd ${BUILDDIRPREFIX}-libelf
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000433 rm -f .failed
434 echo "$HOSTCFLAGS"
Patrick Georgi643c9e82011-11-04 21:30:49 +0100435 CC="$CC" CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100436 ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000437 --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed
438 $MAKE $JOBS || touch .failed
439 $MAKE install DESTDIR=$DESTDIR || touch .failed
440
Patrick Georgi198d23c2012-12-08 08:02:44 +0100441 normalize_dirs
442
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000443 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200444) > ${BUILDDIRPREFIX}-libelf/crossgcc-build.log 2>&1
445test -r ${BUILDDIRPREFIX}-libelf/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100446 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200447test -r ${BUILDDIRPREFIX}-libelf/.failed && exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000448fi
449
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200450if [ -f ${BUILDDIRPREFIX}-binutils/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000451 printf "Skipping binutils as it is already built\n"
452else
453printf "Building binutils ${BINUTILS_VERSION} ... "
454(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700455 # What a pain: binutils don't come with configure
456 # script anymore. Create it:
457 cd binutils-${BINUTILS_VERSION}/
458 autoconf
459 cd ..
460 # Now build binutils
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200461 cd ${BUILDDIRPREFIX}-binutils
Stefan Reinauer074d9132009-09-26 16:43:17 +0000462 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100463 CC="$CC" ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100464 --target=${TARGETARCH} --disable-werror --disable-nls \
465 $USE_GOLD CFLAGS="$HOSTCFLAGS" || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000466 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000467 $MAKE install DESTDIR=$DESTDIR || touch .failed
468 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200469) > ${BUILDDIRPREFIX}-binutils/crossgcc-build.log 2>&1
470test -r ${BUILDDIRPREFIX}-binutils/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100471 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200472test -r ${BUILDDIRPREFIX}-binutils/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000473fi
474
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200475if [ -f ${BUILDDIRPREFIX}-gcc/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000476 printf "Skipping GCC as it is already built\n"
477else
478printf "Building GCC ${GCC_VERSION} ... "
479(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700480 # Even worse than binutils: GCC does not come with configure
481 # script anymore, but also enforces an obsolete autoconf version
482 # to create it. This is a poster child of how autotools help make
483 # software portable.
484 cd gcc-${GCC_VERSION}
485 sed '/dnl Ensure exactly this Autoconf version is used/d' \
486 config/override.m4 > config/override.m4.new
487 autoconf_version=`autoconf -V | grep "autoconf" | tr ' ' '\n' | tail -1`
488 sed "s/${GCC_AUTOCONF_VERSION}/${autoconf_version}/g" \
489 config/override.m4.new > config/override.m4
490 autoconf
491 cd ..
492 # Now, finally, we can build gcc:
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200493 cd ${BUILDDIRPREFIX}-gcc
Stefan Reinauer074d9132009-09-26 16:43:17 +0000494 rm -f .failed
495 # GCC does not honour HOSTCFLAGS at all. CFLAGS are used for
496 # both target and host object files. This is pretty misdesigned.
497 # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET
498 # but it does not seem to work properly. At least the host library
499 # libiberty is not compiled with CFLAGS_FOR_BUILD.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700500 CC="$CC" CFLAGS_FOR_TARGET="-O2" CFLAGS="$HOSTCFLAGS" \
501 CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000502 --prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000503 --target=${TARGETARCH} --disable-werror --disable-shared \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000504 --disable-libssp --disable-bootstrap --disable-nls \
Patrick Georgi969cd932012-12-07 13:13:53 +0100505 --disable-libquadmath --without-headers \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000506 $GCC_OPTIONS --enable-languages="c" $USE_GOLD \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000507 --with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000508 --with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \
509 --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION $CROSSGCC_DATE" \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000510 || touch .failed
Patrick Georgi969cd932012-12-07 13:13:53 +0100511 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-gcc || touch .failed
512 $MAKE install-gcc DESTDIR=$DESTDIR || touch .failed
513
514 if [ "`echo $TARGETARCH | grep -c -- -mingw32`" -eq 0 ]; then
515 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-target-libgcc || touch .failed
516 $MAKE install-target-libgcc DESTDIR=$DESTDIR || touch .failed
517 fi
518
Stefan Reinauer074d9132009-09-26 16:43:17 +0000519 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200520) > ${BUILDDIRPREFIX}-gcc/crossgcc-build.log 2>&1
521test -r ${BUILDDIRPREFIX}-gcc/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100522 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200523test -r ${BUILDDIRPREFIX}-gcc/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000524fi
525
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200526if [ -f ${BUILDDIRPREFIX}-expat/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100527 printf "Skipping Expat as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100528elif [ $SKIPPYTHON -eq 1 ]; then
529 printf "Skipping Expat (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100530else
531printf "Building Expat ${EXPAT_VERSION} ... "
532(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200533 cd ${BUILDDIRPREFIX}-expat
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100534 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100535 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${EXPAT_DIR}/configure --disable-shared \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100536 --prefix=$TARGETDIR --target=${TARGETARCH} || touch .failed
537 $MAKE || touch .failed
538 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100539
540 normalize_dirs
541
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100542 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200543) > ${BUILDDIRPREFIX}-expat/crossgcc-build.log 2>&1
544test -r ${BUILDDIRPREFIX}-expat/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100545 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200546test -r ${BUILDDIRPREFIX}-expat/.failed && exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100547fi
548
549
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200550if [ -f ${BUILDDIRPREFIX}-python/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100551 printf "Skipping Python as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100552elif [ $SKIPPYTHON -eq 1 ]; then
553 printf "Skipping Python (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100554else
555printf "Building Python ${PYTHON_VERSION} ... "
556(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200557 cd ${BUILDDIRPREFIX}-python
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100558 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100559 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${PYTHON_DIR}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100560 --target=${TARGETARCH} || touch .failed
561 $MAKE $JOBS || touch .failed
562 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100563
564 normalize_dirs
565
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100566 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200567) > ${BUILDDIRPREFIX}-python/crossgcc-build.log 2>&1
568test -r ${BUILDDIRPREFIX}-python/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100569 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200570test -r ${BUILDDIRPREFIX}-python/.failed && exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100571fi
572
573
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200574if [ -f ${BUILDDIRPREFIX}-gdb/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000575 printf "Skipping GDB as it is already built\n"
Peter Stugeceacd772011-06-09 04:54:16 +0200576elif [ $SKIPGDB -eq 1 ]; then
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100577 printf "Skipping GDB (GDB support not enabled)\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000578else
579printf "Building GDB ${GDB_VERSION} ... "
580(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200581 cd ${BUILDDIRPREFIX}-gdb
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100582 export PYTHONHOME=$DESTDIR$TARGETDIR
Stefan Reinauer074d9132009-09-26 16:43:17 +0000583 rm -f .failed
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100584 LDFLAGS="-Wl,-rpath,\$\$ORIGIN/../lib/ -L$DESTDIR$TARGETDIR/lib \
585 -lpthread -ldl -lutil" \
Patrick Georgi643c9e82011-11-04 21:30:49 +0100586 CC="$CC" CFLAGS="$HOSTCFLAGS -I$DESTDIR$TARGETDIR/include" \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100587 ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR \
588 --target=${TARGETARCH} --disable-werror --disable-nls
Patrick Georgi73166c72010-04-14 20:42:42 +0000589 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000590 $MAKE install DESTDIR=$DESTDIR || touch .failed
591 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200592) > ${BUILDDIRPREFIX}-gdb/crossgcc-build.log 2>&1
593test -r ${BUILDDIRPREFIX}-gdb/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100594 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200595test -r ${BUILDDIRPREFIX}-gdb/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000596fi
597
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200598if [ -f $IASL_DIR/source/compiler/.success ]; then
Marc Jones2aac3f62011-08-08 16:07:50 -0600599 printf "Skipping IASL as it is already built\n"
600else
601printf "Building IASL ${IASL_VERSION} ... "
602(
Idwer Vollering6b11c8b2012-11-15 21:14:36 +0100603 cd $IASL_DIR/generate/unix
Stefan Reinauer4266b922012-12-05 16:18:32 -0800604 rm -f .failed
Marc Jones2aac3f62011-08-08 16:07:50 -0600605 CFLAGS="$HOSTCFLAGS"
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700606 HOST="_LINUX"
607 test $UNAME = "Darwin" && HOST="_APPLE"
608 test $UNAME = "FreeBSD" && HOST="_FreeBSD"
609 test $UNAME = "Cygwin" && HOST="_CYGWIN"
610 HOST="$HOST" OPT_CFLAGS="-O -D_FORTIFY_SOURCE=2" CFLAGS="$CFLAGS" $MAKE CC="$CC" iasl || touch .failed
Stefan Reinauer4266b922012-12-05 16:18:32 -0800611 rm -f $DESTDIR$TARGETDIR/bin/iasl || touch .failed
Zheng Bao3c4bd912013-08-27 10:23:13 +0800612 cp bin/iasl $DESTDIR$TARGETDIR/bin || touch .failed
Stefan Reinauer4266b922012-12-05 16:18:32 -0800613 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200614) > $IASL_DIR/source/compiler/crossgcc-build.log 2>&1
Stefan Reinauer4266b922012-12-05 16:18:32 -0800615test -r $IASL_DIR/generate/unix/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100616 printf "${green}ok${NC}\n"
Stefan Reinauer4266b922012-12-05 16:18:32 -0800617test -r $IASL_DIR/generate/unix/.failed && exit 1
Marc Jones2aac3f62011-08-08 16:07:50 -0600618fi
619
Zheng Bao30b895f2013-02-06 18:04:40 +0800620rm -f $DESTDIR$TARGETDIR/$0.commit.*
621cp $0 $DESTDIR$TARGETDIR/"$0.commit.`git describe`"
622
Stefan Reinauer074d9132009-09-26 16:43:17 +0000623if [ $SAVETEMPS -eq 0 ]; then
624 printf "Cleaning up... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200625 rm -rf ${GMP_DIR} ${BUILDDIRPREFIX}-gmp
626 rm -rf ${MPFR_DIR} ${BUILDDIRPREFIX}-mpfr
627 rm -rf ${MPC_DIR} ${BUILDDIRPREFIX}-mpc
628 rm -rf ${LIBELF_DIR} ${BUILDDIRPREFIX}-libelf
629 rm -rf ${BINUTILS_DIR} ${BUILDDIRPREFIX}-binutils
630 rm -rf ${GCC_DIR} ${BUILDDIRPREFIX}-gcc
631 rm -rf ${GDB_DIR} ${BUILDDIRPREFIX}-gdb
632 rm -rf ${EXPAT_DIR} ${BUILDDIRPREFIX}-expat
633 rm -rf ${PYTHON_DIR} ${BUILDDIRPREFIX}-python
Marc Jones2aac3f62011-08-08 16:07:50 -0600634 rm -rf ${IASL_DIR}
Stefan Reinauer074d9132009-09-26 16:43:17 +0000635 printf "${green}ok${NC}\n"
636else
637 printf "Leaving temporary files around... ${green}ok${NC}\n"
638fi
639
640printf "\n${green}You can now run your $TARGETARCH cross toolchain from $TARGETDIR.${NC}\n"
641
642