Peter Stuge | 09377b7 | 2011-08-21 06:24:55 +0200 | [diff] [blame] | 1 | #!/bin/sh |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 2 | # |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 3 | # Copyright (C) 2008-2010 by coresystems GmbH |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 4 | # written by Patrick Georgi <patrick.georgi@coresystems.de> and |
| 5 | # Stefan Reinauer <stefan.reinauer@coresystems.de> |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 6 | # |
Marc Jones | 2aac3f6 | 2011-08-08 16:07:50 -0600 | [diff] [blame] | 7 | # Copyright (C) 2011 by Sage Electronic Engineering |
| 8 | # |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 9 | # 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 Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 20 | # Foundation, Inc. |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 21 | # |
| 22 | |
Patrick Georgi | 8135dba | 2015-03-17 21:05:20 +0100 | [diff] [blame] | 23 | cd `dirname $0` |
| 24 | |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 25 | CROSSGCC_DATE="June 4th, 2015" |
| 26 | CROSSGCC_VERSION="1.29" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 27 | |
| 28 | # default settings |
| 29 | TARGETDIR=`pwd`/xgcc |
| 30 | TARGETARCH=i386-elf |
| 31 | DESTDIR= |
| 32 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 33 | # GCC toolchain version numbers |
Patrick Georgi | 53c388f | 2015-03-07 09:55:18 +0100 | [diff] [blame] | 34 | GMP_VERSION=6.0.0 |
Stefan Reinauer | 0d2119d | 2013-07-10 14:27:56 -0700 | [diff] [blame] | 35 | MPFR_VERSION=3.1.2 |
Paul Menzel | e661942 | 2015-02-23 10:33:59 +0100 | [diff] [blame] | 36 | MPC_VERSION=1.0.3 |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 37 | LIBELF_VERSION=0.8.13 |
Patrick Georgi | 53c388f | 2015-03-07 09:55:18 +0100 | [diff] [blame] | 38 | GCC_VERSION=4.9.2 |
Stefan Reinauer | 0d2119d | 2013-07-10 14:27:56 -0700 | [diff] [blame] | 39 | GCC_AUTOCONF_VERSION=2.69 |
Patrick Georgi | 53c388f | 2015-03-07 09:55:18 +0100 | [diff] [blame] | 40 | BINUTILS_VERSION=2.25 |
| 41 | GDB_VERSION=7.9 |
| 42 | IASL_VERSION=20150204 |
| 43 | PYTHON_VERSION=3.4.3 |
Idwer Vollering | 296a015 | 2012-10-26 01:48:04 +0200 | [diff] [blame] | 44 | EXPAT_VERSION=2.1.0 |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 45 | # CLANG version number |
| 46 | CLANG_VERSION=3.6.1 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 47 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 48 | # GCC toolchain archive locations |
Patrick Georgi | 53c388f | 2015-03-07 09:55:18 +0100 | [diff] [blame] | 49 | GMP_ARCHIVE="http://ftpmirror.gnu.org/gmp/gmp-${GMP_VERSION}a.tar.bz2" |
Patrick Georgi | 6e61ad3 | 2012-05-12 23:19:30 +0200 | [diff] [blame] | 50 | MPFR_ARCHIVE="http://ftpmirror.gnu.org/mpfr/mpfr-${MPFR_VERSION}.tar.bz2" |
Idwer Vollering | 7962fc7 | 2012-10-25 02:14:09 +0200 | [diff] [blame] | 51 | MPC_ARCHIVE="http://ftpmirror.gnu.org/mpc/mpc-${MPC_VERSION}.tar.gz" |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 52 | LIBELF_ARCHIVE="http://www.mr511.de/software/libelf-${LIBELF_VERSION}.tar.gz" |
Idwer Vollering | 1cfee0b | 2012-10-25 02:03:53 +0200 | [diff] [blame] | 53 | GCC_ARCHIVE="http://ftpmirror.gnu.org/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.bz2" |
Stefan Reinauer | 0d2119d | 2013-07-10 14:27:56 -0700 | [diff] [blame] | 54 | BINUTILS_ARCHIVE="http://ftpmirror.gnu.org/binutils/binutils-${BINUTILS_VERSION}.tar.bz2" |
Patrick Georgi | 53c388f | 2015-03-07 09:55:18 +0100 | [diff] [blame] | 55 | GDB_ARCHIVE="http://ftpmirror.gnu.org/gdb/gdb-${GDB_VERSION}.tar.xz" |
| 56 | IASL_ARCHIVE="https://acpica.org/sites/acpica/files/acpica-unix-${IASL_VERSION}.tar.gz" |
| 57 | PYTHON_ARCHIVE="http://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz" |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 58 | EXPAT_ARCHIVE="http://downloads.sourceforge.net/sourceforge/expat/expat-${EXPAT_VERSION}.tar.gz" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 59 | # CLANG toolchain archive locations |
| 60 | LLVM_ARCHIVE="http://llvm.org/releases/${CLANG_VERSION}/llvm-${CLANG_VERSION}.src.tar.xz" |
| 61 | CFE_ARCHIVE="http://llvm.org/releases/${CLANG_VERSION}/cfe-${CLANG_VERSION}.src.tar.xz" |
| 62 | CRT_ARCHIVE="http://llvm.org/releases/${CLANG_VERSION}/compiler-rt-${CLANG_VERSION}.src.tar.xz" |
| 63 | CTE_ARCHIVE="http://llvm.org/releases/${CLANG_VERSION}/clang-tools-extra-${CLANG_VERSION}.src.tar.xz" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 64 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 65 | # GCC toolchain directories |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 66 | GMP_DIR="gmp-${GMP_VERSION}" |
| 67 | MPFR_DIR="mpfr-${MPFR_VERSION}" |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 68 | MPC_DIR="mpc-${MPC_VERSION}" |
| 69 | LIBELF_DIR="libelf-${LIBELF_VERSION}" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 70 | GCC_DIR="gcc-${GCC_VERSION}" |
| 71 | BINUTILS_DIR="binutils-${BINUTILS_VERSION}" |
| 72 | GDB_DIR="gdb-${GDB_VERSION}" |
Marc Jones | 2aac3f6 | 2011-08-08 16:07:50 -0600 | [diff] [blame] | 73 | IASL_DIR="acpica-unix-${IASL_VERSION}" |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 74 | PYTHON_DIR="Python-${PYTHON_VERSION}" |
| 75 | EXPAT_DIR="expat-${EXPAT_VERSION}" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 76 | # CLANG toolchain directories |
| 77 | LLVM_DIR="llvm-${CLANG_VERSION}.src" |
| 78 | CFE_DIR="cfe-${CLANG_VERSION}.src" |
| 79 | CRT_DIR="compiler-rt-${CLANG_VERSION}.src" |
| 80 | CTE_DIR="clang-tools-extra-${CLANG_VERSION}.src" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 81 | |
Patrick Georgi | 6321f52 | 2015-02-27 23:36:26 +0100 | [diff] [blame] | 82 | unset MAKELEVEL MAKEFLAGS |
| 83 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 84 | SAVETEMPS=0 |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 85 | BUILDCLANG=0 |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 86 | SKIPGDB=1 |
| 87 | SKIPPYTHON=1 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 88 | |
Patrick Georgi | 1861ff7 | 2011-10-31 12:15:55 +0100 | [diff] [blame] | 89 | red='\033[0;31m' |
| 90 | RED='\033[1;31m' |
| 91 | green='\033[0;32m' |
| 92 | GREEN='\033[1;32m' |
| 93 | blue='\033[0;34m' |
| 94 | BLUE='\033[1;34m' |
| 95 | cyan='\033[0;36m' |
| 96 | CYAN='\033[1;36m' |
| 97 | NC='\033[0m' # No Color |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 98 | |
Stefan Reinauer | 0d2119d | 2013-07-10 14:27:56 -0700 | [diff] [blame] | 99 | UNAME=`uname` |
| 100 | |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 101 | normalize_dirs() |
| 102 | { |
| 103 | mkdir -p $DESTDIR$TARGETDIR/lib |
| 104 | test -d $DESTDIR$TARGETDIR/lib32 && mv $DESTDIR$TARGETDIR/lib32/* $DESTDIR$TARGETDIR/lib |
| 105 | test -d $DESTDIR$TARGETDIR/lib64 && mv $DESTDIR$TARGETDIR/lib64/* $DESTDIR$TARGETDIR/lib |
| 106 | rmdir -p $DESTDIR$TARGETDIR/lib32 $DESTDIR$TARGETDIR/lib64 |
| 107 | |
| 108 | perl -pi -e "s,/lib32,/lib," $DESTDIR$TARGETDIR/lib/*.la |
| 109 | perl -pi -e "s,/lib64,/lib," $DESTDIR$TARGETDIR/lib/*.la |
| 110 | } |
| 111 | |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 112 | searchtool() |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 113 | { |
| 114 | # $1 short name |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 115 | # $2 search string |
| 116 | # $3 soft fail if set |
| 117 | # result: file name of that tool on stdout |
| 118 | # or no output if nothing suitable was found |
| 119 | search=GNU |
| 120 | if [ -n "$2" ]; then |
| 121 | search="$2" |
| 122 | fi |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 123 | for i in "$1" "g$1" "gnu$1"; do |
| 124 | if test -x "`which $i 2>/dev/null`"; then |
Alexander Couzens | d268ab3 | 2015-04-13 17:15:12 +0200 | [diff] [blame] | 125 | if test `cat /dev/null | $i --version 2>&1 |grep -c "$search"` \ |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 126 | -gt 0; then |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 127 | echo $i |
| 128 | return |
| 129 | fi |
| 130 | fi |
| 131 | done |
Andrew Wu | b67e9a1 | 2014-04-28 18:13:44 +0800 | [diff] [blame] | 132 | # A workaround for OSX 10.9 and some BSDs, whose nongnu |
| 133 | # patch and tar also work. |
Patrick Georgi | 7cb26b4 | 2015-04-28 21:29:22 +0200 | [diff] [blame] | 134 | if [ $UNAME = "Darwin" -o $UNAME = "FreeBSD" -o $UNAME = "NetBSD" -o $UNAME = "OpenBSD" ]; then |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 135 | if [ "$1" = "patch" -o "$1" = "tar" ]; then |
Zheng Bao | 36156ff | 2012-09-28 16:18:58 +0800 | [diff] [blame] | 136 | if test -x "`which $1 2>/dev/null`"; then |
| 137 | echo $1 |
| 138 | return |
| 139 | fi |
| 140 | fi |
| 141 | fi |
zbao | 939dc84 | 2015-04-30 04:44:07 +0800 | [diff] [blame] | 142 | if [ "`echo $1 | cut -b -3`" = "sha" ]; then |
| 143 | if [ $UNAME = "FreeBSD" ]; then |
| 144 | if test -x "`which sha1 2>/dev/null`"; then |
| 145 | echo sha1 |
| 146 | return |
| 147 | fi |
| 148 | fi |
| 149 | if [ $UNAME = "NetBSD" ]; then |
| 150 | if test -x "`which cksum 2>/dev/null`"; then |
| 151 | echo cksum -a `echo $1 | sed -e 's,sum,,'` |
| 152 | return |
| 153 | fi |
| 154 | fi |
| 155 | if [ $UNAME = "Darwin" ]; then |
| 156 | if test -x "`which openssl 2>/dev/null`"; then |
| 157 | echo openssl `echo $1 | sed -e 's,sum,,'` |
| 158 | return |
| 159 | fi |
| 160 | fi |
| 161 | fi |
Patrick Georgi | ae5ab60 | 2015-04-29 23:30:15 +0200 | [diff] [blame] | 162 | printf "${RED}ERROR:${red} Missing tool: Please install $1 (eg using your OS packaging system)${NC}\n" >&2 |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 163 | [ -z "$3" ] && exit 1 |
| 164 | false |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 167 | TAR=`searchtool tar` || exit $? |
| 168 | PATCH=`searchtool patch` || exit $? |
| 169 | MAKE=`searchtool make` || exit $? |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 170 | CMAKE=`searchtool cmake "cmake"` || exit $? |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 171 | SHA1SUM=`searchtool sha1sum` |
| 172 | SHA512SUM=`searchtool sha512sum` |
| 173 | CHECKSUM=$SHA1SUM |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 174 | |
Patrick Georgi | b706288 | 2015-02-24 10:52:14 +0100 | [diff] [blame] | 175 | searchtool m4 > /dev/null |
| 176 | searchtool bison > /dev/null |
| 177 | searchtool flex flex > /dev/null |
| 178 | searchtool g++ "Free Software Foundation" nofail > /dev/null || \ |
Patrick Georgi | 915c4fc | 2015-03-09 13:58:23 +0100 | [diff] [blame] | 179 | searchtool clang "clang version" > /dev/null |
| 180 | searchtool wget > /dev/null |
| 181 | searchtool bzip2 "bzip2," > /dev/null |
Patrick Georgi | 5fb2b5c | 2012-05-12 23:25:23 +0200 | [diff] [blame] | 182 | |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 183 | download() { |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 184 | PACKAGE=$1 |
| 185 | archive=$PACKAGE"_ARCHIVE" |
| 186 | archive="`eval echo '$'$archive`" |
| 187 | |
| 188 | FILE=`basename $archive` |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 189 | printf " * $FILE " |
| 190 | |
| 191 | test -f tarballs/$FILE && \ |
| 192 | (test -z "$CHECKSUM" || \ |
| 193 | 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,'`" ) && \ |
| 194 | printf "(cached)" || ( |
| 195 | printf "(downloading)" |
| 196 | rm -f tarballs/$FILE |
| 197 | cd tarballs |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 198 | wget --no-check-certificate -q $archive |
Stefan Reinauer | 8893548 | 2015-06-05 09:51:10 -0700 | [diff] [blame] | 199 | cd .. |
| 200 | test ! -f sum/$FILE.cksum && test -f tarballs/$FILE && \ |
| 201 | (test -z "$CHECKSUM" || $CHECKSUM tarballs/$FILE > sum/$FILE.cksum ) && \ |
| 202 | printf "(checksum created. ${RED}Note. Please upload sum/$FILE.cksum if the corresponding archive is upgraded.${NC})" |
| 203 | ) |
| 204 | test -f tarballs/$FILE || \ |
| 205 | printf "\n${RED}Failed to download $FILE.${NC}\n" |
| 206 | test -f tarballs/$FILE || exit 1 |
| 207 | printf "\n" |
| 208 | } |
| 209 | |
| 210 | unpack_and_patch() { |
| 211 | PACKAGE=$1 |
| 212 | archive=$PACKAGE"_ARCHIVE" |
| 213 | archive="`eval echo '$'$archive`" |
| 214 | dir=$PACKAGE"_DIR" |
| 215 | dir="`eval echo '$'${dir}`" |
| 216 | test -d ${dir} && test -f ${dir}/.unpack_success || ( |
| 217 | printf " * `basename $archive`\n" |
| 218 | FLAGS=zxf |
| 219 | suffix=`echo $archive | sed 's,.*\.,,'` |
| 220 | test "$suffix" = "gz" && FLAGS=zxf |
| 221 | test "$suffix" = "bz2" && FLAGS=jxf |
| 222 | test "$suffix" = "xz" && FLAGS="--xz -xf" |
| 223 | test "$suffix" = "lzma" && FLAGS="--lzma -xf" |
| 224 | $TAR $FLAGS tarballs/`basename $archive` |
| 225 | for patch in patches/${dir}_*.patch; do |
| 226 | test -r $patch || continue |
| 227 | printf " o `basename $patch`\n" |
| 228 | $PATCH -s -N -p0 < `echo $patch` || \ |
| 229 | printf "\n${RED}Failed $patch.${NC}\n" |
| 230 | done |
| 231 | touch ${dir}/.unpack_success |
| 232 | ) |
| 233 | } |
| 234 | |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 235 | wait_for_build() { |
| 236 | # $1: directory in which log file and failure marker are stored |
| 237 | cat > "$1/crossgcc-build.log" |
| 238 | test -r "$1/.failed" && printf "${RED}failed${NC}. Check $1/crossgcc-build.log.\n" || \ |
| 239 | printf "${green}ok${NC}\n" |
| 240 | test -r "$1/.failed" && exit 1 |
| 241 | true |
| 242 | } |
| 243 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 244 | cleanup() |
| 245 | { |
| 246 | printf "Cleaning up temporary files... " |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 247 | # GCC toolchain |
| 248 | rm -rf ${GMP_DIR} ${BUILDDIRPREFIX}-gmp |
| 249 | rm -rf ${MPFR_DIR} ${BUILDDIRPREFIX}-mpfr |
| 250 | rm -rf ${MPC_DIR} ${BUILDDIRPREFIX}-mpc |
| 251 | rm -rf ${LIBELF_DIR} ${BUILDDIRPREFIX}-libelf |
| 252 | rm -rf ${BINUTILS_DIR} ${BUILDDIRPREFIX}-binutils |
| 253 | rm -rf ${GCC_DIR} ${BUILDDIRPREFIX}-gcc |
| 254 | |
| 255 | # Other tools |
| 256 | rm -rf ${GDB_DIR} ${BUILDDIRPREFIX}-gdb |
| 257 | rm -rf ${EXPAT_DIR} ${BUILDDIRPREFIX}-expat |
| 258 | rm -rf ${PYTHON_DIR} ${BUILDDIRPREFIX}-python |
| 259 | rm -rf ${IASL_DIR} |
| 260 | |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 261 | # CLANG |
| 262 | rm -rf ${LLVM_DIR} ${CFE_DIR} ${CRT_DIR} ${CTE_DIR} ${BUILDDIR} |
| 263 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 264 | printf "${green}ok${NC}\n" |
| 265 | } |
| 266 | |
| 267 | myhelp() |
| 268 | { |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 269 | printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>] [-C] [-G] [-S]\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 270 | printf " $0 [-V|--version]\n" |
| 271 | printf " $0 [-h|--help]\n\n" |
| 272 | |
| 273 | printf "Options:\n" |
| 274 | printf " [-V|--version] print version number and exit\n" |
| 275 | printf " [-h|--help] print this help and exit\n" |
| 276 | printf " [-c|--clean] remove temporary files before build\n" |
| 277 | printf " [-t|--savetemps] don't remove temporary files after build\n" |
Patrick Georgi | c1a75b1 | 2011-11-04 21:37:14 +0100 | [diff] [blame] | 278 | printf " [-y|--ccache] Use ccache when building cross compiler\n" |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 279 | printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 280 | printf " [-C|--clang] build CLANG toolchain" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 281 | printf " [-p|--platform <platform>] target platform to build cross compiler for\n" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 282 | printf " (defaults to $TARGETARCH) *)\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 283 | printf " [-d|--directory <target dir>] target directory to install cross compiler to\n" |
| 284 | printf " (defaults to $TARGETDIR)\n\n" |
| 285 | printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n" |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 286 | printf " (for RPM builds, default unset)\n" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 287 | printf " [-G|--gdb] build GNU debugger *)\n" |
| 288 | printf " [-S|--scripting] build scripting support for GDB *)\n\n" |
| 289 | printf " *) option only available when building GCC toolchain (not with CLANG)\n\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | myversion() |
| 293 | { |
| 294 | # version tag is always printed, so just print the license here |
| 295 | |
| 296 | cat << EOF |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 297 | Copyright (C) 2008-2010 by coresystems GmbH |
Marc Jones | 2aac3f6 | 2011-08-08 16:07:50 -0600 | [diff] [blame] | 298 | Copyright (C) 2011 by Sage Electronic Engineering |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 299 | |
| 300 | This program is free software; you can redistribute it and/or modify |
| 301 | it under the terms of the GNU General Public License as published by |
| 302 | the Free Software Foundation; version 2 of the License. |
| 303 | |
| 304 | This program is distributed in the hope that it will be useful, |
| 305 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 306 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 307 | GNU General Public License for more details. |
| 308 | |
| 309 | EOF |
| 310 | } |
| 311 | |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 312 | printf "${blue}Welcome to the ${red}coreboot${blue} cross toolchain builder v$CROSSGCC_VERSION ($CROSSGCC_DATE)${NC}\n\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 313 | |
Patrick Georgi | 6bba29f | 2010-01-29 17:40:52 +0000 | [diff] [blame] | 314 | # Look if we have getopt. If not, build it. |
| 315 | export PATH=$PATH:. |
| 316 | getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c |
| 317 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 318 | # parse parameters.. try to find out whether we're running GNU getopt |
Peter Stuge | 09377b7 | 2011-08-21 06:24:55 +0200 | [diff] [blame] | 319 | getoptbrand="`getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,'`" |
| 320 | if [ "${getoptbrand}" = "getopt" ]; then |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 321 | # Detected GNU getopt that supports long options. |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 322 | args=`getopt -l version,help,clean,directory:,platform:,jobs:,destdir:,savetemps,skip-gdb,ccache,clang Vhcd:p:j:D:tGyC -- "$@"` |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 323 | eval set "$args" |
| 324 | else |
| 325 | # Detected non-GNU getopt |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 326 | args=`getopt Vhcd:p:j:D:tGyC $*` |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 327 | set -- $args |
| 328 | fi |
| 329 | |
| 330 | if [ $? != 0 ]; then |
| 331 | myhelp |
| 332 | exit 1 |
| 333 | fi |
| 334 | |
| 335 | while true ; do |
| 336 | case "$1" in |
| 337 | -V|--version) shift; myversion; exit 0;; |
| 338 | -h|--help) shift; myhelp; exit 0;; |
Patrick Georgi | 44af57a | 2013-12-19 22:06:22 +0100 | [diff] [blame] | 339 | -c|--clean) shift; clean=1;; |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 340 | -t|--savetemps) shift; SAVETEMPS=1;; |
| 341 | -d|--directory) shift; TARGETDIR="$1"; shift;; |
| 342 | -p|--platform) shift; TARGETARCH="$1"; shift;; |
| 343 | -D|--destdir) shift; DESTDIR="$1"; shift;; |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 344 | -j|--jobs) shift; JOBS="-j $1"; shift;; |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 345 | -C|--clang) shift; BUILDCLANG=1;; |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 346 | -G|--gdb) shift; SKIPGDB=0;; |
| 347 | -S|--scripting) shift; SKIPPYTHON=0;; |
Patrick Georgi | c1a75b1 | 2011-11-04 21:37:14 +0100 | [diff] [blame] | 348 | -y|--ccache) shift; USECCACHE=1;; |
Patrick Georgi | d2e0dd5 | 2013-06-09 08:05:45 +0200 | [diff] [blame] | 349 | --) shift; break;; |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 350 | -*) printf "Invalid option\n\n"; myhelp; exit 1;; |
Patrick Georgi | d2e0dd5 | 2013-06-09 08:05:45 +0200 | [diff] [blame] | 351 | *) break;; |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 352 | esac |
| 353 | done |
| 354 | |
Ronald G. Minnich | b460a66 | 2013-05-26 05:33:35 -0700 | [diff] [blame] | 355 | case "$TARGETARCH" in |
Stefan Reinauer | 24f9cb9 | 2015-03-13 22:50:22 +0100 | [diff] [blame] | 356 | x86_64-elf) ;; |
| 357 | x86_64*) TARGETARCH=x86_64-elf;; |
David Hubbard | 5b0420a | 2013-05-28 16:33:15 -0600 | [diff] [blame] | 358 | i386-elf) ;; |
| 359 | i386-mingw32) ;; |
Patrick Georgi | 9b7efa5 | 2015-03-08 09:20:36 +0100 | [diff] [blame] | 360 | mipsel-elf) ;; |
Patrick Georgi | f0bbc95 | 2015-03-07 10:57:25 +0100 | [diff] [blame] | 361 | riscv-elf) ;; |
Ronald G. Minnich | b460a66 | 2013-05-26 05:33:35 -0700 | [diff] [blame] | 362 | i386*) TARGETARCH=i386-elf;; |
Patrick Georgi | c888326 | 2013-09-19 10:57:58 +0200 | [diff] [blame] | 363 | arm*) TARGETARCH=armv7-a-eabi;; |
Stefan Reinauer | 0d2119d | 2013-07-10 14:27:56 -0700 | [diff] [blame] | 364 | aarch64*) TARGETARCH=aarch64-elf;; |
| 365 | *) printf "${red}WARNING: Unsupported architecture $TARGETARCH.${NC}\n\n"; ;; |
Ronald G. Minnich | b460a66 | 2013-05-26 05:33:35 -0700 | [diff] [blame] | 366 | esac |
| 367 | |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 368 | if [ "$BUILDCLANG" -eq 0 ]; then |
| 369 | echo "Target architecture is now $TARGETARCH" |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 370 | NAME="${TARGETARCH} cross" |
| 371 | PACKAGES="GMP MPFR MPC LIBELF BINUTILS GCC IASL" |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 372 | else |
| 373 | NAME=clang |
| 374 | PACKAGES="LLVM CFE CRT CTE" |
| 375 | fi |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 376 | |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 377 | BUILDDIRPREFIX=build-${TARGETARCH} |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 378 | BUILDDIR=$PWD/build-clang |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 379 | |
Patrick Georgi | 44af57a | 2013-12-19 22:06:22 +0100 | [diff] [blame] | 380 | if [ "$clean" = "1" ]; then |
| 381 | cleanup |
| 382 | fi |
| 383 | |
Peter Stuge | ceacd77 | 2011-06-09 04:54:16 +0200 | [diff] [blame] | 384 | if [ $SKIPGDB -eq 1 ]; then |
| 385 | printf "Will skip GDB ... ${green}ok${NC}\n" |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 386 | if [ $SKIPPYTHON -eq 0 ]; then |
| 387 | printf "Python scripting needs GDB ... disabling ... ${green}ok${NC}\n" |
| 388 | SKIPPYTHON=1 |
| 389 | fi |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 390 | else |
| 391 | PACKAGES="$PACKAGES GDB" |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 392 | fi |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 393 | if [ $SKIPPYTHON -eq 0 ]; then |
| 394 | PACKAGES="$PACKAGES EXPAT PYTHON" |
Peter Stuge | ceacd77 | 2011-06-09 04:54:16 +0200 | [diff] [blame] | 395 | fi |
| 396 | |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 397 | # coreboot does not like the GOLD linker |
| 398 | # USE_GOLD="--enable-gold" |
| 399 | USE_GOLD="" |
| 400 | GCC_OPTIONS="--enable-lto" |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 401 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 402 | printf "Downloading tar balls ... \n" |
| 403 | mkdir -p tarballs |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 404 | for P in $PACKAGES; do |
| 405 | download $P |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 406 | done |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 407 | printf "Downloaded tar balls ... ${green}ok${NC}\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 408 | |
| 409 | printf "Unpacking and patching ... \n" |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 410 | for P in $PACKAGES; do |
| 411 | unpack_and_patch $P |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 412 | done |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 413 | printf "Unpacked and patched ... ${green}ok${NC}\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 414 | |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 415 | if [[ "$PACKAGES" == *GCC* ]]; then |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 416 | CC=cc |
Stefan Reinauer | 0d2119d | 2013-07-10 14:27:56 -0700 | [diff] [blame] | 417 | if [ $UNAME = "Darwin" ]; then |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 418 | #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix" |
| 419 | |
| 420 | # generally the OS X compiler can create x64 binaries. |
| 421 | # Per default it generated i386 binaries in 10.5 and x64 |
| 422 | # binaries in 10.6 (even if the kernel is 32bit) |
| 423 | # For some weird reason, 10.5 autodetects an ABI=64 though |
| 424 | # so we're setting the ABI explicitly here. |
Zheng Bao | 04ceed6 | 2012-10-23 19:41:25 +0800 | [diff] [blame] | 425 | if [ `sysctl -n hw.optional.x86_64 2>/dev/null` -eq 1 ] 2>/dev/null; then |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 426 | OPTIONS="ABI=64" |
| 427 | else |
| 428 | OPTIONS="ABI=32" |
| 429 | fi |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 430 | |
Stefan Reinauer | 4266b92 | 2012-12-05 16:18:32 -0800 | [diff] [blame] | 431 | # In Xcode 4.5.2 the default compiler is clang. |
| 432 | # However, this compiler fails to compile gcc 4.7.x. As a |
| 433 | # workaround it's possible to compile gcc with llvm-gcc. |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 434 | if $CC -v 2>&1 | grep -q LLVM; then |
Stefan Reinauer | 4266b92 | 2012-12-05 16:18:32 -0800 | [diff] [blame] | 435 | CC=llvm-gcc |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 436 | fi |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 437 | fi |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 438 | fi # GCC |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 439 | |
Patrick Georgi | c1a75b1 | 2011-11-04 21:37:14 +0100 | [diff] [blame] | 440 | if [ "$USECCACHE" = 1 ]; then |
| 441 | CC="ccache $CC" |
| 442 | fi |
| 443 | |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 444 | mkdir -p ${BUILDDIRPREFIX}-gmp ${BUILDDIRPREFIX}-mpfr ${BUILDDIRPREFIX}-mpc ${BUILDDIRPREFIX}-libelf ${BUILDDIRPREFIX}-binutils \ |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 445 | ${BUILDDIRPREFIX}-gcc ${BUILDDIRPREFIX}-python ${BUILDDIRPREFIX}-expat ${BUILDDIRPREFIX}-gdb |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 446 | mkdir -p ${BUILDDIR} |
Stefan Reinauer | 16bd789 | 2012-12-07 23:57:01 +0100 | [diff] [blame] | 447 | |
| 448 | mkdir -p $DESTDIR$TARGETDIR/bin |
| 449 | export PATH=$DESTDIR$TARGETDIR/bin:$PATH |
| 450 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 451 | [[ "$PACKAGES" == *GMP* ]] && \ |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 452 | if [ -f ${BUILDDIRPREFIX}-gmp/.success ]; then |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 453 | printf "Skipping GMP as it is already built\n" |
| 454 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 455 | printf "Building GMP ${GMP_VERSION} ... " |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 456 | ( |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 457 | cd ${BUILDDIRPREFIX}-gmp |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 458 | rm -f .failed |
Patrick Georgi | 31bf37e | 2015-06-04 00:09:12 +0200 | [diff] [blame] | 459 | CC="$CC" CFLAGS="-Os" ../${GMP_DIR}/configure --disable-shared --enable-fat --prefix=$TARGETDIR $OPTIONS \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 460 | || touch .failed |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 461 | $MAKE $JOBS || touch .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 462 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 463 | |
| 464 | normalize_dirs |
| 465 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 466 | if [ ! -f .failed ]; then touch .success; fi |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 467 | ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-gmp" || exit 1 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 468 | |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 469 | # Now set CFLAGS to match GMP CFLAGS but strip out -pedantic |
| 470 | # as GCC 4.6.x fails if it's there. |
| 471 | HOSTCFLAGS=`grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2 |\ |
| 472 | sed s,-pedantic,,` |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 473 | fi |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 474 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 475 | [[ "$PACKAGES" == *MPFR* ]] && \ |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 476 | if [ -f ${BUILDDIRPREFIX}-mpfr/.success ]; then |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 477 | printf "Skipping MPFR as it is already built\n" |
| 478 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 479 | printf "Building MPFR ${MPFR_VERSION} ... " |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 480 | ( |
Stefan Reinauer | 0d2119d | 2013-07-10 14:27:56 -0700 | [diff] [blame] | 481 | test $UNAME = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL" |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 482 | cd ${BUILDDIRPREFIX}-mpfr |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 483 | rm -f .failed |
Patrick Georgi | 643c9e8 | 2011-11-04 21:30:49 +0100 | [diff] [blame] | 484 | CC="$CC" ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 485 | --infodir=$TARGETDIR/info \ |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 486 | --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \ |
| 487 | touch .failed |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 488 | $MAKE $JOBS || touch .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 489 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 490 | |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 491 | normalize_dirs |
| 492 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 493 | # work around build problem of libgmp.la |
| 494 | if [ "$DESTDIR" != "" ]; then |
| 495 | perl -pi -e "s,$DESTDIR,," $DESTDIR$TARGETDIR/libgmp.la |
| 496 | fi |
| 497 | |
| 498 | if [ ! -f .failed ]; then touch .success; fi |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 499 | ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-mpfr" || exit 1 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 500 | fi |
| 501 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 502 | [[ "$PACKAGES" == *MPC* ]] && \ |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 503 | if [ -f ${BUILDDIRPREFIX}-mpc/.success ]; then |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 504 | printf "Skipping MPC as it is already built\n" |
| 505 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 506 | printf "Building MPC ${MPC_VERSION} ... " |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 507 | ( |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 508 | cd ${BUILDDIRPREFIX}-mpc |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 509 | rm -f .failed |
Patrick Georgi | 643c9e8 | 2011-11-04 21:30:49 +0100 | [diff] [blame] | 510 | CC="$CC" ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \ |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 511 | --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \ |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 512 | --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \ |
| 513 | touch .failed |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 514 | $MAKE $JOBS || touch .failed |
| 515 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 516 | |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 517 | normalize_dirs |
| 518 | |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 519 | if [ ! -f .failed ]; then touch .success; fi |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 520 | ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-mpc" || exit 1 |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 521 | fi |
| 522 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 523 | [[ "$PACKAGES" == *LIBELF* ]] && \ |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 524 | if [ -f ${BUILDDIRPREFIX}-libelf/.success ]; then |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 525 | printf "Skipping libelf as it is already built\n" |
| 526 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 527 | printf "Building libelf ${LIBELF_VERSION} ... " |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 528 | ( |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 529 | cd ${BUILDDIRPREFIX}-libelf |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 530 | rm -f .failed |
| 531 | echo "$HOSTCFLAGS" |
Patrick Georgi | 643c9e8 | 2011-11-04 21:30:49 +0100 | [diff] [blame] | 532 | CC="$CC" CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no \ |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 533 | ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \ |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 534 | --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed |
| 535 | $MAKE $JOBS || touch .failed |
Scott Duplichan | 4270a97 | 2014-12-12 20:21:40 -0600 | [diff] [blame] | 536 | $MAKE install prefix=$DESTDIR$TARGETDIR || touch .failed |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 537 | |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 538 | normalize_dirs |
| 539 | |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 540 | if [ ! -f .failed ]; then touch .success; fi |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 541 | ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-libelf" || exit 1 |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 542 | fi |
| 543 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 544 | [[ "$PACKAGES" == *BINUTILS* ]] && \ |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 545 | if [ -f ${BUILDDIRPREFIX}-binutils/.success ]; then |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 546 | printf "Skipping binutils as it is already built\n" |
| 547 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 548 | printf "Building binutils ${BINUTILS_VERSION} ... " |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 549 | ( |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 550 | # What a pain: binutils don't come with configure |
| 551 | # script anymore. Create it: |
| 552 | cd binutils-${BINUTILS_VERSION}/ |
| 553 | autoconf |
| 554 | cd .. |
| 555 | # Now build binutils |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 556 | cd ${BUILDDIRPREFIX}-binutils |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 557 | rm -f .failed |
Patrick Georgi | 643c9e8 | 2011-11-04 21:30:49 +0100 | [diff] [blame] | 558 | CC="$CC" ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR \ |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 559 | --target=${TARGETARCH} --disable-werror --disable-nls \ |
| 560 | $USE_GOLD CFLAGS="$HOSTCFLAGS" || touch .failed |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 561 | $MAKE $JOBS || touch .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 562 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 563 | if [ ! -f .failed ]; then touch .success; fi |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 564 | ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-binutils" || exit 1 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 565 | fi |
| 566 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 567 | [[ "$PACKAGES" == *GCC* ]] && \ |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 568 | if [ -f ${BUILDDIRPREFIX}-gcc/.success ]; then |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 569 | printf "Skipping GCC as it is already built\n" |
| 570 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 571 | printf "Building GCC ${GCC_VERSION} ... " |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 572 | ( |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 573 | # Even worse than binutils: GCC does not come with configure |
| 574 | # script anymore, but also enforces an obsolete autoconf version |
| 575 | # to create it. This is a poster child of how autotools help make |
| 576 | # software portable. |
| 577 | cd gcc-${GCC_VERSION} |
| 578 | sed '/dnl Ensure exactly this Autoconf version is used/d' \ |
| 579 | config/override.m4 > config/override.m4.new |
| 580 | autoconf_version=`autoconf -V | grep "autoconf" | tr ' ' '\n' | tail -1` |
| 581 | sed "s/${GCC_AUTOCONF_VERSION}/${autoconf_version}/g" \ |
| 582 | config/override.m4.new > config/override.m4 |
| 583 | autoconf |
| 584 | cd .. |
| 585 | # Now, finally, we can build gcc: |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 586 | cd ${BUILDDIRPREFIX}-gcc |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 587 | rm -f .failed |
| 588 | # GCC does not honour HOSTCFLAGS at all. CFLAGS are used for |
| 589 | # both target and host object files. This is pretty misdesigned. |
| 590 | # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET |
| 591 | # but it does not seem to work properly. At least the host library |
| 592 | # libiberty is not compiled with CFLAGS_FOR_BUILD. |
Stefan Reinauer | 9491b4d | 2011-10-11 22:37:59 -0700 | [diff] [blame] | 593 | CC="$CC" CFLAGS_FOR_TARGET="-O2" CFLAGS="$HOSTCFLAGS" \ |
| 594 | CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 595 | --prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \ |
Stefan Reinauer | 6ade161 | 2010-01-16 16:44:20 +0000 | [diff] [blame] | 596 | --target=${TARGETARCH} --disable-werror --disable-shared \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 597 | --disable-libssp --disable-bootstrap --disable-nls \ |
Patrick Georgi | 969cd93 | 2012-12-07 13:13:53 +0100 | [diff] [blame] | 598 | --disable-libquadmath --without-headers \ |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 599 | $GCC_OPTIONS --enable-languages="c" $USE_GOLD \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 600 | --with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \ |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 601 | --with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \ |
| 602 | --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION $CROSSGCC_DATE" \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 603 | || touch .failed |
Patrick Georgi | 969cd93 | 2012-12-07 13:13:53 +0100 | [diff] [blame] | 604 | $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-gcc || touch .failed |
| 605 | $MAKE install-gcc DESTDIR=$DESTDIR || touch .failed |
| 606 | |
| 607 | if [ "`echo $TARGETARCH | grep -c -- -mingw32`" -eq 0 ]; then |
| 608 | $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" all-target-libgcc || touch .failed |
| 609 | $MAKE install-target-libgcc DESTDIR=$DESTDIR || touch .failed |
| 610 | fi |
| 611 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 612 | if [ ! -f .failed ]; then touch .success; fi |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 613 | ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-gcc" || exit 1 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 614 | fi |
| 615 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 616 | [[ "$PACKAGES" == *EXPAT* ]] && \ |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 617 | if [ -f ${BUILDDIRPREFIX}-expat/.success ]; then |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 618 | printf "Skipping Expat as it is already built\n" |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 619 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 620 | printf "Building Expat ${EXPAT_VERSION} ... " |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 621 | ( |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 622 | cd ${BUILDDIRPREFIX}-expat |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 623 | rm -f .failed |
Patrick Georgi | 643c9e8 | 2011-11-04 21:30:49 +0100 | [diff] [blame] | 624 | CC="$CC" CFLAGS="$HOSTCFLAGS" ../${EXPAT_DIR}/configure --disable-shared \ |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 625 | --prefix=$TARGETDIR --target=${TARGETARCH} || touch .failed |
| 626 | $MAKE || touch .failed |
| 627 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 628 | |
| 629 | normalize_dirs |
| 630 | |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 631 | if [ ! -f .failed ]; then touch .success; fi |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 632 | ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-expat" || exit 1 |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 633 | fi |
| 634 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 635 | [[ "$PACKAGES" == *PYTHON* ]] && \ |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 636 | if [ -f ${BUILDDIRPREFIX}-python/.success ]; then |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 637 | printf "Skipping Python as it is already built\n" |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 638 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 639 | printf "Building Python ${PYTHON_VERSION} ... " |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 640 | ( |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 641 | cd ${BUILDDIRPREFIX}-python |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 642 | rm -f .failed |
Patrick Georgi | 643c9e8 | 2011-11-04 21:30:49 +0100 | [diff] [blame] | 643 | CC="$CC" CFLAGS="$HOSTCFLAGS" ../${PYTHON_DIR}/configure --prefix=$TARGETDIR \ |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 644 | --target=${TARGETARCH} || touch .failed |
| 645 | $MAKE $JOBS || touch .failed |
| 646 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
Patrick Georgi | 198d23c | 2012-12-08 08:02:44 +0100 | [diff] [blame] | 647 | |
| 648 | normalize_dirs |
| 649 | |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 650 | if [ ! -f .failed ]; then touch .success; fi |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 651 | ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-python" || exit 1 |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 652 | fi |
| 653 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 654 | [[ "$PACKAGES" == *GDB* ]] && \ |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 655 | if [ -f ${BUILDDIRPREFIX}-gdb/.success ]; then |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 656 | printf "Skipping GDB as it is already built\n" |
| 657 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 658 | printf "Building GDB ${GDB_VERSION} ... " |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 659 | ( |
Patrick Georgi | 3af0aa2 | 2013-09-17 20:59:52 +0200 | [diff] [blame] | 660 | cd ${BUILDDIRPREFIX}-gdb |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 661 | export PYTHONHOME=$DESTDIR$TARGETDIR |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 662 | rm -f .failed |
Idwer Vollering | 1b7c959 | 2015-04-09 15:34:07 +0200 | [diff] [blame] | 663 | if [ $(uname) != "FreeBSD" -a $(uname) != "NetBSD" ]; then |
| 664 | LIBDL="-ldl" |
| 665 | fi |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 666 | LDFLAGS="-Wl,-rpath,\$\$ORIGIN/../lib/ -L$DESTDIR$TARGETDIR/lib \ |
Idwer Vollering | 1b7c959 | 2015-04-09 15:34:07 +0200 | [diff] [blame] | 667 | -lpthread $LIBDL -lutil" \ |
Patrick Georgi | 643c9e8 | 2011-11-04 21:30:49 +0100 | [diff] [blame] | 668 | CC="$CC" CFLAGS="$HOSTCFLAGS -I$DESTDIR$TARGETDIR/include" \ |
Stefan Reinauer | 2c3cd12 | 2011-11-01 21:43:50 +0100 | [diff] [blame] | 669 | ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR \ |
| 670 | --target=${TARGETARCH} --disable-werror --disable-nls |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 671 | $MAKE $JOBS || touch .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 672 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 673 | if [ ! -f .failed ]; then touch .success; fi |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 674 | ) 2>&1 | wait_for_build "${BUILDDIRPREFIX}-gdb" || exit 1 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 675 | fi |
| 676 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 677 | [[ "$PACKAGES" == *IASL* ]] && \ |
Patrick Georgi | 6e61ad3 | 2012-05-12 23:19:30 +0200 | [diff] [blame] | 678 | if [ -f $IASL_DIR/source/compiler/.success ]; then |
Marc Jones | 2aac3f6 | 2011-08-08 16:07:50 -0600 | [diff] [blame] | 679 | printf "Skipping IASL as it is already built\n" |
| 680 | else |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 681 | printf "Building IASL ${IASL_VERSION} ... " |
Marc Jones | 2aac3f6 | 2011-08-08 16:07:50 -0600 | [diff] [blame] | 682 | ( |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 683 | RDIR=$IASL_DIR/source/compiler |
Idwer Vollering | 6b11c8b | 2012-11-15 21:14:36 +0100 | [diff] [blame] | 684 | cd $IASL_DIR/generate/unix |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 685 | rm -f $RDIR/.failed |
Marc Jones | 2aac3f6 | 2011-08-08 16:07:50 -0600 | [diff] [blame] | 686 | CFLAGS="$HOSTCFLAGS" |
Stefan Reinauer | 0d2119d | 2013-07-10 14:27:56 -0700 | [diff] [blame] | 687 | HOST="_LINUX" |
| 688 | test $UNAME = "Darwin" && HOST="_APPLE" |
| 689 | test $UNAME = "FreeBSD" && HOST="_FreeBSD" |
| 690 | test $UNAME = "Cygwin" && HOST="_CYGWIN" |
Patrick Georgi | 74c0642 | 2015-03-25 18:40:13 +0100 | [diff] [blame] | 691 | HOST="$HOST" OPT_CFLAGS="-O -D_FORTIFY_SOURCE=2" CFLAGS="$CFLAGS" $MAKE CC="$CC" iasl || touch $RDIR/.failed |
| 692 | rm -f $DESTDIR$TARGETDIR/bin/iasl || touch $RDIR/.failed |
| 693 | cp bin/iasl $DESTDIR$TARGETDIR/bin || touch $RDIR/.failed |
| 694 | if [ ! -f $RDIR/.failed ]; then touch $RDIR/.success; fi |
| 695 | ) 2>&1 | wait_for_build "$IASL_DIR/source/compiler" || exit 1 |
Marc Jones | 2aac3f6 | 2011-08-08 16:07:50 -0600 | [diff] [blame] | 696 | fi |
| 697 | |
Stefan Reinauer | 14ce213 | 2015-06-05 13:01:13 -0700 | [diff] [blame^] | 698 | [[ "$PACKAGES" == *CLANG* ]] && \ |
| 699 | if [ -f ${BUILDDIR}/.success ]; then |
| 700 | printf "Skipping CLANG as it is already built\n" |
| 701 | else |
| 702 | printf "Building CLANG ${CLANG_VERSION} ... " |
| 703 | ( |
| 704 | ln -sf $PWD/$CFE_DIR $LLVM_DIR/tools/clang |
| 705 | ln -sf $PWD/$CTE_DIR $LLVM_DIR/tools/clang/tools/extra |
| 706 | ln -sf $PWD/$CRT_DIR $LLVM_DIR/projects/compiler-rt |
| 707 | |
| 708 | cd ${BUILDDIR} |
| 709 | |
| 710 | $CMAKE -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$DESTDIR$TARGETDIR \ |
| 711 | -DCMAKE_BUILD_TYPE=Release ../$LLVM_DIR || touch .failed |
| 712 | $MAKE $JOBS || touch .failed |
| 713 | $MAKE install || touch .failed |
| 714 | |
| 715 | cd - |
| 716 | |
| 717 | cp -a $CFE_DIR/tools/scan-build/* $DESTDIR$TARGETDIR/bin |
| 718 | cp -a $CFE_DIR/tools/scan-view/* $DESTDIR$TARGETDIR/bin |
| 719 | |
| 720 | if [ ! -f .failed ]; then touch .success; fi |
| 721 | ) 2>&1 | wait_for_build "${BUILDDIR}" || exit 1 |
| 722 | fi |
| 723 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 724 | # Adding git information of current tree to target directory |
| 725 | # for reproducibility |
Patrick Georgi | 5602f2c | 2015-03-28 15:48:47 +0100 | [diff] [blame] | 726 | PROGNAME=`basename "$0"` |
| 727 | rm -f "$DESTDIR$TARGETDIR/$PROGNAME".commit.* |
| 728 | cp "$PROGNAME" $DESTDIR$TARGETDIR/"$PROGNAME.commit.`git describe`" |
Zheng Bao | 30b895f | 2013-02-06 18:04:40 +0800 | [diff] [blame] | 729 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 730 | if [ $SAVETEMPS -eq 0 ]; then |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 731 | cleanup |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 732 | else |
| 733 | printf "Leaving temporary files around... ${green}ok${NC}\n" |
| 734 | fi |
| 735 | |
Stefan Reinauer | 699ac27 | 2015-06-05 12:43:28 -0700 | [diff] [blame] | 736 | printf "\n${green}You can now run your $NAME toolchain from $TARGETDIR.${NC}\n" |