blob: 22524d6b4dbd5f0e37cb5d0bf37a0f10af233fb4 [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
Patrick Georgib890a122015-03-26 15:17:45 +010020# Foundation, Inc.
Stefan Reinauer074d9132009-09-26 16:43:17 +000021#
22
Patrick Georgi8135dba2015-03-17 21:05:20 +010023cd `dirname $0`
24
Patrick Georgi31bf37e2015-06-04 00:09:12 +020025CROSSGCC_DATE="June 3th, 2015"
26CROSSGCC_VERSION="1.28"
Stefan Reinauer074d9132009-09-26 16:43:17 +000027
28# default settings
29TARGETDIR=`pwd`/xgcc
30TARGETARCH=i386-elf
31DESTDIR=
32
33# version numbers
Patrick Georgi53c388f2015-03-07 09:55:18 +010034GMP_VERSION=6.0.0
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070035MPFR_VERSION=3.1.2
Paul Menzele6619422015-02-23 10:33:59 +010036MPC_VERSION=1.0.3
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000037LIBELF_VERSION=0.8.13
Patrick Georgi53c388f2015-03-07 09:55:18 +010038GCC_VERSION=4.9.2
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070039GCC_AUTOCONF_VERSION=2.69
Patrick Georgi53c388f2015-03-07 09:55:18 +010040BINUTILS_VERSION=2.25
41GDB_VERSION=7.9
42IASL_VERSION=20150204
43PYTHON_VERSION=3.4.3
Idwer Vollering296a0152012-10-26 01:48:04 +020044EXPAT_VERSION=2.1.0
Stefan Reinauer074d9132009-09-26 16:43:17 +000045
46# archive locations
Patrick Georgi53c388f2015-03-07 09:55:18 +010047GMP_ARCHIVE="http://ftpmirror.gnu.org/gmp/gmp-${GMP_VERSION}a.tar.bz2"
Patrick Georgi6e61ad32012-05-12 23:19:30 +020048MPFR_ARCHIVE="http://ftpmirror.gnu.org/mpfr/mpfr-${MPFR_VERSION}.tar.bz2"
Idwer Vollering7962fc72012-10-25 02:14:09 +020049MPC_ARCHIVE="http://ftpmirror.gnu.org/mpc/mpc-${MPC_VERSION}.tar.gz"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000050LIBELF_ARCHIVE="http://www.mr511.de/software/libelf-${LIBELF_VERSION}.tar.gz"
Idwer Vollering1cfee0b2012-10-25 02:03:53 +020051GCC_ARCHIVE="http://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2"
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070052BINUTILS_ARCHIVE="http://ftpmirror.gnu.org/binutils/binutils-${BINUTILS_VERSION}.tar.bz2"
Patrick Georgi53c388f2015-03-07 09:55:18 +010053GDB_ARCHIVE="http://ftpmirror.gnu.org/gdb/gdb-${GDB_VERSION}.tar.xz"
54IASL_ARCHIVE="https://acpica.org/sites/acpica/files/acpica-unix-${IASL_VERSION}.tar.gz"
55PYTHON_ARCHIVE="http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +010056EXPAT_ARCHIVE="http://downloads.sourceforge.net/sourceforge/expat/expat-${EXPAT_VERSION}.tar.gz"
Stefan Reinauer074d9132009-09-26 16:43:17 +000057
58GMP_DIR="gmp-${GMP_VERSION}"
59MPFR_DIR="mpfr-${MPFR_VERSION}"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +000060MPC_DIR="mpc-${MPC_VERSION}"
61LIBELF_DIR="libelf-${LIBELF_VERSION}"
Stefan Reinauer074d9132009-09-26 16:43:17 +000062GCC_DIR="gcc-${GCC_VERSION}"
63BINUTILS_DIR="binutils-${BINUTILS_VERSION}"
64GDB_DIR="gdb-${GDB_VERSION}"
Marc Jones2aac3f62011-08-08 16:07:50 -060065IASL_DIR="acpica-unix-${IASL_VERSION}"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +010066PYTHON_DIR="Python-${PYTHON_VERSION}"
67EXPAT_DIR="expat-${EXPAT_VERSION}"
Stefan Reinauer074d9132009-09-26 16:43:17 +000068
Patrick Georgi6321f522015-02-27 23:36:26 +010069unset MAKELEVEL MAKEFLAGS
70
Stefan Reinauer074d9132009-09-26 16:43:17 +000071SAVETEMPS=0
Stefan Reinauer2c3cd122011-11-01 21:43:50 +010072SKIPGDB=1
73SKIPPYTHON=1
Stefan Reinauer074d9132009-09-26 16:43:17 +000074
Patrick Georgi1861ff72011-10-31 12:15:55 +010075red='\033[0;31m'
76RED='\033[1;31m'
77green='\033[0;32m'
78GREEN='\033[1;32m'
79blue='\033[0;34m'
80BLUE='\033[1;34m'
81cyan='\033[0;36m'
82CYAN='\033[1;36m'
83NC='\033[0m' # No Color
Stefan Reinauer074d9132009-09-26 16:43:17 +000084
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070085UNAME=`uname`
86
Patrick Georgi198d23c2012-12-08 08:02:44 +010087normalize_dirs()
88{
89 mkdir -p $DESTDIR$TARGETDIR/lib
90 test -d $DESTDIR$TARGETDIR/lib32 && mv $DESTDIR$TARGETDIR/lib32/* $DESTDIR$TARGETDIR/lib
91 test -d $DESTDIR$TARGETDIR/lib64 && mv $DESTDIR$TARGETDIR/lib64/* $DESTDIR$TARGETDIR/lib
92 rmdir -p $DESTDIR$TARGETDIR/lib32 $DESTDIR$TARGETDIR/lib64
93
94 perl -pi -e "s,/lib32,/lib," $DESTDIR$TARGETDIR/lib/*.la
95 perl -pi -e "s,/lib64,/lib," $DESTDIR$TARGETDIR/lib/*.la
96}
97
Patrick Georgib7062882015-02-24 10:52:14 +010098searchtool()
Stefan Reinauer074d9132009-09-26 16:43:17 +000099{
100 # $1 short name
Patrick Georgib7062882015-02-24 10:52:14 +0100101 # $2 search string
102 # $3 soft fail if set
103 # result: file name of that tool on stdout
104 # or no output if nothing suitable was found
105 search=GNU
106 if [ -n "$2" ]; then
107 search="$2"
108 fi
Stefan Reinauer074d9132009-09-26 16:43:17 +0000109 for i in "$1" "g$1" "gnu$1"; do
110 if test -x "`which $i 2>/dev/null`"; then
Alexander Couzensd268ab32015-04-13 17:15:12 +0200111 if test `cat /dev/null | $i --version 2>&1 |grep -c "$search"` \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100112 -gt 0; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000113 echo $i
114 return
115 fi
116 fi
117 done
Andrew Wub67e9a12014-04-28 18:13:44 +0800118 # A workaround for OSX 10.9 and some BSDs, whose nongnu
119 # patch and tar also work.
Patrick Georgi7cb26b42015-04-28 21:29:22 +0200120 if [ $UNAME = "Darwin" -o $UNAME = "FreeBSD" -o $UNAME = "NetBSD" -o $UNAME = "OpenBSD" ]; then
Patrick Georgib7062882015-02-24 10:52:14 +0100121 if [ "$1" = "patch" -o "$1" = "tar" ]; then
Zheng Bao36156ff2012-09-28 16:18:58 +0800122 if test -x "`which $1 2>/dev/null`"; then
123 echo $1
124 return
125 fi
126 fi
127 fi
zbao939dc842015-04-30 04:44:07 +0800128 if [ "`echo $1 | cut -b -3`" = "sha" ]; then
129 if [ $UNAME = "FreeBSD" ]; then
130 if test -x "`which sha1 2>/dev/null`"; then
131 echo sha1
132 return
133 fi
134 fi
135 if [ $UNAME = "NetBSD" ]; then
136 if test -x "`which cksum 2>/dev/null`"; then
137 echo cksum -a `echo $1 | sed -e 's,sum,,'`
138 return
139 fi
140 fi
141 if [ $UNAME = "Darwin" ]; then
142 if test -x "`which openssl 2>/dev/null`"; then
143 echo openssl `echo $1 | sed -e 's,sum,,'`
144 return
145 fi
146 fi
147 fi
Patrick Georgiae5ab602015-04-29 23:30:15 +0200148 printf "${RED}ERROR:${red} Missing tool: Please install $1 (eg using your OS packaging system)${NC}\n" >&2
Patrick Georgib7062882015-02-24 10:52:14 +0100149 [ -z "$3" ] && exit 1
150 false
Stefan Reinauer074d9132009-09-26 16:43:17 +0000151}
152
Patrick Georgib7062882015-02-24 10:52:14 +0100153TAR=`searchtool tar` || exit $?
154PATCH=`searchtool patch` || exit $?
155MAKE=`searchtool make` || exit $?
Stefan Reinauer074d9132009-09-26 16:43:17 +0000156
Patrick Georgib7062882015-02-24 10:52:14 +0100157searchtool m4 > /dev/null
158searchtool bison > /dev/null
159searchtool flex flex > /dev/null
160searchtool g++ "Free Software Foundation" nofail > /dev/null || \
Patrick Georgi915c4fc2015-03-09 13:58:23 +0100161searchtool clang "clang version" > /dev/null
162searchtool wget > /dev/null
163searchtool bzip2 "bzip2," > /dev/null
Patrick Georgi5fb2b5c2012-05-12 23:25:23 +0200164
Stefan Reinauer88935482015-06-05 09:51:10 -0700165download() {
166 ARCHIVE=$1
167 FILE=`basename $ARCHIVE`
168 printf " * $FILE "
169
170 test -f tarballs/$FILE && \
171 (test -z "$CHECKSUM" || \
172 test "`cat sum/$FILE.cksum 2>/dev/null | sed -e 's,.*\([0-9a-f]\{40\}\).*,\1,'`" = "`$CHECKSUM tarballs/$FILE 2>/dev/null | sed -e 's,.*\([0-9a-f]\{40\}\).*,\1,'`" ) && \
173 printf "(cached)" || (
174 printf "(downloading)"
175 rm -f tarballs/$FILE
176 cd tarballs
177 wget --no-check-certificate -q $ARCHIVE
178 cd ..
179 test ! -f sum/$FILE.cksum && test -f tarballs/$FILE && \
180 (test -z "$CHECKSUM" || $CHECKSUM tarballs/$FILE > sum/$FILE.cksum ) && \
181 printf "(checksum created. ${RED}Note. Please upload sum/$FILE.cksum if the corresponding archive is upgraded.${NC})"
182 )
183 test -f tarballs/$FILE || \
184 printf "\n${RED}Failed to download $FILE.${NC}\n"
185 test -f tarballs/$FILE || exit 1
186 printf "\n"
187}
188
189unpack_and_patch() {
190 PACKAGE=$1
191 archive=$PACKAGE"_ARCHIVE"
192 archive="`eval echo '$'$archive`"
193 dir=$PACKAGE"_DIR"
194 dir="`eval echo '$'${dir}`"
195 test -d ${dir} && test -f ${dir}/.unpack_success || (
196 printf " * `basename $archive`\n"
197 FLAGS=zxf
198 suffix=`echo $archive | sed 's,.*\.,,'`
199 test "$suffix" = "gz" && FLAGS=zxf
200 test "$suffix" = "bz2" && FLAGS=jxf
201 test "$suffix" = "xz" && FLAGS="--xz -xf"
202 test "$suffix" = "lzma" && FLAGS="--lzma -xf"
203 $TAR $FLAGS tarballs/`basename $archive`
204 for patch in patches/${dir}_*.patch; do
205 test -r $patch || continue
206 printf " o `basename $patch`\n"
207 $PATCH -s -N -p0 < `echo $patch` || \
208 printf "\n${RED}Failed $patch.${NC}\n"
209 done
210 touch ${dir}/.unpack_success
211 )
212}
213
Patrick Georgi74c06422015-03-25 18:40:13 +0100214wait_for_build() {
215 # $1: directory in which log file and failure marker are stored
216 cat > "$1/crossgcc-build.log"
217 test -r "$1/.failed" && printf "${RED}failed${NC}. Check $1/crossgcc-build.log.\n" || \
218 printf "${green}ok${NC}\n"
219 test -r "$1/.failed" && exit 1
220 true
221}
222
zbao939dc842015-04-30 04:44:07 +0800223SHA1SUM=`searchtool sha1sum`
224SHA512SUM=`searchtool sha512sum`
225CHECKSUM=$SHA1SUM
226
Stefan Reinauer074d9132009-09-26 16:43:17 +0000227cleanup()
228{
229 printf "Cleaning up temporary files... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200230 rm -rf ${BUILDDIRPREFIX}-* combined gcc-* gmp-* mpfr-* mpc-* libelf-* binutils-*
Patrick Georgi969cd932012-12-07 13:13:53 +0100231 rm -rf gdb-* acpica-* python-* expat-*
Stefan Reinauer074d9132009-09-26 16:43:17 +0000232 printf "${green}ok${NC}\n"
233}
234
235myhelp()
236{
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100237 printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-G] [-S]\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000238 printf " $0 [-V|--version]\n"
239 printf " $0 [-h|--help]\n\n"
240
241 printf "Options:\n"
242 printf " [-V|--version] print version number and exit\n"
243 printf " [-h|--help] print this help and exit\n"
244 printf " [-c|--clean] remove temporary files before build\n"
245 printf " [-t|--savetemps] don't remove temporary files after build\n"
Patrick Georgic1a75b12011-11-04 21:37:14 +0100246 printf " [-y|--ccache] Use ccache when building cross compiler\n"
Patrick Georgi73166c72010-04-14 20:42:42 +0000247 printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000248 printf " [-p|--platform <platform>] target platform to build cross compiler for\n"
249 printf " (defaults to $TARGETARCH)\n"
250 printf " [-d|--directory <target dir>] target directory to install cross compiler to\n"
251 printf " (defaults to $TARGETDIR)\n\n"
252 printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100253 printf " (for RPM builds, default unset)\n"
254 printf " [-G|--gdb] build GNU debugger\n"
255 printf " [-S|--scripting] build scripting support for GDB\n\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000256}
257
258myversion()
259{
260 # version tag is always printed, so just print the license here
261
262 cat << EOF
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000263Copyright (C) 2008-2010 by coresystems GmbH
Marc Jones2aac3f62011-08-08 16:07:50 -0600264Copyright (C) 2011 by Sage Electronic Engineering
Stefan Reinauer074d9132009-09-26 16:43:17 +0000265
266This program is free software; you can redistribute it and/or modify
267it under the terms of the GNU General Public License as published by
268the Free Software Foundation; version 2 of the License.
269
270This program is distributed in the hope that it will be useful,
271but WITHOUT ANY WARRANTY; without even the implied warranty of
272MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
273GNU General Public License for more details.
274
275EOF
276}
277
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700278printf "${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 +0000279
Patrick Georgi6bba29f2010-01-29 17:40:52 +0000280# Look if we have getopt. If not, build it.
281export PATH=$PATH:.
282getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
283
Stefan Reinauer074d9132009-09-26 16:43:17 +0000284# parse parameters.. try to find out whether we're running GNU getopt
Peter Stuge09377b72011-08-21 06:24:55 +0200285getoptbrand="`getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,'`"
286if [ "${getoptbrand}" = "getopt" ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000287 # Detected GNU getopt that supports long options.
Patrick Georgic1a75b12011-11-04 21:37:14 +0100288 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 +0000289 eval set "$args"
290else
291 # Detected non-GNU getopt
Patrick Georgic1a75b12011-11-04 21:37:14 +0100292 args=`getopt Vhcd:p:j:D:tGy $*`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000293 set -- $args
294fi
295
296if [ $? != 0 ]; then
297 myhelp
298 exit 1
299fi
300
301while true ; do
302 case "$1" in
303 -V|--version) shift; myversion; exit 0;;
304 -h|--help) shift; myhelp; exit 0;;
Patrick Georgi44af57a2013-12-19 22:06:22 +0100305 -c|--clean) shift; clean=1;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000306 -t|--savetemps) shift; SAVETEMPS=1;;
307 -d|--directory) shift; TARGETDIR="$1"; shift;;
308 -p|--platform) shift; TARGETARCH="$1"; shift;;
309 -D|--destdir) shift; DESTDIR="$1"; shift;;
Patrick Georgi73166c72010-04-14 20:42:42 +0000310 -j|--jobs) shift; JOBS="-j $1"; shift;;
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100311 -G|--gdb) shift; SKIPGDB=0;;
312 -S|--scripting) shift; SKIPPYTHON=0;;
Patrick Georgic1a75b12011-11-04 21:37:14 +0100313 -y|--ccache) shift; USECCACHE=1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200314 --) shift; break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000315 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200316 *) break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000317 esac
318done
319
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700320case "$TARGETARCH" in
Stefan Reinauer24f9cb92015-03-13 22:50:22 +0100321 x86_64-elf) ;;
322 x86_64*) TARGETARCH=x86_64-elf;;
David Hubbard5b0420a2013-05-28 16:33:15 -0600323 i386-elf) ;;
324 i386-mingw32) ;;
Patrick Georgi9b7efa52015-03-08 09:20:36 +0100325 mipsel-elf) ;;
Patrick Georgif0bbc952015-03-07 10:57:25 +0100326 riscv-elf) ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700327 i386*) TARGETARCH=i386-elf;;
Patrick Georgic8883262013-09-19 10:57:58 +0200328 arm*) TARGETARCH=armv7-a-eabi;;
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700329 aarch64*) TARGETARCH=aarch64-elf;;
330 *) printf "${red}WARNING: Unsupported architecture $TARGETARCH.${NC}\n\n"; ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700331esac
332
333echo "Target arch is now $TARGETARCH"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200334BUILDDIRPREFIX=build-${TARGETARCH}
335
Patrick Georgi44af57a2013-12-19 22:06:22 +0100336if [ "$clean" = "1" ]; then
337 cleanup
338fi
339
Peter Stugeceacd772011-06-09 04:54:16 +0200340GDB_PACKAGE="GDB"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100341PYTHON_PACKAGE="PYTHON"
342EXPAT_PACKAGE="EXPAT"
Peter Stugeceacd772011-06-09 04:54:16 +0200343if [ $SKIPGDB -eq 1 ]; then
344 printf "Will skip GDB ... ${green}ok${NC}\n"
Peter Stuge0e8ee812011-08-28 11:04:23 +0200345 GDB_ARCHIVE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200346 GDB_PACKAGE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100347 if [ $SKIPPYTHON -eq 0 ]; then
348 printf "Python scripting needs GDB ... disabling ... ${green}ok${NC}\n"
349 SKIPPYTHON=1
350 fi
351fi
352if [ $SKIPPYTHON -eq 1 ]; then
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600353 PYTHON_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100354 PYTHON_PACKAGE=""
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600355 EXPAT_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100356 EXPAT_PACKAGE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200357fi
358
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700359# coreboot does not like the GOLD linker
360# USE_GOLD="--enable-gold"
361USE_GOLD=""
362GCC_OPTIONS="--enable-lto"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000363
Stefan Reinauer074d9132009-09-26 16:43:17 +0000364printf "Downloading tar balls ... \n"
365mkdir -p tarballs
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100366for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100367 $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100368 $IASL_ARCHIVE $PYTHON_ARCHIVE $EXPAT_ARCHIVE; do
Stefan Reinauer88935482015-06-05 09:51:10 -0700369 download $ARCHIVE
Stefan Reinauer074d9132009-09-26 16:43:17 +0000370done
371printf "Downloaded tar balls ... "
372printf "${green}ok${NC}\n"
373
374printf "Unpacking and patching ... \n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100375for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS $PYTHON_PACKAGE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100376 $EXPAT_PACKAGE $GDB_PACKAGE IASL; do
Stefan Reinauer88935482015-06-05 09:51:10 -0700377 unpack_and_patch $PACKAGE
Stefan Reinauer074d9132009-09-26 16:43:17 +0000378done
379printf "Unpacked and patched ... "
380printf "${green}ok${NC}\n"
381
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700382CC=cc
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700383if [ $UNAME = "Darwin" ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000384 #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix"
385
386 # generally the OS X compiler can create x64 binaries.
387 # Per default it generated i386 binaries in 10.5 and x64
388 # binaries in 10.6 (even if the kernel is 32bit)
389 # For some weird reason, 10.5 autodetects an ABI=64 though
390 # so we're setting the ABI explicitly here.
Zheng Bao04ceed62012-10-23 19:41:25 +0800391 if [ `sysctl -n hw.optional.x86_64 2>/dev/null` -eq 1 ] 2>/dev/null; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000392 OPTIONS="ABI=64"
393 else
394 OPTIONS="ABI=32"
395 fi
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700396
Stefan Reinauer4266b922012-12-05 16:18:32 -0800397 # In Xcode 4.5.2 the default compiler is clang.
398 # However, this compiler fails to compile gcc 4.7.x. As a
399 # workaround it's possible to compile gcc with llvm-gcc.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700400 if $CC -v 2>&1 | grep -q LLVM; then
Stefan Reinauer4266b922012-12-05 16:18:32 -0800401 CC=llvm-gcc
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700402 fi
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000403fi
404
Patrick Georgic1a75b12011-11-04 21:37:14 +0100405if [ "$USECCACHE" = 1 ]; then
406 CC="ccache $CC"
407fi
408
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200409mkdir -p ${BUILDDIRPREFIX}-gmp ${BUILDDIRPREFIX}-mpfr ${BUILDDIRPREFIX}-mpc ${BUILDDIRPREFIX}-libelf ${BUILDDIRPREFIX}-binutils \
410 ${BUILDDIRPREFIX}-gcc ${BUILDDIRPREFIX}-python ${BUILDDIRPREFIX}-expat
Stefan Reinauer16bd7892012-12-07 23:57:01 +0100411
412mkdir -p $DESTDIR$TARGETDIR/bin
413export PATH=$DESTDIR$TARGETDIR/bin:$PATH
414
Peter Stugeceacd772011-06-09 04:54:16 +0200415if [ $SKIPGDB -eq 0 ]; then
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200416 mkdir -p ${BUILDDIRPREFIX}-gdb
Peter Stugeceacd772011-06-09 04:54:16 +0200417fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200418if [ -f ${BUILDDIRPREFIX}-gmp/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000419 printf "Skipping GMP as it is already built\n"
420else
421printf "Building GMP ${GMP_VERSION} ... "
422(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200423 cd ${BUILDDIRPREFIX}-gmp
Stefan Reinauer074d9132009-09-26 16:43:17 +0000424 rm -f .failed
Patrick Georgi31bf37e2015-06-04 00:09:12 +0200425 CC="$CC" CFLAGS="-Os" ../${GMP_DIR}/configure --disable-shared --enable-fat --prefix=$TARGETDIR $OPTIONS \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000426 || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000427 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000428 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100429
430 normalize_dirs
431
Stefan Reinauer074d9132009-09-26 16:43:17 +0000432 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi74c06422015-03-25 18:40:13 +0100433) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-gmp" || exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000434fi
435
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700436# Now set CFLAGS to match GMP CFLAGS but strip out -pedantic
437# as GCC 4.6.x fails if it's there.
438HOSTCFLAGS=`grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2 |\
439 sed s,-pedantic,,`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000440
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200441if [ -f ${BUILDDIRPREFIX}-mpfr/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000442 printf "Skipping MPFR as it is already built\n"
443else
444printf "Building MPFR ${MPFR_VERSION} ... "
445(
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700446 test $UNAME = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200447 cd ${BUILDDIRPREFIX}-mpfr
Stefan Reinauer074d9132009-09-26 16:43:17 +0000448 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100449 CC="$CC" ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000450 --infodir=$TARGETDIR/info \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100451 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
452 touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000453 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000454 $MAKE install DESTDIR=$DESTDIR || touch .failed
455
Patrick Georgi198d23c2012-12-08 08:02:44 +0100456 normalize_dirs
457
Stefan Reinauer074d9132009-09-26 16:43:17 +0000458 # work around build problem of libgmp.la
459 if [ "$DESTDIR" != "" ]; then
460 perl -pi -e "s,$DESTDIR,," $DESTDIR$TARGETDIR/libgmp.la
461 fi
462
463 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi74c06422015-03-25 18:40:13 +0100464) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-mpfr" || exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000465fi
466
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200467if [ -f ${BUILDDIRPREFIX}-mpc/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000468 printf "Skipping MPC as it is already built\n"
469else
470printf "Building MPC ${MPC_VERSION} ... "
471(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200472 cd ${BUILDDIRPREFIX}-mpc
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000473 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100474 CC="$CC" ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000475 --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100476 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
477 touch .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000478 $MAKE $JOBS || touch .failed
479 $MAKE install DESTDIR=$DESTDIR || touch .failed
480
Patrick Georgi198d23c2012-12-08 08:02:44 +0100481 normalize_dirs
482
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000483 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi74c06422015-03-25 18:40:13 +0100484) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-mpc" || exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000485fi
486
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200487if [ -f ${BUILDDIRPREFIX}-libelf/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000488 printf "Skipping libelf as it is already built\n"
489else
490printf "Building libelf ${LIBELF_VERSION} ... "
491(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200492 cd ${BUILDDIRPREFIX}-libelf
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000493 rm -f .failed
494 echo "$HOSTCFLAGS"
Patrick Georgi643c9e82011-11-04 21:30:49 +0100495 CC="$CC" CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100496 ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000497 --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed
498 $MAKE $JOBS || touch .failed
Scott Duplichan4270a972014-12-12 20:21:40 -0600499 $MAKE install prefix=$DESTDIR$TARGETDIR || touch .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000500
Patrick Georgi198d23c2012-12-08 08:02:44 +0100501 normalize_dirs
502
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000503 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi74c06422015-03-25 18:40:13 +0100504) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-libelf" || exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000505fi
506
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200507if [ -f ${BUILDDIRPREFIX}-binutils/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000508 printf "Skipping binutils as it is already built\n"
509else
510printf "Building binutils ${BINUTILS_VERSION} ... "
511(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700512 # What a pain: binutils don't come with configure
513 # script anymore. Create it:
514 cd binutils-${BINUTILS_VERSION}/
515 autoconf
516 cd ..
517 # Now build binutils
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200518 cd ${BUILDDIRPREFIX}-binutils
Stefan Reinauer074d9132009-09-26 16:43:17 +0000519 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100520 CC="$CC" ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100521 --target=${TARGETARCH} --disable-werror --disable-nls \
522 $USE_GOLD CFLAGS="$HOSTCFLAGS" || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000523 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000524 $MAKE install DESTDIR=$DESTDIR || touch .failed
525 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi74c06422015-03-25 18:40:13 +0100526) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-binutils" || exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000527fi
528
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200529if [ -f ${BUILDDIRPREFIX}-gcc/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000530 printf "Skipping GCC as it is already built\n"
531else
532printf "Building GCC ${GCC_VERSION} ... "
533(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700534 # Even worse than binutils: GCC does not come with configure
535 # script anymore, but also enforces an obsolete autoconf version
536 # to create it. This is a poster child of how autotools help make
537 # software portable.
538 cd gcc-${GCC_VERSION}
539 sed '/dnl Ensure exactly this Autoconf version is used/d' \
540 config/override.m4 > config/override.m4.new
541 autoconf_version=`autoconf -V | grep "autoconf" | tr ' ' '\n' | tail -1`
542 sed "s/${GCC_AUTOCONF_VERSION}/${autoconf_version}/g" \
543 config/override.m4.new > config/override.m4
544 autoconf
545 cd ..
546 # Now, finally, we can build gcc:
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200547 cd ${BUILDDIRPREFIX}-gcc
Stefan Reinauer074d9132009-09-26 16:43:17 +0000548 rm -f .failed
549 # GCC does not honour HOSTCFLAGS at all. CFLAGS are used for
550 # both target and host object files. This is pretty misdesigned.
551 # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET
552 # but it does not seem to work properly. At least the host library
553 # libiberty is not compiled with CFLAGS_FOR_BUILD.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700554 CC="$CC" CFLAGS_FOR_TARGET="-O2" CFLAGS="$HOSTCFLAGS" \
555 CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000556 --prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000557 --target=${TARGETARCH} --disable-werror --disable-shared \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000558 --disable-libssp --disable-bootstrap --disable-nls \
Patrick Georgi969cd932012-12-07 13:13:53 +0100559 --disable-libquadmath --without-headers \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000560 $GCC_OPTIONS --enable-languages="c" $USE_GOLD \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000561 --with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000562 --with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \
563 --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION $CROSSGCC_DATE" \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000564 || touch .failed
Patrick Georgi969cd932012-12-07 13:13:53 +0100565 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-gcc || touch .failed
566 $MAKE install-gcc DESTDIR=$DESTDIR || touch .failed
567
568 if [ "`echo $TARGETARCH | grep -c -- -mingw32`" -eq 0 ]; then
569 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-target-libgcc || touch .failed
570 $MAKE install-target-libgcc DESTDIR=$DESTDIR || touch .failed
571 fi
572
Stefan Reinauer074d9132009-09-26 16:43:17 +0000573 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi74c06422015-03-25 18:40:13 +0100574) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-gcc" || exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000575fi
576
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200577if [ -f ${BUILDDIRPREFIX}-expat/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100578 printf "Skipping Expat as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100579elif [ $SKIPPYTHON -eq 1 ]; then
580 printf "Skipping Expat (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100581else
582printf "Building Expat ${EXPAT_VERSION} ... "
583(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200584 cd ${BUILDDIRPREFIX}-expat
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100585 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100586 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${EXPAT_DIR}/configure --disable-shared \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100587 --prefix=$TARGETDIR --target=${TARGETARCH} || touch .failed
588 $MAKE || touch .failed
589 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100590
591 normalize_dirs
592
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100593 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi74c06422015-03-25 18:40:13 +0100594) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-expat" || exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100595fi
596
597
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200598if [ -f ${BUILDDIRPREFIX}-python/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100599 printf "Skipping Python as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100600elif [ $SKIPPYTHON -eq 1 ]; then
601 printf "Skipping Python (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100602else
603printf "Building Python ${PYTHON_VERSION} ... "
604(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200605 cd ${BUILDDIRPREFIX}-python
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100606 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100607 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${PYTHON_DIR}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100608 --target=${TARGETARCH} || touch .failed
609 $MAKE $JOBS || touch .failed
610 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100611
612 normalize_dirs
613
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100614 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi74c06422015-03-25 18:40:13 +0100615) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-python" || exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100616fi
617
618
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200619if [ -f ${BUILDDIRPREFIX}-gdb/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000620 printf "Skipping GDB as it is already built\n"
Peter Stugeceacd772011-06-09 04:54:16 +0200621elif [ $SKIPGDB -eq 1 ]; then
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100622 printf "Skipping GDB (GDB support not enabled)\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000623else
624printf "Building GDB ${GDB_VERSION} ... "
625(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200626 cd ${BUILDDIRPREFIX}-gdb
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100627 export PYTHONHOME=$DESTDIR$TARGETDIR
Stefan Reinauer074d9132009-09-26 16:43:17 +0000628 rm -f .failed
Idwer Vollering1b7c9592015-04-09 15:34:07 +0200629 if [ $(uname) != "FreeBSD" -a $(uname) != "NetBSD" ]; then
630 LIBDL="-ldl"
631 fi
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100632 LDFLAGS="-Wl,-rpath,\$\$ORIGIN/../lib/ -L$DESTDIR$TARGETDIR/lib \
Idwer Vollering1b7c9592015-04-09 15:34:07 +0200633 -lpthread $LIBDL -lutil" \
Patrick Georgi643c9e82011-11-04 21:30:49 +0100634 CC="$CC" CFLAGS="$HOSTCFLAGS -I$DESTDIR$TARGETDIR/include" \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100635 ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR \
636 --target=${TARGETARCH} --disable-werror --disable-nls
Patrick Georgi73166c72010-04-14 20:42:42 +0000637 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000638 $MAKE install DESTDIR=$DESTDIR || touch .failed
639 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi74c06422015-03-25 18:40:13 +0100640) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-gdb" || exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000641fi
642
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200643if [ -f $IASL_DIR/source/compiler/.success ]; then
Marc Jones2aac3f62011-08-08 16:07:50 -0600644 printf "Skipping IASL as it is already built\n"
645else
646printf "Building IASL ${IASL_VERSION} ... "
647(
Patrick Georgi74c06422015-03-25 18:40:13 +0100648 RDIR=$IASL_DIR/source/compiler
Idwer Vollering6b11c8b2012-11-15 21:14:36 +0100649 cd $IASL_DIR/generate/unix
Patrick Georgi74c06422015-03-25 18:40:13 +0100650 rm -f $RDIR/.failed
Marc Jones2aac3f62011-08-08 16:07:50 -0600651 CFLAGS="$HOSTCFLAGS"
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700652 HOST="_LINUX"
653 test $UNAME = "Darwin" && HOST="_APPLE"
654 test $UNAME = "FreeBSD" && HOST="_FreeBSD"
655 test $UNAME = "Cygwin" && HOST="_CYGWIN"
Patrick Georgi74c06422015-03-25 18:40:13 +0100656 HOST="$HOST" OPT_CFLAGS="-O -D_FORTIFY_SOURCE=2" CFLAGS="$CFLAGS" $MAKE CC="$CC" iasl || touch $RDIR/.failed
657 rm -f $DESTDIR$TARGETDIR/bin/iasl || touch $RDIR/.failed
658 cp bin/iasl $DESTDIR$TARGETDIR/bin || touch $RDIR/.failed
659 if [ ! -f $RDIR/.failed ]; then touch $RDIR/.success; fi
660) 2>&1 | wait_for_build "$IASL_DIR/source/compiler" || exit 1
Marc Jones2aac3f62011-08-08 16:07:50 -0600661fi
662
Patrick Georgi5602f2c2015-03-28 15:48:47 +0100663PROGNAME=`basename "$0"`
664rm -f "$DESTDIR$TARGETDIR/$PROGNAME".commit.*
665cp "$PROGNAME" $DESTDIR$TARGETDIR/"$PROGNAME.commit.`git describe`"
Zheng Bao30b895f2013-02-06 18:04:40 +0800666
Stefan Reinauer074d9132009-09-26 16:43:17 +0000667if [ $SAVETEMPS -eq 0 ]; then
668 printf "Cleaning up... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200669 rm -rf ${GMP_DIR} ${BUILDDIRPREFIX}-gmp
670 rm -rf ${MPFR_DIR} ${BUILDDIRPREFIX}-mpfr
671 rm -rf ${MPC_DIR} ${BUILDDIRPREFIX}-mpc
672 rm -rf ${LIBELF_DIR} ${BUILDDIRPREFIX}-libelf
673 rm -rf ${BINUTILS_DIR} ${BUILDDIRPREFIX}-binutils
674 rm -rf ${GCC_DIR} ${BUILDDIRPREFIX}-gcc
675 rm -rf ${GDB_DIR} ${BUILDDIRPREFIX}-gdb
676 rm -rf ${EXPAT_DIR} ${BUILDDIRPREFIX}-expat
677 rm -rf ${PYTHON_DIR} ${BUILDDIRPREFIX}-python
Marc Jones2aac3f62011-08-08 16:07:50 -0600678 rm -rf ${IASL_DIR}
Stefan Reinauer074d9132009-09-26 16:43:17 +0000679 printf "${green}ok${NC}\n"
680else
681 printf "Leaving temporary files around... ${green}ok${NC}\n"
682fi
683
684printf "\n${green}You can now run your $TARGETARCH cross toolchain from $TARGETDIR.${NC}\n"
685
686