blob: e4ddbc24e485cec4feea4579d08c3352dd2547ea [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
Paul Menzele6619422015-02-23 10:33:59 +010023CROSSGCC_DATE="February 23th, 2015"
24CROSSGCC_VERSION="1.26"
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
Paul Menzele6619422015-02-23 10:33:59 +010034MPC_VERSION=1.0.3
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000035LIBELF_VERSION=0.8.13
Patrick Georgid730ca82014-11-19 17:35:28 +010036GCC_VERSION=4.8.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
Andrew Wub67e9a12014-04-28 18:13:44 +0800108 # A workaround for OSX 10.9 and some BSDs, whose nongnu
109 # patch and tar also work.
110 if [ $UNAME = "Darwin" -o $UNAME = "FreeBSD" -o $UNAME = "NetBSD" ]; then
Zheng Bao36156ff2012-09-28 16:18:58 +0800111 if [ $1 != "make" ]; then
112 if test -x "`which $1 2>/dev/null`"; then
113 echo $1
114 return
115 fi
116 fi
117 fi
Stefan Reinauer074d9132009-09-26 16:43:17 +0000118 printf "${RED}ERROR:${red} Missing toolchain: $1${NC}\n" >&2
119 exit 1
120}
121
Patrick Georgi68df8042011-07-17 11:36:10 +0200122TAR=`searchgnu tar` || exit $?
123PATCH=`searchgnu patch` || exit $?
124MAKE=`searchgnu make` || exit $?
Stefan Reinauer074d9132009-09-26 16:43:17 +0000125
Patrick Georgi5fb2b5c2012-05-12 23:25:23 +0200126searchgnu m4 > /dev/null
127searchgnu bison > /dev/null
Patrick Georgi0a3f2392012-11-20 12:04:32 +0100128
129if ! flex --version > /dev/null 2> /dev/null; then
130 printf "${RED}ERROR:${red} Missing toolchain: flex${NC}\n" >&2
131 exit 1
132fi
Patrick Georgi5fb2b5c2012-05-12 23:25:23 +0200133
Stefan Reinauer074d9132009-09-26 16:43:17 +0000134cleanup()
135{
136 printf "Cleaning up temporary files... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200137 rm -rf ${BUILDDIRPREFIX}-* combined gcc-* gmp-* mpfr-* mpc-* libelf-* binutils-*
Patrick Georgi969cd932012-12-07 13:13:53 +0100138 rm -rf gdb-* acpica-* python-* expat-*
Stefan Reinauer074d9132009-09-26 16:43:17 +0000139 printf "${green}ok${NC}\n"
140}
141
142myhelp()
143{
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100144 printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-G] [-S]\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000145 printf " $0 [-V|--version]\n"
146 printf " $0 [-h|--help]\n\n"
147
148 printf "Options:\n"
149 printf " [-V|--version] print version number and exit\n"
150 printf " [-h|--help] print this help and exit\n"
151 printf " [-c|--clean] remove temporary files before build\n"
152 printf " [-t|--savetemps] don't remove temporary files after build\n"
Patrick Georgic1a75b12011-11-04 21:37:14 +0100153 printf " [-y|--ccache] Use ccache when building cross compiler\n"
Patrick Georgi73166c72010-04-14 20:42:42 +0000154 printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000155 printf " [-p|--platform <platform>] target platform to build cross compiler for\n"
156 printf " (defaults to $TARGETARCH)\n"
157 printf " [-d|--directory <target dir>] target directory to install cross compiler to\n"
158 printf " (defaults to $TARGETDIR)\n\n"
159 printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100160 printf " (for RPM builds, default unset)\n"
161 printf " [-G|--gdb] build GNU debugger\n"
162 printf " [-S|--scripting] build scripting support for GDB\n\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000163}
164
165myversion()
166{
167 # version tag is always printed, so just print the license here
168
169 cat << EOF
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000170Copyright (C) 2008-2010 by coresystems GmbH
Marc Jones2aac3f62011-08-08 16:07:50 -0600171Copyright (C) 2011 by Sage Electronic Engineering
Stefan Reinauer074d9132009-09-26 16:43:17 +0000172
173This program is free software; you can redistribute it and/or modify
174it under the terms of the GNU General Public License as published by
175the Free Software Foundation; version 2 of the License.
176
177This program is distributed in the hope that it will be useful,
178but WITHOUT ANY WARRANTY; without even the implied warranty of
179MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
180GNU General Public License for more details.
181
182EOF
183}
184
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700185printf "${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 +0000186
Patrick Georgi6bba29f2010-01-29 17:40:52 +0000187# Look if we have getopt. If not, build it.
188export PATH=$PATH:.
189getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
190
Stefan Reinauer074d9132009-09-26 16:43:17 +0000191# parse parameters.. try to find out whether we're running GNU getopt
Peter Stuge09377b72011-08-21 06:24:55 +0200192getoptbrand="`getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,'`"
193if [ "${getoptbrand}" = "getopt" ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000194 # Detected GNU getopt that supports long options.
Patrick Georgic1a75b12011-11-04 21:37:14 +0100195 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 +0000196 eval set "$args"
197else
198 # Detected non-GNU getopt
Patrick Georgic1a75b12011-11-04 21:37:14 +0100199 args=`getopt Vhcd:p:j:D:tGy $*`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000200 set -- $args
201fi
202
203if [ $? != 0 ]; then
204 myhelp
205 exit 1
206fi
207
208while true ; do
209 case "$1" in
210 -V|--version) shift; myversion; exit 0;;
211 -h|--help) shift; myhelp; exit 0;;
Patrick Georgi44af57a2013-12-19 22:06:22 +0100212 -c|--clean) shift; clean=1;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000213 -t|--savetemps) shift; SAVETEMPS=1;;
214 -d|--directory) shift; TARGETDIR="$1"; shift;;
215 -p|--platform) shift; TARGETARCH="$1"; shift;;
216 -D|--destdir) shift; DESTDIR="$1"; shift;;
Patrick Georgi73166c72010-04-14 20:42:42 +0000217 -j|--jobs) shift; JOBS="-j $1"; shift;;
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100218 -G|--gdb) shift; SKIPGDB=0;;
219 -S|--scripting) shift; SKIPPYTHON=0;;
Patrick Georgic1a75b12011-11-04 21:37:14 +0100220 -y|--ccache) shift; USECCACHE=1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200221 --) shift; break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000222 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200223 *) break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000224 esac
225done
226
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700227case "$TARGETARCH" in
David Hubbard5b0420a2013-05-28 16:33:15 -0600228 i386-elf) ;;
229 i386-mingw32) ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700230 i386*) TARGETARCH=i386-elf;;
Patrick Georgic8883262013-09-19 10:57:58 +0200231 arm*) TARGETARCH=armv7-a-eabi;;
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700232 aarch64*) TARGETARCH=aarch64-elf;;
233 *) printf "${red}WARNING: Unsupported architecture $TARGETARCH.${NC}\n\n"; ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700234esac
235
236echo "Target arch is now $TARGETARCH"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200237BUILDDIRPREFIX=build-${TARGETARCH}
238
Patrick Georgi44af57a2013-12-19 22:06:22 +0100239if [ "$clean" = "1" ]; then
240 cleanup
241fi
242
Peter Stugeceacd772011-06-09 04:54:16 +0200243GDB_PACKAGE="GDB"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100244PYTHON_PACKAGE="PYTHON"
245EXPAT_PACKAGE="EXPAT"
Peter Stugeceacd772011-06-09 04:54:16 +0200246if [ $SKIPGDB -eq 1 ]; then
247 printf "Will skip GDB ... ${green}ok${NC}\n"
Peter Stuge0e8ee812011-08-28 11:04:23 +0200248 GDB_ARCHIVE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200249 GDB_PACKAGE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100250 if [ $SKIPPYTHON -eq 0 ]; then
251 printf "Python scripting needs GDB ... disabling ... ${green}ok${NC}\n"
252 SKIPPYTHON=1
253 fi
254fi
255if [ $SKIPPYTHON -eq 1 ]; then
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600256 PYTHON_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100257 PYTHON_PACKAGE=""
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600258 EXPAT_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100259 EXPAT_PACKAGE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200260fi
261
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700262# coreboot does not like the GOLD linker
263# USE_GOLD="--enable-gold"
264USE_GOLD=""
265GCC_OPTIONS="--enable-lto"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000266
Stefan Reinauer074d9132009-09-26 16:43:17 +0000267printf "Downloading tar balls ... \n"
268mkdir -p tarballs
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100269for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100270 $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100271 $IASL_ARCHIVE $PYTHON_ARCHIVE $EXPAT_ARCHIVE; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000272 FILE=`basename $ARCHIVE`
273 printf " * $FILE "
274 test -f tarballs/$FILE && printf "(cached)" || (
275 printf "(downloading)"
276 cd tarballs
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200277 wget --no-check-certificate -q $ARCHIVE
Stefan Reinauer074d9132009-09-26 16:43:17 +0000278 )
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100279 test -f tarballs/$FILE || \
Zheng Bao5b209c02012-09-20 16:09:51 +0800280 printf "\n${RED}Failed to download $FILE.${NC}\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000281 test -f tarballs/$FILE || exit 1
282 printf "\n"
283done
284printf "Downloaded tar balls ... "
285printf "${green}ok${NC}\n"
286
287printf "Unpacking and patching ... \n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100288for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS $PYTHON_PACKAGE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100289 $EXPAT_PACKAGE $GDB_PACKAGE IASL; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000290 archive=$PACKAGE"_ARCHIVE"
Peter Stuge09377b72011-08-21 06:24:55 +0200291 archive="`eval echo '$'$archive`"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000292 dir=$PACKAGE"_DIR"
Peter Stuge09377b72011-08-21 06:24:55 +0200293 dir="`eval echo '$'${dir}`"
Zheng Baof95bb2d2013-12-13 12:30:46 +0800294 test -d ${dir} && test -f ${dir}/.unpack_success || (
Stefan Reinauer074d9132009-09-26 16:43:17 +0000295 printf " * `basename $archive`\n"
296 FLAGS=zxf
Peter Stuge09377b72011-08-21 06:24:55 +0200297 suffix=`echo $archive | sed 's,.*\.,,'`
298 test "$suffix" = "gz" && FLAGS=zxf
299 test "$suffix" = "bz2" && FLAGS=jxf
300 test "$suffix" = "lzma" && FLAGS="--lzma -xf"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000301 $TAR $FLAGS tarballs/`basename $archive`
Peter Stuge09377b72011-08-21 06:24:55 +0200302 for patch in patches/${dir}_*.patch; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000303 test -r $patch || continue
304 printf " o `basename $patch`\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100305 $PATCH -s -N -p0 < `echo $patch` || \
Zheng Bao5b209c02012-09-20 16:09:51 +0800306 printf "\n${RED}Failed $patch.${NC}\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000307 done
Zheng Bao691b313c2013-12-09 14:09:07 +0800308 touch ${dir}/.unpack_success
Stefan Reinauer074d9132009-09-26 16:43:17 +0000309 )
310done
311printf "Unpacked and patched ... "
312printf "${green}ok${NC}\n"
313
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700314CC=cc
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700315if [ $UNAME = "Darwin" ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000316 #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix"
317
318 # generally the OS X compiler can create x64 binaries.
319 # Per default it generated i386 binaries in 10.5 and x64
320 # binaries in 10.6 (even if the kernel is 32bit)
321 # For some weird reason, 10.5 autodetects an ABI=64 though
322 # so we're setting the ABI explicitly here.
Zheng Bao04ceed62012-10-23 19:41:25 +0800323 if [ `sysctl -n hw.optional.x86_64 2>/dev/null` -eq 1 ] 2>/dev/null; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000324 OPTIONS="ABI=64"
325 else
326 OPTIONS="ABI=32"
327 fi
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700328
Stefan Reinauer4266b922012-12-05 16:18:32 -0800329 # In Xcode 4.5.2 the default compiler is clang.
330 # However, this compiler fails to compile gcc 4.7.x. As a
331 # workaround it's possible to compile gcc with llvm-gcc.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700332 if $CC -v 2>&1 | grep -q LLVM; then
Stefan Reinauer4266b922012-12-05 16:18:32 -0800333 CC=llvm-gcc
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700334 fi
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000335fi
336
Patrick Georgic1a75b12011-11-04 21:37:14 +0100337if [ "$USECCACHE" = 1 ]; then
338 CC="ccache $CC"
339fi
340
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200341mkdir -p ${BUILDDIRPREFIX}-gmp ${BUILDDIRPREFIX}-mpfr ${BUILDDIRPREFIX}-mpc ${BUILDDIRPREFIX}-libelf ${BUILDDIRPREFIX}-binutils \
342 ${BUILDDIRPREFIX}-gcc ${BUILDDIRPREFIX}-python ${BUILDDIRPREFIX}-expat
Stefan Reinauer16bd7892012-12-07 23:57:01 +0100343
344mkdir -p $DESTDIR$TARGETDIR/bin
345export PATH=$DESTDIR$TARGETDIR/bin:$PATH
346
Peter Stugeceacd772011-06-09 04:54:16 +0200347if [ $SKIPGDB -eq 0 ]; then
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200348 mkdir -p ${BUILDDIRPREFIX}-gdb
Peter Stugeceacd772011-06-09 04:54:16 +0200349fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200350if [ -f ${BUILDDIRPREFIX}-gmp/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000351 printf "Skipping GMP as it is already built\n"
352else
353printf "Building GMP ${GMP_VERSION} ... "
354(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200355 cd ${BUILDDIRPREFIX}-gmp
Stefan Reinauer074d9132009-09-26 16:43:17 +0000356 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100357 CC="$CC" ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000358 || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000359 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000360 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100361
362 normalize_dirs
363
Stefan Reinauer074d9132009-09-26 16:43:17 +0000364 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200365) > ${BUILDDIRPREFIX}-gmp/crossgcc-build.log 2>&1
366test -r ${BUILDDIRPREFIX}-gmp/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100367 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200368test -r ${BUILDDIRPREFIX}-gmp/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000369fi
370
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700371# Now set CFLAGS to match GMP CFLAGS but strip out -pedantic
372# as GCC 4.6.x fails if it's there.
373HOSTCFLAGS=`grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2 |\
374 sed s,-pedantic,,`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000375
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200376if [ -f ${BUILDDIRPREFIX}-mpfr/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000377 printf "Skipping MPFR as it is already built\n"
378else
379printf "Building MPFR ${MPFR_VERSION} ... "
380(
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700381 test $UNAME = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200382 cd ${BUILDDIRPREFIX}-mpfr
Stefan Reinauer074d9132009-09-26 16:43:17 +0000383 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100384 CC="$CC" ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000385 --infodir=$TARGETDIR/info \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100386 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
387 touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000388 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000389 $MAKE install DESTDIR=$DESTDIR || touch .failed
390
Patrick Georgi198d23c2012-12-08 08:02:44 +0100391 normalize_dirs
392
Stefan Reinauer074d9132009-09-26 16:43:17 +0000393 # work around build problem of libgmp.la
394 if [ "$DESTDIR" != "" ]; then
395 perl -pi -e "s,$DESTDIR,," $DESTDIR$TARGETDIR/libgmp.la
396 fi
397
398 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200399) > ${BUILDDIRPREFIX}-mpfr/crossgcc-build.log 2>&1
400test -r ${BUILDDIRPREFIX}-mpfr/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100401 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200402test -r ${BUILDDIRPREFIX}-mpfr/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000403fi
404
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200405if [ -f ${BUILDDIRPREFIX}-mpc/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000406 printf "Skipping MPC as it is already built\n"
407else
408printf "Building MPC ${MPC_VERSION} ... "
409(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200410 cd ${BUILDDIRPREFIX}-mpc
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000411 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100412 CC="$CC" ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000413 --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100414 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
415 touch .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000416 $MAKE $JOBS || touch .failed
417 $MAKE install DESTDIR=$DESTDIR || touch .failed
418
Patrick Georgi198d23c2012-12-08 08:02:44 +0100419 normalize_dirs
420
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000421 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200422) > ${BUILDDIRPREFIX}-mpc/crossgcc-build.log 2>&1
423test -r ${BUILDDIRPREFIX}-mpc/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100424 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200425test -r ${BUILDDIRPREFIX}-mpc/.failed && exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000426fi
427
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200428if [ -f ${BUILDDIRPREFIX}-libelf/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000429 printf "Skipping libelf as it is already built\n"
430else
431printf "Building libelf ${LIBELF_VERSION} ... "
432(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200433 cd ${BUILDDIRPREFIX}-libelf
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000434 rm -f .failed
435 echo "$HOSTCFLAGS"
Patrick Georgi643c9e82011-11-04 21:30:49 +0100436 CC="$CC" CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100437 ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000438 --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed
439 $MAKE $JOBS || touch .failed
Scott Duplichan4270a972014-12-12 20:21:40 -0600440 $MAKE install prefix=$DESTDIR$TARGETDIR || touch .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000441
Patrick Georgi198d23c2012-12-08 08:02:44 +0100442 normalize_dirs
443
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000444 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200445) > ${BUILDDIRPREFIX}-libelf/crossgcc-build.log 2>&1
446test -r ${BUILDDIRPREFIX}-libelf/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100447 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200448test -r ${BUILDDIRPREFIX}-libelf/.failed && exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000449fi
450
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200451if [ -f ${BUILDDIRPREFIX}-binutils/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000452 printf "Skipping binutils as it is already built\n"
453else
454printf "Building binutils ${BINUTILS_VERSION} ... "
455(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700456 # What a pain: binutils don't come with configure
457 # script anymore. Create it:
458 cd binutils-${BINUTILS_VERSION}/
459 autoconf
460 cd ..
461 # Now build binutils
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200462 cd ${BUILDDIRPREFIX}-binutils
Stefan Reinauer074d9132009-09-26 16:43:17 +0000463 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100464 CC="$CC" ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100465 --target=${TARGETARCH} --disable-werror --disable-nls \
466 $USE_GOLD CFLAGS="$HOSTCFLAGS" || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000467 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000468 $MAKE install DESTDIR=$DESTDIR || touch .failed
469 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200470) > ${BUILDDIRPREFIX}-binutils/crossgcc-build.log 2>&1
471test -r ${BUILDDIRPREFIX}-binutils/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100472 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200473test -r ${BUILDDIRPREFIX}-binutils/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000474fi
475
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200476if [ -f ${BUILDDIRPREFIX}-gcc/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000477 printf "Skipping GCC as it is already built\n"
478else
479printf "Building GCC ${GCC_VERSION} ... "
480(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700481 # Even worse than binutils: GCC does not come with configure
482 # script anymore, but also enforces an obsolete autoconf version
483 # to create it. This is a poster child of how autotools help make
484 # software portable.
485 cd gcc-${GCC_VERSION}
486 sed '/dnl Ensure exactly this Autoconf version is used/d' \
487 config/override.m4 > config/override.m4.new
488 autoconf_version=`autoconf -V | grep "autoconf" | tr ' ' '\n' | tail -1`
489 sed "s/${GCC_AUTOCONF_VERSION}/${autoconf_version}/g" \
490 config/override.m4.new > config/override.m4
491 autoconf
492 cd ..
493 # Now, finally, we can build gcc:
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200494 cd ${BUILDDIRPREFIX}-gcc
Stefan Reinauer074d9132009-09-26 16:43:17 +0000495 rm -f .failed
496 # GCC does not honour HOSTCFLAGS at all. CFLAGS are used for
497 # both target and host object files. This is pretty misdesigned.
498 # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET
499 # but it does not seem to work properly. At least the host library
500 # libiberty is not compiled with CFLAGS_FOR_BUILD.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700501 CC="$CC" CFLAGS_FOR_TARGET="-O2" CFLAGS="$HOSTCFLAGS" \
502 CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000503 --prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000504 --target=${TARGETARCH} --disable-werror --disable-shared \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000505 --disable-libssp --disable-bootstrap --disable-nls \
Patrick Georgi969cd932012-12-07 13:13:53 +0100506 --disable-libquadmath --without-headers \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000507 $GCC_OPTIONS --enable-languages="c" $USE_GOLD \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000508 --with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000509 --with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \
510 --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION $CROSSGCC_DATE" \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000511 || touch .failed
Patrick Georgi969cd932012-12-07 13:13:53 +0100512 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-gcc || touch .failed
513 $MAKE install-gcc DESTDIR=$DESTDIR || touch .failed
514
515 if [ "`echo $TARGETARCH | grep -c -- -mingw32`" -eq 0 ]; then
516 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-target-libgcc || touch .failed
517 $MAKE install-target-libgcc DESTDIR=$DESTDIR || touch .failed
518 fi
519
Stefan Reinauer074d9132009-09-26 16:43:17 +0000520 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200521) > ${BUILDDIRPREFIX}-gcc/crossgcc-build.log 2>&1
522test -r ${BUILDDIRPREFIX}-gcc/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100523 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200524test -r ${BUILDDIRPREFIX}-gcc/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000525fi
526
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200527if [ -f ${BUILDDIRPREFIX}-expat/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100528 printf "Skipping Expat as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100529elif [ $SKIPPYTHON -eq 1 ]; then
530 printf "Skipping Expat (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100531else
532printf "Building Expat ${EXPAT_VERSION} ... "
533(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200534 cd ${BUILDDIRPREFIX}-expat
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100535 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100536 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${EXPAT_DIR}/configure --disable-shared \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100537 --prefix=$TARGETDIR --target=${TARGETARCH} || touch .failed
538 $MAKE || touch .failed
539 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100540
541 normalize_dirs
542
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100543 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200544) > ${BUILDDIRPREFIX}-expat/crossgcc-build.log 2>&1
545test -r ${BUILDDIRPREFIX}-expat/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100546 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200547test -r ${BUILDDIRPREFIX}-expat/.failed && exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100548fi
549
550
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200551if [ -f ${BUILDDIRPREFIX}-python/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100552 printf "Skipping Python as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100553elif [ $SKIPPYTHON -eq 1 ]; then
554 printf "Skipping Python (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100555else
556printf "Building Python ${PYTHON_VERSION} ... "
557(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200558 cd ${BUILDDIRPREFIX}-python
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100559 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100560 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${PYTHON_DIR}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100561 --target=${TARGETARCH} || touch .failed
562 $MAKE $JOBS || touch .failed
563 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100564
565 normalize_dirs
566
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100567 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200568) > ${BUILDDIRPREFIX}-python/crossgcc-build.log 2>&1
569test -r ${BUILDDIRPREFIX}-python/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100570 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200571test -r ${BUILDDIRPREFIX}-python/.failed && exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100572fi
573
574
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200575if [ -f ${BUILDDIRPREFIX}-gdb/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000576 printf "Skipping GDB as it is already built\n"
Peter Stugeceacd772011-06-09 04:54:16 +0200577elif [ $SKIPGDB -eq 1 ]; then
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100578 printf "Skipping GDB (GDB support not enabled)\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000579else
580printf "Building GDB ${GDB_VERSION} ... "
581(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200582 cd ${BUILDDIRPREFIX}-gdb
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100583 export PYTHONHOME=$DESTDIR$TARGETDIR
Stefan Reinauer074d9132009-09-26 16:43:17 +0000584 rm -f .failed
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100585 LDFLAGS="-Wl,-rpath,\$\$ORIGIN/../lib/ -L$DESTDIR$TARGETDIR/lib \
586 -lpthread -ldl -lutil" \
Patrick Georgi643c9e82011-11-04 21:30:49 +0100587 CC="$CC" CFLAGS="$HOSTCFLAGS -I$DESTDIR$TARGETDIR/include" \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100588 ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR \
589 --target=${TARGETARCH} --disable-werror --disable-nls
Patrick Georgi73166c72010-04-14 20:42:42 +0000590 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000591 $MAKE install DESTDIR=$DESTDIR || touch .failed
592 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200593) > ${BUILDDIRPREFIX}-gdb/crossgcc-build.log 2>&1
594test -r ${BUILDDIRPREFIX}-gdb/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100595 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200596test -r ${BUILDDIRPREFIX}-gdb/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000597fi
598
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200599if [ -f $IASL_DIR/source/compiler/.success ]; then
Marc Jones2aac3f62011-08-08 16:07:50 -0600600 printf "Skipping IASL as it is already built\n"
601else
602printf "Building IASL ${IASL_VERSION} ... "
603(
Idwer Vollering6b11c8b2012-11-15 21:14:36 +0100604 cd $IASL_DIR/generate/unix
Stefan Reinauer4266b922012-12-05 16:18:32 -0800605 rm -f .failed
Marc Jones2aac3f62011-08-08 16:07:50 -0600606 CFLAGS="$HOSTCFLAGS"
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700607 HOST="_LINUX"
608 test $UNAME = "Darwin" && HOST="_APPLE"
609 test $UNAME = "FreeBSD" && HOST="_FreeBSD"
610 test $UNAME = "Cygwin" && HOST="_CYGWIN"
611 HOST="$HOST" OPT_CFLAGS="-O -D_FORTIFY_SOURCE=2" CFLAGS="$CFLAGS" $MAKE CC="$CC" iasl || touch .failed
Stefan Reinauer4266b922012-12-05 16:18:32 -0800612 rm -f $DESTDIR$TARGETDIR/bin/iasl || touch .failed
Zheng Bao3c4bd912013-08-27 10:23:13 +0800613 cp bin/iasl $DESTDIR$TARGETDIR/bin || touch .failed
Stefan Reinauer4266b922012-12-05 16:18:32 -0800614 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200615) > $IASL_DIR/source/compiler/crossgcc-build.log 2>&1
Stefan Reinauer4266b922012-12-05 16:18:32 -0800616test -r $IASL_DIR/generate/unix/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100617 printf "${green}ok${NC}\n"
Stefan Reinauer4266b922012-12-05 16:18:32 -0800618test -r $IASL_DIR/generate/unix/.failed && exit 1
Marc Jones2aac3f62011-08-08 16:07:50 -0600619fi
620
Zheng Bao30b895f2013-02-06 18:04:40 +0800621rm -f $DESTDIR$TARGETDIR/$0.commit.*
622cp $0 $DESTDIR$TARGETDIR/"$0.commit.`git describe`"
623
Stefan Reinauer074d9132009-09-26 16:43:17 +0000624if [ $SAVETEMPS -eq 0 ]; then
625 printf "Cleaning up... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200626 rm -rf ${GMP_DIR} ${BUILDDIRPREFIX}-gmp
627 rm -rf ${MPFR_DIR} ${BUILDDIRPREFIX}-mpfr
628 rm -rf ${MPC_DIR} ${BUILDDIRPREFIX}-mpc
629 rm -rf ${LIBELF_DIR} ${BUILDDIRPREFIX}-libelf
630 rm -rf ${BINUTILS_DIR} ${BUILDDIRPREFIX}-binutils
631 rm -rf ${GCC_DIR} ${BUILDDIRPREFIX}-gcc
632 rm -rf ${GDB_DIR} ${BUILDDIRPREFIX}-gdb
633 rm -rf ${EXPAT_DIR} ${BUILDDIRPREFIX}-expat
634 rm -rf ${PYTHON_DIR} ${BUILDDIRPREFIX}-python
Marc Jones2aac3f62011-08-08 16:07:50 -0600635 rm -rf ${IASL_DIR}
Stefan Reinauer074d9132009-09-26 16:43:17 +0000636 printf "${green}ok${NC}\n"
637else
638 printf "Leaving temporary files around... ${green}ok${NC}\n"
639fi
640
641printf "\n${green}You can now run your $TARGETARCH cross toolchain from $TARGETDIR.${NC}\n"
642
643