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