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