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