blob: 7221b8326ad5dfb1487db4c5351bdb7954010393 [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
Patrick Georgib7062882015-02-24 10:52:14 +010096searchtool()
Stefan Reinauer074d9132009-09-26 16:43:17 +000097{
98 # $1 short name
Patrick Georgib7062882015-02-24 10:52:14 +010099 # $2 search string
100 # $3 soft fail if set
101 # result: file name of that tool on stdout
102 # or no output if nothing suitable was found
103 search=GNU
104 if [ -n "$2" ]; then
105 search="$2"
106 fi
Stefan Reinauer074d9132009-09-26 16:43:17 +0000107 for i in "$1" "g$1" "gnu$1"; do
108 if test -x "`which $i 2>/dev/null`"; then
Patrick Georgib7062882015-02-24 10:52:14 +0100109 if test `$i --version 2>/dev/null |grep -c "$search"` \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100110 -gt 0; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000111 echo $i
112 return
113 fi
114 fi
115 done
Andrew Wub67e9a12014-04-28 18:13:44 +0800116 # A workaround for OSX 10.9 and some BSDs, whose nongnu
117 # patch and tar also work.
118 if [ $UNAME = "Darwin" -o $UNAME = "FreeBSD" -o $UNAME = "NetBSD" ]; then
Patrick Georgib7062882015-02-24 10:52:14 +0100119 if [ "$1" = "patch" -o "$1" = "tar" ]; then
Zheng Bao36156ff2012-09-28 16:18:58 +0800120 if test -x "`which $1 2>/dev/null`"; then
121 echo $1
122 return
123 fi
124 fi
125 fi
Stefan Reinauer074d9132009-09-26 16:43:17 +0000126 printf "${RED}ERROR:${red} Missing toolchain: $1${NC}\n" >&2
Patrick Georgib7062882015-02-24 10:52:14 +0100127 [ -z "$3" ] && exit 1
128 false
Stefan Reinauer074d9132009-09-26 16:43:17 +0000129}
130
Patrick Georgib7062882015-02-24 10:52:14 +0100131TAR=`searchtool tar` || exit $?
132PATCH=`searchtool patch` || exit $?
133MAKE=`searchtool make` || exit $?
Stefan Reinauer074d9132009-09-26 16:43:17 +0000134
Patrick Georgib7062882015-02-24 10:52:14 +0100135searchtool m4 > /dev/null
136searchtool bison > /dev/null
137searchtool flex flex > /dev/null
138searchtool g++ "Free Software Foundation" nofail > /dev/null || \
139searchtool clang "clang version"
Patrick Georgi5fb2b5c2012-05-12 23:25:23 +0200140
Stefan Reinauer074d9132009-09-26 16:43:17 +0000141cleanup()
142{
143 printf "Cleaning up temporary files... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200144 rm -rf ${BUILDDIRPREFIX}-* combined gcc-* gmp-* mpfr-* mpc-* libelf-* binutils-*
Patrick Georgi969cd932012-12-07 13:13:53 +0100145 rm -rf gdb-* acpica-* python-* expat-*
Stefan Reinauer074d9132009-09-26 16:43:17 +0000146 printf "${green}ok${NC}\n"
147}
148
149myhelp()
150{
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100151 printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-G] [-S]\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000152 printf " $0 [-V|--version]\n"
153 printf " $0 [-h|--help]\n\n"
154
155 printf "Options:\n"
156 printf " [-V|--version] print version number and exit\n"
157 printf " [-h|--help] print this help and exit\n"
158 printf " [-c|--clean] remove temporary files before build\n"
159 printf " [-t|--savetemps] don't remove temporary files after build\n"
Patrick Georgic1a75b12011-11-04 21:37:14 +0100160 printf " [-y|--ccache] Use ccache when building cross compiler\n"
Patrick Georgi73166c72010-04-14 20:42:42 +0000161 printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000162 printf " [-p|--platform <platform>] target platform to build cross compiler for\n"
163 printf " (defaults to $TARGETARCH)\n"
164 printf " [-d|--directory <target dir>] target directory to install cross compiler to\n"
165 printf " (defaults to $TARGETDIR)\n\n"
166 printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100167 printf " (for RPM builds, default unset)\n"
168 printf " [-G|--gdb] build GNU debugger\n"
169 printf " [-S|--scripting] build scripting support for GDB\n\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000170}
171
172myversion()
173{
174 # version tag is always printed, so just print the license here
175
176 cat << EOF
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000177Copyright (C) 2008-2010 by coresystems GmbH
Marc Jones2aac3f62011-08-08 16:07:50 -0600178Copyright (C) 2011 by Sage Electronic Engineering
Stefan Reinauer074d9132009-09-26 16:43:17 +0000179
180This program is free software; you can redistribute it and/or modify
181it under the terms of the GNU General Public License as published by
182the Free Software Foundation; version 2 of the License.
183
184This program is distributed in the hope that it will be useful,
185but WITHOUT ANY WARRANTY; without even the implied warranty of
186MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
187GNU General Public License for more details.
188
189EOF
190}
191
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700192printf "${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 +0000193
Patrick Georgi6bba29f2010-01-29 17:40:52 +0000194# Look if we have getopt. If not, build it.
195export PATH=$PATH:.
196getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
197
Stefan Reinauer074d9132009-09-26 16:43:17 +0000198# parse parameters.. try to find out whether we're running GNU getopt
Peter Stuge09377b72011-08-21 06:24:55 +0200199getoptbrand="`getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,'`"
200if [ "${getoptbrand}" = "getopt" ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000201 # Detected GNU getopt that supports long options.
Patrick Georgic1a75b12011-11-04 21:37:14 +0100202 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 +0000203 eval set "$args"
204else
205 # Detected non-GNU getopt
Patrick Georgic1a75b12011-11-04 21:37:14 +0100206 args=`getopt Vhcd:p:j:D:tGy $*`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000207 set -- $args
208fi
209
210if [ $? != 0 ]; then
211 myhelp
212 exit 1
213fi
214
215while true ; do
216 case "$1" in
217 -V|--version) shift; myversion; exit 0;;
218 -h|--help) shift; myhelp; exit 0;;
Patrick Georgi44af57a2013-12-19 22:06:22 +0100219 -c|--clean) shift; clean=1;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000220 -t|--savetemps) shift; SAVETEMPS=1;;
221 -d|--directory) shift; TARGETDIR="$1"; shift;;
222 -p|--platform) shift; TARGETARCH="$1"; shift;;
223 -D|--destdir) shift; DESTDIR="$1"; shift;;
Patrick Georgi73166c72010-04-14 20:42:42 +0000224 -j|--jobs) shift; JOBS="-j $1"; shift;;
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100225 -G|--gdb) shift; SKIPGDB=0;;
226 -S|--scripting) shift; SKIPPYTHON=0;;
Patrick Georgic1a75b12011-11-04 21:37:14 +0100227 -y|--ccache) shift; USECCACHE=1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200228 --) shift; break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000229 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
Patrick Georgid2e0dd52013-06-09 08:05:45 +0200230 *) break;;
Stefan Reinauer074d9132009-09-26 16:43:17 +0000231 esac
232done
233
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700234case "$TARGETARCH" in
David Hubbard5b0420a2013-05-28 16:33:15 -0600235 i386-elf) ;;
236 i386-mingw32) ;;
Patrick Georgi9b7efa52015-03-08 09:20:36 +0100237 mipsel-elf) ;;
Patrick Georgif0bbc952015-03-07 10:57:25 +0100238 riscv-elf) ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700239 i386*) TARGETARCH=i386-elf;;
Patrick Georgic8883262013-09-19 10:57:58 +0200240 arm*) TARGETARCH=armv7-a-eabi;;
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700241 aarch64*) TARGETARCH=aarch64-elf;;
242 *) printf "${red}WARNING: Unsupported architecture $TARGETARCH.${NC}\n\n"; ;;
Ronald G. Minnichb460a662013-05-26 05:33:35 -0700243esac
244
245echo "Target arch is now $TARGETARCH"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200246BUILDDIRPREFIX=build-${TARGETARCH}
247
Patrick Georgi44af57a2013-12-19 22:06:22 +0100248if [ "$clean" = "1" ]; then
249 cleanup
250fi
251
Peter Stugeceacd772011-06-09 04:54:16 +0200252GDB_PACKAGE="GDB"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100253PYTHON_PACKAGE="PYTHON"
254EXPAT_PACKAGE="EXPAT"
Peter Stugeceacd772011-06-09 04:54:16 +0200255if [ $SKIPGDB -eq 1 ]; then
256 printf "Will skip GDB ... ${green}ok${NC}\n"
Peter Stuge0e8ee812011-08-28 11:04:23 +0200257 GDB_ARCHIVE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200258 GDB_PACKAGE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100259 if [ $SKIPPYTHON -eq 0 ]; then
260 printf "Python scripting needs GDB ... disabling ... ${green}ok${NC}\n"
261 SKIPPYTHON=1
262 fi
263fi
264if [ $SKIPPYTHON -eq 1 ]; then
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600265 PYTHON_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100266 PYTHON_PACKAGE=""
Jonathan A. Kollasch2d7ab4c2011-11-07 13:05:18 -0600267 EXPAT_ARCHIVE=""
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100268 EXPAT_PACKAGE=""
Peter Stugeceacd772011-06-09 04:54:16 +0200269fi
270
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700271# coreboot does not like the GOLD linker
272# USE_GOLD="--enable-gold"
273USE_GOLD=""
274GCC_OPTIONS="--enable-lto"
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000275
Stefan Reinauer074d9132009-09-26 16:43:17 +0000276printf "Downloading tar balls ... \n"
277mkdir -p tarballs
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100278for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100279 $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100280 $IASL_ARCHIVE $PYTHON_ARCHIVE $EXPAT_ARCHIVE; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000281 FILE=`basename $ARCHIVE`
282 printf " * $FILE "
283 test -f tarballs/$FILE && printf "(cached)" || (
284 printf "(downloading)"
285 cd tarballs
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200286 wget --no-check-certificate -q $ARCHIVE
Stefan Reinauer074d9132009-09-26 16:43:17 +0000287 )
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100288 test -f tarballs/$FILE || \
Zheng Bao5b209c02012-09-20 16:09:51 +0800289 printf "\n${RED}Failed to download $FILE.${NC}\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000290 test -f tarballs/$FILE || exit 1
291 printf "\n"
292done
293printf "Downloaded tar balls ... "
294printf "${green}ok${NC}\n"
295
296printf "Unpacking and patching ... \n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100297for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS $PYTHON_PACKAGE \
Patrick Georgi969cd932012-12-07 13:13:53 +0100298 $EXPAT_PACKAGE $GDB_PACKAGE IASL; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000299 archive=$PACKAGE"_ARCHIVE"
Peter Stuge09377b72011-08-21 06:24:55 +0200300 archive="`eval echo '$'$archive`"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000301 dir=$PACKAGE"_DIR"
Peter Stuge09377b72011-08-21 06:24:55 +0200302 dir="`eval echo '$'${dir}`"
Zheng Baof95bb2d2013-12-13 12:30:46 +0800303 test -d ${dir} && test -f ${dir}/.unpack_success || (
Stefan Reinauer074d9132009-09-26 16:43:17 +0000304 printf " * `basename $archive`\n"
305 FLAGS=zxf
Peter Stuge09377b72011-08-21 06:24:55 +0200306 suffix=`echo $archive | sed 's,.*\.,,'`
307 test "$suffix" = "gz" && FLAGS=zxf
308 test "$suffix" = "bz2" && FLAGS=jxf
Patrick Georgi53c388f2015-03-07 09:55:18 +0100309 test "$suffix" = "xz" && FLAGS="--xz -xf"
Peter Stuge09377b72011-08-21 06:24:55 +0200310 test "$suffix" = "lzma" && FLAGS="--lzma -xf"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000311 $TAR $FLAGS tarballs/`basename $archive`
Peter Stuge09377b72011-08-21 06:24:55 +0200312 for patch in patches/${dir}_*.patch; do
Stefan Reinauer074d9132009-09-26 16:43:17 +0000313 test -r $patch || continue
314 printf " o `basename $patch`\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100315 $PATCH -s -N -p0 < `echo $patch` || \
Zheng Bao5b209c02012-09-20 16:09:51 +0800316 printf "\n${RED}Failed $patch.${NC}\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000317 done
Zheng Bao691b313c2013-12-09 14:09:07 +0800318 touch ${dir}/.unpack_success
Stefan Reinauer074d9132009-09-26 16:43:17 +0000319 )
320done
321printf "Unpacked and patched ... "
322printf "${green}ok${NC}\n"
323
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700324CC=cc
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700325if [ $UNAME = "Darwin" ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000326 #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix"
327
328 # generally the OS X compiler can create x64 binaries.
329 # Per default it generated i386 binaries in 10.5 and x64
330 # binaries in 10.6 (even if the kernel is 32bit)
331 # For some weird reason, 10.5 autodetects an ABI=64 though
332 # so we're setting the ABI explicitly here.
Zheng Bao04ceed62012-10-23 19:41:25 +0800333 if [ `sysctl -n hw.optional.x86_64 2>/dev/null` -eq 1 ] 2>/dev/null; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000334 OPTIONS="ABI=64"
335 else
336 OPTIONS="ABI=32"
337 fi
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700338
Stefan Reinauer4266b922012-12-05 16:18:32 -0800339 # In Xcode 4.5.2 the default compiler is clang.
340 # However, this compiler fails to compile gcc 4.7.x. As a
341 # workaround it's possible to compile gcc with llvm-gcc.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700342 if $CC -v 2>&1 | grep -q LLVM; then
Stefan Reinauer4266b922012-12-05 16:18:32 -0800343 CC=llvm-gcc
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700344 fi
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000345fi
346
Patrick Georgic1a75b12011-11-04 21:37:14 +0100347if [ "$USECCACHE" = 1 ]; then
348 CC="ccache $CC"
349fi
350
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200351mkdir -p ${BUILDDIRPREFIX}-gmp ${BUILDDIRPREFIX}-mpfr ${BUILDDIRPREFIX}-mpc ${BUILDDIRPREFIX}-libelf ${BUILDDIRPREFIX}-binutils \
352 ${BUILDDIRPREFIX}-gcc ${BUILDDIRPREFIX}-python ${BUILDDIRPREFIX}-expat
Stefan Reinauer16bd7892012-12-07 23:57:01 +0100353
354mkdir -p $DESTDIR$TARGETDIR/bin
355export PATH=$DESTDIR$TARGETDIR/bin:$PATH
356
Peter Stugeceacd772011-06-09 04:54:16 +0200357if [ $SKIPGDB -eq 0 ]; then
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200358 mkdir -p ${BUILDDIRPREFIX}-gdb
Peter Stugeceacd772011-06-09 04:54:16 +0200359fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200360if [ -f ${BUILDDIRPREFIX}-gmp/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000361 printf "Skipping GMP as it is already built\n"
362else
363printf "Building GMP ${GMP_VERSION} ... "
364(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200365 cd ${BUILDDIRPREFIX}-gmp
Stefan Reinauer074d9132009-09-26 16:43:17 +0000366 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100367 CC="$CC" ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000368 || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000369 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000370 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100371
372 normalize_dirs
373
Stefan Reinauer074d9132009-09-26 16:43:17 +0000374 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200375) > ${BUILDDIRPREFIX}-gmp/crossgcc-build.log 2>&1
376test -r ${BUILDDIRPREFIX}-gmp/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100377 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200378test -r ${BUILDDIRPREFIX}-gmp/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000379fi
380
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700381# Now set CFLAGS to match GMP CFLAGS but strip out -pedantic
382# as GCC 4.6.x fails if it's there.
383HOSTCFLAGS=`grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2 |\
384 sed s,-pedantic,,`
Stefan Reinauer074d9132009-09-26 16:43:17 +0000385
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200386if [ -f ${BUILDDIRPREFIX}-mpfr/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000387 printf "Skipping MPFR as it is already built\n"
388else
389printf "Building MPFR ${MPFR_VERSION} ... "
390(
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700391 test $UNAME = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200392 cd ${BUILDDIRPREFIX}-mpfr
Stefan Reinauer074d9132009-09-26 16:43:17 +0000393 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100394 CC="$CC" ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000395 --infodir=$TARGETDIR/info \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100396 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
397 touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000398 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000399 $MAKE install DESTDIR=$DESTDIR || touch .failed
400
Patrick Georgi198d23c2012-12-08 08:02:44 +0100401 normalize_dirs
402
Stefan Reinauer074d9132009-09-26 16:43:17 +0000403 # work around build problem of libgmp.la
404 if [ "$DESTDIR" != "" ]; then
405 perl -pi -e "s,$DESTDIR,," $DESTDIR$TARGETDIR/libgmp.la
406 fi
407
408 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200409) > ${BUILDDIRPREFIX}-mpfr/crossgcc-build.log 2>&1
410test -r ${BUILDDIRPREFIX}-mpfr/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100411 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200412test -r ${BUILDDIRPREFIX}-mpfr/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000413fi
414
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200415if [ -f ${BUILDDIRPREFIX}-mpc/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000416 printf "Skipping MPC as it is already built\n"
417else
418printf "Building MPC ${MPC_VERSION} ... "
419(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200420 cd ${BUILDDIRPREFIX}-mpc
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000421 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100422 CC="$CC" ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000423 --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100424 --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
425 touch .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000426 $MAKE $JOBS || touch .failed
427 $MAKE install DESTDIR=$DESTDIR || touch .failed
428
Patrick Georgi198d23c2012-12-08 08:02:44 +0100429 normalize_dirs
430
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000431 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200432) > ${BUILDDIRPREFIX}-mpc/crossgcc-build.log 2>&1
433test -r ${BUILDDIRPREFIX}-mpc/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100434 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200435test -r ${BUILDDIRPREFIX}-mpc/.failed && exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000436fi
437
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200438if [ -f ${BUILDDIRPREFIX}-libelf/.success ]; then
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000439 printf "Skipping libelf as it is already built\n"
440else
441printf "Building libelf ${LIBELF_VERSION} ... "
442(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200443 cd ${BUILDDIRPREFIX}-libelf
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000444 rm -f .failed
445 echo "$HOSTCFLAGS"
Patrick Georgi643c9e82011-11-04 21:30:49 +0100446 CC="$CC" CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100447 ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000448 --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed
449 $MAKE $JOBS || touch .failed
Scott Duplichan4270a972014-12-12 20:21:40 -0600450 $MAKE install prefix=$DESTDIR$TARGETDIR || touch .failed
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000451
Patrick Georgi198d23c2012-12-08 08:02:44 +0100452 normalize_dirs
453
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000454 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200455) > ${BUILDDIRPREFIX}-libelf/crossgcc-build.log 2>&1
456test -r ${BUILDDIRPREFIX}-libelf/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100457 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200458test -r ${BUILDDIRPREFIX}-libelf/.failed && exit 1
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000459fi
460
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200461if [ -f ${BUILDDIRPREFIX}-binutils/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000462 printf "Skipping binutils as it is already built\n"
463else
464printf "Building binutils ${BINUTILS_VERSION} ... "
465(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700466 # What a pain: binutils don't come with configure
467 # script anymore. Create it:
468 cd binutils-${BINUTILS_VERSION}/
469 autoconf
470 cd ..
471 # Now build binutils
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200472 cd ${BUILDDIRPREFIX}-binutils
Stefan Reinauer074d9132009-09-26 16:43:17 +0000473 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100474 CC="$CC" ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100475 --target=${TARGETARCH} --disable-werror --disable-nls \
476 $USE_GOLD CFLAGS="$HOSTCFLAGS" || touch .failed
Patrick Georgi73166c72010-04-14 20:42:42 +0000477 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000478 $MAKE install DESTDIR=$DESTDIR || touch .failed
479 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200480) > ${BUILDDIRPREFIX}-binutils/crossgcc-build.log 2>&1
481test -r ${BUILDDIRPREFIX}-binutils/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100482 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200483test -r ${BUILDDIRPREFIX}-binutils/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000484fi
485
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200486if [ -f ${BUILDDIRPREFIX}-gcc/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000487 printf "Skipping GCC as it is already built\n"
488else
489printf "Building GCC ${GCC_VERSION} ... "
490(
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700491 # Even worse than binutils: GCC does not come with configure
492 # script anymore, but also enforces an obsolete autoconf version
493 # to create it. This is a poster child of how autotools help make
494 # software portable.
495 cd gcc-${GCC_VERSION}
496 sed '/dnl Ensure exactly this Autoconf version is used/d' \
497 config/override.m4 > config/override.m4.new
498 autoconf_version=`autoconf -V | grep "autoconf" | tr ' ' '\n' | tail -1`
499 sed "s/${GCC_AUTOCONF_VERSION}/${autoconf_version}/g" \
500 config/override.m4.new > config/override.m4
501 autoconf
502 cd ..
503 # Now, finally, we can build gcc:
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200504 cd ${BUILDDIRPREFIX}-gcc
Stefan Reinauer074d9132009-09-26 16:43:17 +0000505 rm -f .failed
506 # GCC does not honour HOSTCFLAGS at all. CFLAGS are used for
507 # both target and host object files. This is pretty misdesigned.
508 # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET
509 # but it does not seem to work properly. At least the host library
510 # libiberty is not compiled with CFLAGS_FOR_BUILD.
Stefan Reinauer9491b4d2011-10-11 22:37:59 -0700511 CC="$CC" CFLAGS_FOR_TARGET="-O2" CFLAGS="$HOSTCFLAGS" \
512 CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000513 --prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \
Stefan Reinauer6ade1612010-01-16 16:44:20 +0000514 --target=${TARGETARCH} --disable-werror --disable-shared \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000515 --disable-libssp --disable-bootstrap --disable-nls \
Patrick Georgi969cd932012-12-07 13:13:53 +0100516 --disable-libquadmath --without-headers \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000517 $GCC_OPTIONS --enable-languages="c" $USE_GOLD \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000518 --with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \
Stefan Reinauer5f1ad892010-05-17 11:02:25 +0000519 --with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \
520 --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION $CROSSGCC_DATE" \
Stefan Reinauer074d9132009-09-26 16:43:17 +0000521 || touch .failed
Patrick Georgi969cd932012-12-07 13:13:53 +0100522 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-gcc || touch .failed
523 $MAKE install-gcc DESTDIR=$DESTDIR || touch .failed
524
525 if [ "`echo $TARGETARCH | grep -c -- -mingw32`" -eq 0 ]; then
526 $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-target-libgcc || touch .failed
527 $MAKE install-target-libgcc DESTDIR=$DESTDIR || touch .failed
528 fi
529
Stefan Reinauer074d9132009-09-26 16:43:17 +0000530 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200531) > ${BUILDDIRPREFIX}-gcc/crossgcc-build.log 2>&1
532test -r ${BUILDDIRPREFIX}-gcc/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100533 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200534test -r ${BUILDDIRPREFIX}-gcc/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000535fi
536
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200537if [ -f ${BUILDDIRPREFIX}-expat/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100538 printf "Skipping Expat as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100539elif [ $SKIPPYTHON -eq 1 ]; then
540 printf "Skipping Expat (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100541else
542printf "Building Expat ${EXPAT_VERSION} ... "
543(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200544 cd ${BUILDDIRPREFIX}-expat
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100545 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100546 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${EXPAT_DIR}/configure --disable-shared \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100547 --prefix=$TARGETDIR --target=${TARGETARCH} || touch .failed
548 $MAKE || touch .failed
549 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100550
551 normalize_dirs
552
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100553 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200554) > ${BUILDDIRPREFIX}-expat/crossgcc-build.log 2>&1
555test -r ${BUILDDIRPREFIX}-expat/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100556 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200557test -r ${BUILDDIRPREFIX}-expat/.failed && exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100558fi
559
560
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200561if [ -f ${BUILDDIRPREFIX}-python/.success ]; then
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100562 printf "Skipping Python as it is already built\n"
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100563elif [ $SKIPPYTHON -eq 1 ]; then
564 printf "Skipping Python (Python scripting not enabled)\n"
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100565else
566printf "Building Python ${PYTHON_VERSION} ... "
567(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200568 cd ${BUILDDIRPREFIX}-python
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100569 rm -f .failed
Patrick Georgi643c9e82011-11-04 21:30:49 +0100570 CC="$CC" CFLAGS="$HOSTCFLAGS" ../${PYTHON_DIR}/configure --prefix=$TARGETDIR \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100571 --target=${TARGETARCH} || touch .failed
572 $MAKE $JOBS || touch .failed
573 $MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi198d23c2012-12-08 08:02:44 +0100574
575 normalize_dirs
576
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100577 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200578) > ${BUILDDIRPREFIX}-python/crossgcc-build.log 2>&1
579test -r ${BUILDDIRPREFIX}-python/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100580 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200581test -r ${BUILDDIRPREFIX}-python/.failed && exit 1
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100582fi
583
584
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200585if [ -f ${BUILDDIRPREFIX}-gdb/.success ]; then
Stefan Reinauer074d9132009-09-26 16:43:17 +0000586 printf "Skipping GDB as it is already built\n"
Peter Stugeceacd772011-06-09 04:54:16 +0200587elif [ $SKIPGDB -eq 1 ]; then
Stefan Reinauer1200ec52011-11-01 22:39:41 +0100588 printf "Skipping GDB (GDB support not enabled)\n"
Stefan Reinauer074d9132009-09-26 16:43:17 +0000589else
590printf "Building GDB ${GDB_VERSION} ... "
591(
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200592 cd ${BUILDDIRPREFIX}-gdb
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100593 export PYTHONHOME=$DESTDIR$TARGETDIR
Stefan Reinauer074d9132009-09-26 16:43:17 +0000594 rm -f .failed
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100595 LDFLAGS="-Wl,-rpath,\$\$ORIGIN/../lib/ -L$DESTDIR$TARGETDIR/lib \
596 -lpthread -ldl -lutil" \
Patrick Georgi643c9e82011-11-04 21:30:49 +0100597 CC="$CC" CFLAGS="$HOSTCFLAGS -I$DESTDIR$TARGETDIR/include" \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100598 ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR \
599 --target=${TARGETARCH} --disable-werror --disable-nls
Patrick Georgi73166c72010-04-14 20:42:42 +0000600 $MAKE $JOBS || touch .failed
Stefan Reinauer074d9132009-09-26 16:43:17 +0000601 $MAKE install DESTDIR=$DESTDIR || touch .failed
602 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200603) > ${BUILDDIRPREFIX}-gdb/crossgcc-build.log 2>&1
604test -r ${BUILDDIRPREFIX}-gdb/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100605 printf "${green}ok${NC}\n"
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200606test -r ${BUILDDIRPREFIX}-gdb/.failed && exit 1
Stefan Reinauer074d9132009-09-26 16:43:17 +0000607fi
608
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200609if [ -f $IASL_DIR/source/compiler/.success ]; then
Marc Jones2aac3f62011-08-08 16:07:50 -0600610 printf "Skipping IASL as it is already built\n"
611else
612printf "Building IASL ${IASL_VERSION} ... "
613(
Idwer Vollering6b11c8b2012-11-15 21:14:36 +0100614 cd $IASL_DIR/generate/unix
Stefan Reinauer4266b922012-12-05 16:18:32 -0800615 rm -f .failed
Marc Jones2aac3f62011-08-08 16:07:50 -0600616 CFLAGS="$HOSTCFLAGS"
Stefan Reinauer0d2119d2013-07-10 14:27:56 -0700617 HOST="_LINUX"
618 test $UNAME = "Darwin" && HOST="_APPLE"
619 test $UNAME = "FreeBSD" && HOST="_FreeBSD"
620 test $UNAME = "Cygwin" && HOST="_CYGWIN"
621 HOST="$HOST" OPT_CFLAGS="-O -D_FORTIFY_SOURCE=2" CFLAGS="$CFLAGS" $MAKE CC="$CC" iasl || touch .failed
Stefan Reinauer4266b922012-12-05 16:18:32 -0800622 rm -f $DESTDIR$TARGETDIR/bin/iasl || touch .failed
Zheng Bao3c4bd912013-08-27 10:23:13 +0800623 cp bin/iasl $DESTDIR$TARGETDIR/bin || touch .failed
Stefan Reinauer4266b922012-12-05 16:18:32 -0800624 if [ ! -f .failed ]; then touch .success; fi
Patrick Georgi6e61ad32012-05-12 23:19:30 +0200625) > $IASL_DIR/source/compiler/crossgcc-build.log 2>&1
Stefan Reinauer4266b922012-12-05 16:18:32 -0800626test -r $IASL_DIR/generate/unix/.failed && printf "${RED}failed${NC}\n" || \
Stefan Reinauer2c3cd122011-11-01 21:43:50 +0100627 printf "${green}ok${NC}\n"
Stefan Reinauer4266b922012-12-05 16:18:32 -0800628test -r $IASL_DIR/generate/unix/.failed && exit 1
Marc Jones2aac3f62011-08-08 16:07:50 -0600629fi
630
Zheng Bao30b895f2013-02-06 18:04:40 +0800631rm -f $DESTDIR$TARGETDIR/$0.commit.*
632cp $0 $DESTDIR$TARGETDIR/"$0.commit.`git describe`"
633
Stefan Reinauer074d9132009-09-26 16:43:17 +0000634if [ $SAVETEMPS -eq 0 ]; then
635 printf "Cleaning up... "
Patrick Georgi3af0aa22013-09-17 20:59:52 +0200636 rm -rf ${GMP_DIR} ${BUILDDIRPREFIX}-gmp
637 rm -rf ${MPFR_DIR} ${BUILDDIRPREFIX}-mpfr
638 rm -rf ${MPC_DIR} ${BUILDDIRPREFIX}-mpc
639 rm -rf ${LIBELF_DIR} ${BUILDDIRPREFIX}-libelf
640 rm -rf ${BINUTILS_DIR} ${BUILDDIRPREFIX}-binutils
641 rm -rf ${GCC_DIR} ${BUILDDIRPREFIX}-gcc
642 rm -rf ${GDB_DIR} ${BUILDDIRPREFIX}-gdb
643 rm -rf ${EXPAT_DIR} ${BUILDDIRPREFIX}-expat
644 rm -rf ${PYTHON_DIR} ${BUILDDIRPREFIX}-python
Marc Jones2aac3f62011-08-08 16:07:50 -0600645 rm -rf ${IASL_DIR}
Stefan Reinauer074d9132009-09-26 16:43:17 +0000646 printf "${green}ok${NC}\n"
647else
648 printf "Leaving temporary files around... ${green}ok${NC}\n"
649fi
650
651printf "\n${green}You can now run your $TARGETARCH cross toolchain from $TARGETDIR.${NC}\n"
652
653