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