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