blob: e9936dbaae703cd2510a11d9f4dcea0275d170b0 [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
Patrick Georgi53c388f2015-03-07 09:55:18 +010023CROSSGCC_DATE="March 8th, 2015"
24CROSSGCC_VERSION="1.27"
Stefan Reinauer074d9132009-09-26 16:43:17 +000025
26# default settings
27TARGETDIR=`pwd`/xgcc
28TARGETARCH=i386-elf
29DESTDIR=
30
31# version numbers
Patrick Georgi53c388f2015-03-07 09:55:18 +010032GMP_VERSION=6.0.0
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070033MPFR_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 Georgi53c388f2015-03-07 09:55:18 +010036GCC_VERSION=4.9.2
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070037GCC_AUTOCONF_VERSION=2.69
Patrick Georgi53c388f2015-03-07 09:55:18 +010038BINUTILS_VERSION=2.25
39GDB_VERSION=7.9
40IASL_VERSION=20150204
41PYTHON_VERSION=3.4.3
Idwer Vollering296a0152012-10-26 01:48:04 +020042EXPAT_VERSION=2.1.0
Stefan Reinauer074d9132009-09-26 16:43:17 +000043
44# archive locations
Patrick Georgi53c388f2015-03-07 09:55:18 +010045GMP_ARCHIVE="http://ftpmirror.gnu.org/gmp/gmp-${GMP_VERSION}a.tar.bz2"
Patrick Georgi6e61ad32012-05-12 23:19:30 +020046MPFR_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 Georgi53c388f2015-03-07 09:55:18 +010051GDB_ARCHIVE="http://ftpmirror.gnu.org/gdb/gdb-${GDB_VERSION}.tar.xz"
52IASL_ARCHIVE="https://acpica.org/sites/acpica/files/acpica-unix-${IASL_VERSION}.tar.gz"
53PYTHON_ARCHIVE="http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +010054EXPAT_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
Patrick Georgi6321f522015-02-27 23:36:26 +010067unset MAKELEVEL MAKEFLAGS
68
Stefan Reinauer074d9132009-09-26 16:43:17 +000069SAVETEMPS=0
Stefan Reinauer2c3cd122011-11-01 21:43:50 +010070SKIPGDB=1
71SKIPPYTHON=1
Stefan Reinauer074d9132009-09-26 16:43:17 +000072
Patrick Georgi1861ff72011-10-31 12:15:55 +010073red='\033[0;31m'
74RED='\033[1;31m'
75green='\033[0;32m'
76GREEN='\033[1;32m'
77blue='\033[0;34m'
78BLUE='\033[1;34m'
79cyan='\033[0;36m'
80CYAN='\033[1;36m'
81NC='\033[0m' # No Color
Stefan Reinauer074d9132009-09-26 16:43:17 +000082
Stefan Reinauer0d2119d2013-07-10 14:27:56 -070083UNAME=`uname`
84
Patrick Georgi198d23c2012-12-08 08:02:44 +010085normalize_dirs()
86{
87 mkdir -p $DESTDIR$TARGETDIR/lib
88 test -d $DESTDIR$TARGETDIR/lib32 && mv $DESTDIR$TARGETDIR/lib32/* $DESTDIR$TARGETDIR/lib
89 test -d $DESTDIR$TARGETDIR/lib64 && mv $DESTDIR$TARGETDIR/lib64/* $DESTDIR$TARGETDIR/lib
90 rmdir -p $DESTDIR$TARGETDIR/lib32 $DESTDIR$TARGETDIR/lib64
91
92 perl -pi -e "s,/lib32,/lib," $DESTDIR$TARGETDIR/lib/*.la
93 perl -pi -e "s,/lib64,/lib," $DESTDIR$TARGETDIR/lib/*.la
94}
95
Stefan Reinauer074d9132009-09-26 16:43:17 +000096searchgnu()
97{
98 # $1 short name
99 # result: GNU version of that tool on stdout
100 # or no output if no GNU version was found
101 for i in "$1" "g$1" "gnu$1"; do
102 if test -x "`which $i 2>/dev/null`"; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100103 if test `$i --version 2>/dev/null |grep -c GNU` \
104 -gt 0; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000105 echo $i
106 return
107 fi
108 fi
109 done
Andrew Wub67e9a12014-04-28 18:13:44 +0800110 # A workaround for OSX 10.9 and some BSDs, whose nongnu
111 # patch and tar also work.
112 if [ $UNAME = "Darwin" -o $UNAME = "FreeBSD" -o $UNAME = "NetBSD" ]; then
Zheng Bao36156ff2012-09-28 16:18:58 +0800113 if [ $1 != "make" ]; then
114 if test -x "`which $1 2>/dev/null`"; then
115 echo $1
116 return
117 fi
118 fi
119 fi
Stefan Reinauer074d9132009-09-26 16:43:17 +0000120 printf "${RED}ERROR:${red} Missing toolchain: $1${NC}\n" >&2
121 exit 1
122}
123
Patrick Georgi68df8042011-07-17 11:36:10 +0200124TAR=`searchgnu tar` || exit $?
125PATCH=`searchgnu patch` || exit $?
126MAKE=`searchgnu make` || exit $?
Stefan Reinauer074d9132009-09-26 16:43:17 +0000127
Patrick Georgi5fb2b5c2012-05-12 23:25:23 +0200128searchgnu m4 > /dev/null
129searchgnu bison > /dev/null
Patrick Georgi0a3f2392012-11-20 12:04:32 +0100130
131if ! flex --version > /dev/null 2> /dev/null; then
132 printf "${RED}ERROR:${red} Missing toolchain: flex${NC}\n" >&2
133 exit 1
134fi
Patrick Georgi5fb2b5c2012-05-12 23:25:23 +0200135
Stefan Reinauer074d9132009-09-26 16:43:17 +0000136cleanup()
137{
138 printf "Cleaning up temporary files... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200139 rm -rf ${BUILDDIRPREFIX}-* combined gcc-* gmp-* mpfr-* mpc-* libelf-* binutils-*
Patrick Georgi969cd932012-12-07 13:13:53 +0100140 rm -rf gdb-* acpica-* python-* expat-*
Stefan Reinauer074d9132009-09-26 16:43:17 +0000141 printf "${green}ok${NC}\n"
142}
143
144myhelp()
145{
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100146 printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-G] [-S]\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000147 printf " $0 [-V|--version]\n"
148 printf " $0 [-h|--help]\n\n"
149
150 printf "Options:\n"
151 printf " [-V|--version] print version number and exit\n"
152 printf " [-h|--help] print this help and exit\n"
153 printf " [-c|--clean] remove temporary files before build\n"
154 printf " [-t|--savetemps] don't remove temporary files after build\n"
Patrick Georgic1a75b12011-11-04 21:37:14 +0100155 printf " [-y|--ccache] Use ccache when building cross compiler\n"
Patrick Georgi73166c72010-04-14 20:42:42 +0000156 printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000157 printf " [-p|--platform <platform>] target platform to build cross compiler for\n"
158 printf " (defaults to $TARGETARCH)\n"
159 printf " [-d|--directory <target dir>] target directory to install cross compiler to\n"
160 printf " (defaults to $TARGETDIR)\n\n"
161 printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100162 printf " (for RPM builds, default unset)\n"
163 printf " [-G|--gdb] build GNU debugger\n"
164 printf " [-S|--scripting] build scripting support for GDB\n\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000165}
166
167myversion()
168{
169 # version tag is always printed, so just print the license here
170
171 cat << EOF
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000172Copyright (C) 2008-2010 by coresystems GmbH
Marc Jones2aac3f62011-08-08 16:07:50 -0600173Copyright (C) 2011 by Sage Electronic Engineering
Stefan Reinauer074d9132009-09-26 16:43:17 +0000174
175This program is free software; you can redistribute it and/or modify
176it under the terms of the GNU General Public License as published by
177the Free Software Foundation; version 2 of the License.
178
179This program is distributed in the hope that it will be useful,
180but WITHOUT ANY WARRANTY; without even the implied warranty of
181MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
182GNU General Public License for more details.
183
184EOF
185}
186
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700187printf "${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 +0000188
Patrick Georgi6bba29f2010-01-29 17:40:52 +0000189# Look if we have getopt. If not, build it.
190export PATH=$PATH:.
191getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
192
Stefan Reinauer074d9132009-09-26 16:43:17 +0000193# parse parameters.. try to find out whether we're running GNU getopt
Peter Stuge09377b72011-08-21 06:24:55 +0200194getoptbrand="`getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,'`"
195if [ "${getoptbrand}" = "getopt" ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000196 # Detected GNU getopt that supports long options.
Patrick Georgic1a75b12011-11-04 21:37:14 +0100197 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 +0000198 eval set "$args"
199else
200 # Detected non-GNU getopt
Patrick Georgic1a75b12011-11-04 21:37:14 +0100201 args=`getopt Vhcd:p:j:D:tGy $*`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000202 set -- $args
203fi
204
205if [ $? != 0 ]; then
206 myhelp
207 exit 1
208fi
209
210while true ; do
211 case "$1" in
212 -V|--version) shift; myversion; exit 0;;
213 -h|--help) shift; myhelp; exit 0;;
Patrick Georgi44af57a2013-12-19 22:06:22 +0100214 -c|--clean) shift; clean=1;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000215 -t|--savetemps) shift; SAVETEMPS=1;;
216 -d|--directory) shift; TARGETDIR="$1"; shift;;
217 -p|--platform) shift; TARGETARCH="$1"; shift;;
218 -D|--destdir) shift; DESTDIR="$1"; shift;;
Patrick Georgi73166c72010-04-14 20:42:42 +0000219 -j|--jobs) shift; JOBS="-j $1"; shift;;
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100220 -G|--gdb) shift; SKIPGDB=0;;
221 -S|--scripting) shift; SKIPPYTHON=0;;
Patrick Georgic1a75b12011-11-04 21:37:14 +0100222 -y|--ccache) shift; USECCACHE=1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200223 --) shift; break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000224 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200225 *) break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000226 esac
227done
228
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700229case "$TARGETARCH" in
David Hubbard5b0420a2013-05-28 16:33:15 -0600230 i386-elf) ;;
231 i386-mingw32) ;;
Patrick Georgi9b7efa52015-03-08 09:20:36 +0100232 mipsel-elf) ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700233 i386*) TARGETARCH=i386-elf;;
Patrick Georgic8883262013-09-19 10:57:58 +0200234 arm*) TARGETARCH=armv7-a-eabi;;
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700235 aarch64*) TARGETARCH=aarch64-elf;;
236 *) printf "${red}WARNING: Unsupported architecture $TARGETARCH.${NC}\n\n"; ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700237esac
238
239echo "Target arch is now $TARGETARCH"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200240BUILDDIRPREFIX=build-${TARGETARCH}
241
Patrick Georgi44af57a2013-12-19 22:06:22 +0100242if [ "$clean" = "1" ]; then
243 cleanup
244fi
245
Peter Stugeceacd772011-06-09 04:54:16 +0200246GDB_PACKAGE="GDB"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100247PYTHON_PACKAGE="PYTHON"
248EXPAT_PACKAGE="EXPAT"
Peter Stugeceacd772011-06-09 04:54:16 +0200249if [ $SKIPGDB -eq 1 ]; then
250 printf "Will skip GDB ... ${green}ok${NC}\n"
Peter Stuge0e8ee812011-08-28 11:04:23 +0200251 GDB_ARCHIVE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200252 GDB_PACKAGE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100253 if [ $SKIPPYTHON -eq 0 ]; then
254 printf "Python scripting needs GDB ... disabling ... ${green}ok${NC}\n"
255 SKIPPYTHON=1
256 fi
257fi
258if [ $SKIPPYTHON -eq 1 ]; then
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600259 PYTHON_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100260 PYTHON_PACKAGE=""
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600261 EXPAT_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100262 EXPAT_PACKAGE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200263fi
264
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700265# coreboot does not like the GOLD linker
266# USE_GOLD="--enable-gold"
267USE_GOLD=""
268GCC_OPTIONS="--enable-lto"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000269
Stefan Reinauer074d9132009-09-26 16:43:17 +0000270printf "Downloading tar balls ... \n"
271mkdir -p tarballs
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100272for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100273 $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100274 $IASL_ARCHIVE $PYTHON_ARCHIVE $EXPAT_ARCHIVE; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000275 FILE=`basename $ARCHIVE`
276 printf " * $FILE "
277 test -f tarballs/$FILE && printf "(cached)" || (
278 printf "(downloading)"
279 cd tarballs
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200280 wget --no-check-certificate -q $ARCHIVE
Stefan Reinauer074d9132009-09-26 16:43:17 +0000281 )
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100282 test -f tarballs/$FILE || \
Zheng Bao5b209c02012-09-20 16:09:51 +0800283 printf "\n${RED}Failed to download $FILE.${NC}\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000284 test -f tarballs/$FILE || exit 1
285 printf "\n"
286done
287printf "Downloaded tar balls ... "
288printf "${green}ok${NC}\n"
289
290printf "Unpacking and patching ... \n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100291for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS $PYTHON_PACKAGE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100292 $EXPAT_PACKAGE $GDB_PACKAGE IASL; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000293 archive=$PACKAGE"_ARCHIVE"
Peter Stuge09377b72011-08-21 06:24:55 +0200294 archive="`eval echo '$'$archive`"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000295 dir=$PACKAGE"_DIR"
Peter Stuge09377b72011-08-21 06:24:55 +0200296 dir="`eval echo '$'${dir}`"
Zheng Baof95bb2d2013-12-13 12:30:46 +0800297 test -d ${dir} && test -f ${dir}/.unpack_success || (
Stefan Reinauer074d9132009-09-26 16:43:17 +0000298 printf " * `basename $archive`\n"
299 FLAGS=zxf
Peter Stuge09377b72011-08-21 06:24:55 +0200300 suffix=`echo $archive | sed 's,.*\.,,'`
301 test "$suffix" = "gz" && FLAGS=zxf
302 test "$suffix" = "bz2" && FLAGS=jxf
Patrick Georgi53c388f2015-03-07 09:55:18 +0100303 test "$suffix" = "xz" && FLAGS="--xz -xf"
Peter Stuge09377b72011-08-21 06:24:55 +0200304 test "$suffix" = "lzma" && FLAGS="--lzma -xf"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000305 $TAR $FLAGS tarballs/`basename $archive`
Peter Stuge09377b72011-08-21 06:24:55 +0200306 for patch in patches/${dir}_*.patch; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000307 test -r $patch || continue
308 printf " o `basename $patch`\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100309 $PATCH -s -N -p0 < `echo $patch` || \
Zheng Bao5b209c02012-09-20 16:09:51 +0800310 printf "\n${RED}Failed $patch.${NC}\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000311 done
Zheng Bao691b313c2013-12-09 14:09:07 +0800312 touch ${dir}/.unpack_success
Stefan Reinauer074d9132009-09-26 16:43:17 +0000313 )
314done
315printf "Unpacked and patched ... "
316printf "${green}ok${NC}\n"
317
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700318CC=cc
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700319if [ $UNAME = "Darwin" ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000320 #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix"
321
322 # generally the OS X compiler can create x64 binaries.
323 # Per default it generated i386 binaries in 10.5 and x64
324 # binaries in 10.6 (even if the kernel is 32bit)
325 # For some weird reason, 10.5 autodetects an ABI=64 though
326 # so we're setting the ABI explicitly here.
Zheng Bao04ceed62012-10-23 19:41:25 +0800327 if [ `sysctl -n hw.optional.x86_64 2>/dev/null` -eq 1 ] 2>/dev/null; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000328 OPTIONS="ABI=64"
329 else
330 OPTIONS="ABI=32"
331 fi
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700332
Stefan Reinauer4266b922012-12-05 16:18:32 -0800333 # In Xcode 4.5.2 the default compiler is clang.
334 # However, this compiler fails to compile gcc 4.7.x. As a
335 # workaround it's possible to compile gcc with llvm-gcc.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700336 if $CC -v 2>&1 | grep -q LLVM; then
Stefan Reinauer4266b922012-12-05 16:18:32 -0800337 CC=llvm-gcc
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700338 fi
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000339fi
340
Patrick Georgic1a75b12011-11-04 21:37:14 +0100341if [ "$USECCACHE" = 1 ]; then
342 CC="ccache $CC"
343fi
344
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200345mkdir -p ${BUILDDIRPREFIX}-gmp ${BUILDDIRPREFIX}-mpfr ${BUILDDIRPREFIX}-mpc ${BUILDDIRPREFIX}-libelf ${BUILDDIRPREFIX}-binutils \
346 ${BUILDDIRPREFIX}-gcc ${BUILDDIRPREFIX}-python ${BUILDDIRPREFIX}-expat
Stefan Reinauer16bd7892012-12-07 23:57:01 +0100347
348mkdir -p $DESTDIR$TARGETDIR/bin
349export PATH=$DESTDIR$TARGETDIR/bin:$PATH
350
Peter Stugeceacd772011-06-09 04:54:16 +0200351if [ $SKIPGDB -eq 0 ]; then
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200352 mkdir -p ${BUILDDIRPREFIX}-gdb
Peter Stugeceacd772011-06-09 04:54:16 +0200353fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200354if [ -f ${BUILDDIRPREFIX}-gmp/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000355 printf "Skipping GMP as it is already built\n"
356else
357printf "Building GMP ${GMP_VERSION} ... "
358(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200359 cd ${BUILDDIRPREFIX}-gmp
Stefan Reinauer074d9132009-09-26 16:43:17 +0000360 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100361 CC="$CC" ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000362 || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000363 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000364 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100365
366 normalize_dirs
367
Stefan Reinauer074d9132009-09-26 16:43:17 +0000368 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200369) > ${BUILDDIRPREFIX}-gmp/crossgcc-build.log 2>&1
370test -r ${BUILDDIRPREFIX}-gmp/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100371 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200372test -r ${BUILDDIRPREFIX}-gmp/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000373fi
374
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700375# Now set CFLAGS to match GMP CFLAGS but strip out -pedantic
376# as GCC 4.6.x fails if it's there.
377HOSTCFLAGS=`grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2 |\
378 sed s,-pedantic,,`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000379
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200380if [ -f ${BUILDDIRPREFIX}-mpfr/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000381 printf "Skipping MPFR as it is already built\n"
382else
383printf "Building MPFR ${MPFR_VERSION} ... "
384(
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700385 test $UNAME = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200386 cd ${BUILDDIRPREFIX}-mpfr
Stefan Reinauer074d9132009-09-26 16:43:17 +0000387 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100388 CC="$CC" ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000389 --infodir=$TARGETDIR/info \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100390 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
391 touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000392 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000393 $MAKE install DESTDIR=$DESTDIR || touch .failed
394
Patrick Georgi198d23c2012-12-08 08:02:44 +0100395 normalize_dirs
396
Stefan Reinauer074d9132009-09-26 16:43:17 +0000397 # work around build problem of libgmp.la
398 if [ "$DESTDIR" != "" ]; then
399 perl -pi -e "s,$DESTDIR,," $DESTDIR$TARGETDIR/libgmp.la
400 fi
401
402 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200403) > ${BUILDDIRPREFIX}-mpfr/crossgcc-build.log 2>&1
404test -r ${BUILDDIRPREFIX}-mpfr/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100405 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200406test -r ${BUILDDIRPREFIX}-mpfr/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000407fi
408
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200409if [ -f ${BUILDDIRPREFIX}-mpc/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000410 printf "Skipping MPC as it is already built\n"
411else
412printf "Building MPC ${MPC_VERSION} ... "
413(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200414 cd ${BUILDDIRPREFIX}-mpc
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000415 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100416 CC="$CC" ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000417 --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100418 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
419 touch .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000420 $MAKE $JOBS || touch .failed
421 $MAKE install DESTDIR=$DESTDIR || touch .failed
422
Patrick Georgi198d23c2012-12-08 08:02:44 +0100423 normalize_dirs
424
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000425 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200426) > ${BUILDDIRPREFIX}-mpc/crossgcc-build.log 2>&1
427test -r ${BUILDDIRPREFIX}-mpc/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100428 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200429test -r ${BUILDDIRPREFIX}-mpc/.failed && exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000430fi
431
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200432if [ -f ${BUILDDIRPREFIX}-libelf/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000433 printf "Skipping libelf as it is already built\n"
434else
435printf "Building libelf ${LIBELF_VERSION} ... "
436(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200437 cd ${BUILDDIRPREFIX}-libelf
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000438 rm -f .failed
439 echo "$HOSTCFLAGS"
Patrick Georgi643c9e82011-11-04 21:30:49 +0100440 CC="$CC" CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100441 ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000442 --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed
443 $MAKE $JOBS || touch .failed
Scott Duplichan4270a972014-12-12 20:21:40 -0600444 $MAKE install prefix=$DESTDIR$TARGETDIR || touch .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000445
Patrick Georgi198d23c2012-12-08 08:02:44 +0100446 normalize_dirs
447
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000448 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200449) > ${BUILDDIRPREFIX}-libelf/crossgcc-build.log 2>&1
450test -r ${BUILDDIRPREFIX}-libelf/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100451 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200452test -r ${BUILDDIRPREFIX}-libelf/.failed && exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000453fi
454
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200455if [ -f ${BUILDDIRPREFIX}-binutils/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000456 printf "Skipping binutils as it is already built\n"
457else
458printf "Building binutils ${BINUTILS_VERSION} ... "
459(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700460 # What a pain: binutils don't come with configure
461 # script anymore. Create it:
462 cd binutils-${BINUTILS_VERSION}/
463 autoconf
464 cd ..
465 # Now build binutils
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200466 cd ${BUILDDIRPREFIX}-binutils
Stefan Reinauer074d9132009-09-26 16:43:17 +0000467 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100468 CC="$CC" ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100469 --target=${TARGETARCH} --disable-werror --disable-nls \
470 $USE_GOLD CFLAGS="$HOSTCFLAGS" || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000471 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000472 $MAKE install DESTDIR=$DESTDIR || touch .failed
473 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200474) > ${BUILDDIRPREFIX}-binutils/crossgcc-build.log 2>&1
475test -r ${BUILDDIRPREFIX}-binutils/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100476 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200477test -r ${BUILDDIRPREFIX}-binutils/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000478fi
479
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200480if [ -f ${BUILDDIRPREFIX}-gcc/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000481 printf "Skipping GCC as it is already built\n"
482else
483printf "Building GCC ${GCC_VERSION} ... "
484(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700485 # Even worse than binutils: GCC does not come with configure
486 # script anymore, but also enforces an obsolete autoconf version
487 # to create it. This is a poster child of how autotools help make
488 # software portable.
489 cd gcc-${GCC_VERSION}
490 sed '/dnl Ensure exactly this Autoconf version is used/d' \
491 config/override.m4 > config/override.m4.new
492 autoconf_version=`autoconf -V | grep "autoconf" | tr ' ' '\n' | tail -1`
493 sed "s/${GCC_AUTOCONF_VERSION}/${autoconf_version}/g" \
494 config/override.m4.new > config/override.m4
495 autoconf
496 cd ..
497 # Now, finally, we can build gcc:
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200498 cd ${BUILDDIRPREFIX}-gcc
Stefan Reinauer074d9132009-09-26 16:43:17 +0000499 rm -f .failed
500 # GCC does not honour HOSTCFLAGS at all. CFLAGS are used for
501 # both target and host object files. This is pretty misdesigned.
502 # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET
503 # but it does not seem to work properly. At least the host library
504 # libiberty is not compiled with CFLAGS_FOR_BUILD.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700505 CC="$CC" CFLAGS_FOR_TARGET="-O2" CFLAGS="$HOSTCFLAGS" \
506 CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000507 --prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000508 --target=${TARGETARCH} --disable-werror --disable-shared \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000509 --disable-libssp --disable-bootstrap --disable-nls \
Patrick Georgi969cd932012-12-07 13:13:53 +0100510 --disable-libquadmath --without-headers \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000511 $GCC_OPTIONS --enable-languages="c" $USE_GOLD \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000512 --with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000513 --with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \
514 --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION $CROSSGCC_DATE" \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000515 || touch .failed
Patrick Georgi969cd932012-12-07 13:13:53 +0100516 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-gcc || touch .failed
517 $MAKE install-gcc DESTDIR=$DESTDIR || touch .failed
518
519 if [ "`echo $TARGETARCH | grep -c -- -mingw32`" -eq 0 ]; then
520 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-target-libgcc || touch .failed
521 $MAKE install-target-libgcc DESTDIR=$DESTDIR || touch .failed
522 fi
523
Stefan Reinauer074d9132009-09-26 16:43:17 +0000524 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200525) > ${BUILDDIRPREFIX}-gcc/crossgcc-build.log 2>&1
526test -r ${BUILDDIRPREFIX}-gcc/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100527 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200528test -r ${BUILDDIRPREFIX}-gcc/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000529fi
530
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200531if [ -f ${BUILDDIRPREFIX}-expat/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100532 printf "Skipping Expat as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100533elif [ $SKIPPYTHON -eq 1 ]; then
534 printf "Skipping Expat (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100535else
536printf "Building Expat ${EXPAT_VERSION} ... "
537(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200538 cd ${BUILDDIRPREFIX}-expat
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100539 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100540 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${EXPAT_DIR}/configure --disable-shared \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100541 --prefix=$TARGETDIR --target=${TARGETARCH} || touch .failed
542 $MAKE || touch .failed
543 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100544
545 normalize_dirs
546
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100547 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200548) > ${BUILDDIRPREFIX}-expat/crossgcc-build.log 2>&1
549test -r ${BUILDDIRPREFIX}-expat/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100550 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200551test -r ${BUILDDIRPREFIX}-expat/.failed && exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100552fi
553
554
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200555if [ -f ${BUILDDIRPREFIX}-python/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100556 printf "Skipping Python as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100557elif [ $SKIPPYTHON -eq 1 ]; then
558 printf "Skipping Python (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100559else
560printf "Building Python ${PYTHON_VERSION} ... "
561(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200562 cd ${BUILDDIRPREFIX}-python
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100563 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100564 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${PYTHON_DIR}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100565 --target=${TARGETARCH} || touch .failed
566 $MAKE $JOBS || touch .failed
567 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100568
569 normalize_dirs
570
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100571 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200572) > ${BUILDDIRPREFIX}-python/crossgcc-build.log 2>&1
573test -r ${BUILDDIRPREFIX}-python/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100574 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200575test -r ${BUILDDIRPREFIX}-python/.failed && exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100576fi
577
578
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200579if [ -f ${BUILDDIRPREFIX}-gdb/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000580 printf "Skipping GDB as it is already built\n"
Peter Stugeceacd772011-06-09 04:54:16 +0200581elif [ $SKIPGDB -eq 1 ]; then
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100582 printf "Skipping GDB (GDB support not enabled)\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000583else
584printf "Building GDB ${GDB_VERSION} ... "
585(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200586 cd ${BUILDDIRPREFIX}-gdb
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100587 export PYTHONHOME=$DESTDIR$TARGETDIR
Stefan Reinauer074d9132009-09-26 16:43:17 +0000588 rm -f .failed
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100589 LDFLAGS="-Wl,-rpath,\$\$ORIGIN/../lib/ -L$DESTDIR$TARGETDIR/lib \
590 -lpthread -ldl -lutil" \
Patrick Georgi643c9e82011-11-04 21:30:49 +0100591 CC="$CC" CFLAGS="$HOSTCFLAGS -I$DESTDIR$TARGETDIR/include" \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100592 ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR \
593 --target=${TARGETARCH} --disable-werror --disable-nls
Patrick Georgi73166c72010-04-14 20:42:42 +0000594 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000595 $MAKE install DESTDIR=$DESTDIR || touch .failed
596 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200597) > ${BUILDDIRPREFIX}-gdb/crossgcc-build.log 2>&1
598test -r ${BUILDDIRPREFIX}-gdb/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100599 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200600test -r ${BUILDDIRPREFIX}-gdb/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000601fi
602
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200603if [ -f $IASL_DIR/source/compiler/.success ]; then
Marc Jones2aac3f62011-08-08 16:07:50 -0600604 printf "Skipping IASL as it is already built\n"
605else
606printf "Building IASL ${IASL_VERSION} ... "
607(
Idwer Vollering6b11c8b2012-11-15 21:14:36 +0100608 cd $IASL_DIR/generate/unix
Stefan Reinauer4266b922012-12-05 16:18:32 -0800609 rm -f .failed
Marc Jones2aac3f62011-08-08 16:07:50 -0600610 CFLAGS="$HOSTCFLAGS"
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700611 HOST="_LINUX"
612 test $UNAME = "Darwin" && HOST="_APPLE"
613 test $UNAME = "FreeBSD" && HOST="_FreeBSD"
614 test $UNAME = "Cygwin" && HOST="_CYGWIN"
615 HOST="$HOST" OPT_CFLAGS="-O -D_FORTIFY_SOURCE=2" CFLAGS="$CFLAGS" $MAKE CC="$CC" iasl || touch .failed
Stefan Reinauer4266b922012-12-05 16:18:32 -0800616 rm -f $DESTDIR$TARGETDIR/bin/iasl || touch .failed
Zheng Bao3c4bd912013-08-27 10:23:13 +0800617 cp bin/iasl $DESTDIR$TARGETDIR/bin || touch .failed
Stefan Reinauer4266b922012-12-05 16:18:32 -0800618 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200619) > $IASL_DIR/source/compiler/crossgcc-build.log 2>&1
Stefan Reinauer4266b922012-12-05 16:18:32 -0800620test -r $IASL_DIR/generate/unix/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100621 printf "${green}ok${NC}\n"
Stefan Reinauer4266b922012-12-05 16:18:32 -0800622test -r $IASL_DIR/generate/unix/.failed && exit 1
Marc Jones2aac3f62011-08-08 16:07:50 -0600623fi
624
Zheng Bao30b895f2013-02-06 18:04:40 +0800625rm -f $DESTDIR$TARGETDIR/$0.commit.*
626cp $0 $DESTDIR$TARGETDIR/"$0.commit.`git describe`"
627
Stefan Reinauer074d9132009-09-26 16:43:17 +0000628if [ $SAVETEMPS -eq 0 ]; then
629 printf "Cleaning up... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200630 rm -rf ${GMP_DIR} ${BUILDDIRPREFIX}-gmp
631 rm -rf ${MPFR_DIR} ${BUILDDIRPREFIX}-mpfr
632 rm -rf ${MPC_DIR} ${BUILDDIRPREFIX}-mpc
633 rm -rf ${LIBELF_DIR} ${BUILDDIRPREFIX}-libelf
634 rm -rf ${BINUTILS_DIR} ${BUILDDIRPREFIX}-binutils
635 rm -rf ${GCC_DIR} ${BUILDDIRPREFIX}-gcc
636 rm -rf ${GDB_DIR} ${BUILDDIRPREFIX}-gdb
637 rm -rf ${EXPAT_DIR} ${BUILDDIRPREFIX}-expat
638 rm -rf ${PYTHON_DIR} ${BUILDDIRPREFIX}-python
Marc Jones2aac3f62011-08-08 16:07:50 -0600639 rm -rf ${IASL_DIR}
Stefan Reinauer074d9132009-09-26 16:43:17 +0000640 printf "${green}ok${NC}\n"
641else
642 printf "Leaving temporary files around... ${green}ok${NC}\n"
643fi
644
645printf "\n${green}You can now run your $TARGETARCH cross toolchain from $TARGETDIR.${NC}\n"
646
647