Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 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 | # |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; version 2 of the License. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program; if not, write to the Free Software |
| 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
| 19 | # |
| 20 | |
Marc Jones | 3693266 | 2010-12-03 00:45:56 +0000 | [diff] [blame^] | 21 | CROSSGCC_DATE="November 16th, 2010" |
| 22 | CROSSGCC_VERSION="1.02" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 23 | |
| 24 | # default settings |
| 25 | TARGETDIR=`pwd`/xgcc |
| 26 | TARGETARCH=i386-elf |
| 27 | DESTDIR= |
| 28 | |
| 29 | # version numbers |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 30 | GMP_VERSION=5.0.1 |
Marc Jones | 3693266 | 2010-12-03 00:45:56 +0000 | [diff] [blame^] | 31 | MPFR_VERSION=3.0.0 |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 32 | MPC_VERSION=0.8.2 |
| 33 | LIBELF_VERSION=0.8.13 |
Marc Jones | 3693266 | 2010-12-03 00:45:56 +0000 | [diff] [blame^] | 34 | GCC_VERSION=4.5.1 |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 35 | BINUTILS_VERSION=2.20.1 |
Marc Jones | 3693266 | 2010-12-03 00:45:56 +0000 | [diff] [blame^] | 36 | GDB_VERSION=7.2 |
| 37 | W32API_VERSION=3.15 |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 38 | MINGWRT_VERSION=3.18 |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 39 | |
| 40 | # archive locations |
| 41 | GMP_ARCHIVE="ftp://ftp.gmplib.org/pub/gmp-${GMP_VERSION}/gmp-${GMP_VERSION}.tar.bz2" |
Peter Stuge | 85e6870 | 2009-12-13 13:39:01 +0000 | [diff] [blame] | 42 | MPFR_ARCHIVE="http://www.mpfr.org/mpfr-${MPFR_VERSION}/mpfr-${MPFR_VERSION}.tar.bz2" |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 43 | MPC_ARCHIVE="http://www.multiprecision.org/mpc/download/mpc-${MPC_VERSION}.tar.gz" |
| 44 | LIBELF_ARCHIVE="http://www.mr511.de/software/libelf-${LIBELF_VERSION}.tar.gz" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 45 | GCC_ARCHIVE="ftp://ftp.gwdg.de/pub/gnu/ftp/gnu/gcc/gcc-${GCC_VERSION}/gcc-core-${GCC_VERSION}.tar.bz2" |
| 46 | BINUTILS_ARCHIVE="http://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.bz2" |
| 47 | GDB_ARCHIVE="http://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.bz2" |
Marc Jones | 3693266 | 2010-12-03 00:45:56 +0000 | [diff] [blame^] | 48 | W32API_ARCHIVE="http://downloads.sourceforge.net/project/mingw/MinGW/BaseSystem/RuntimeLibrary/Win32-API/w32api-${W32API_VERSION}/w32api-${W32API_VERSION}-mingw32-src.tar.gz" |
| 49 | MINGWRT_ARCHIVE="http://downloads.sourceforge.net/project/mingw/MinGW/BaseSystem/RuntimeLibrary/MinGW-RT/mingwrt-${MINGWRT_VERSION}/mingwrt-${MINGWRT_VERSION}-mingw32-src.tar.gz" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 50 | |
| 51 | GMP_DIR="gmp-${GMP_VERSION}" |
| 52 | MPFR_DIR="mpfr-${MPFR_VERSION}" |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 53 | MPC_DIR="mpc-${MPC_VERSION}" |
| 54 | LIBELF_DIR="libelf-${LIBELF_VERSION}" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 55 | GCC_DIR="gcc-${GCC_VERSION}" |
| 56 | BINUTILS_DIR="binutils-${BINUTILS_VERSION}" |
| 57 | GDB_DIR="gdb-${GDB_VERSION}" |
Stefan Reinauer | 6ade161 | 2010-01-16 16:44:20 +0000 | [diff] [blame] | 58 | W32API_DIR="w32api-${W32API_VERSION}-mingw32" |
| 59 | MINGWRT_DIR="mingwrt-${MINGWRT_VERSION}-mingw32" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 60 | |
| 61 | SAVETEMPS=0 |
| 62 | |
| 63 | red='\e[0;31m' |
| 64 | RED='\e[1;31m' |
| 65 | green='\e[0;32m' |
| 66 | GREEN='\e[1;32m' |
| 67 | blue='\e[0;34m' |
| 68 | BLUE='\e[1;34m' |
| 69 | cyan='\e[0;36m' |
| 70 | CYAN='\e[1;36m' |
| 71 | NC='\e[0m' # No Color |
| 72 | |
| 73 | searchgnu() |
| 74 | { |
| 75 | # $1 short name |
| 76 | # result: GNU version of that tool on stdout |
| 77 | # or no output if no GNU version was found |
| 78 | for i in "$1" "g$1" "gnu$1"; do |
| 79 | if test -x "`which $i 2>/dev/null`"; then |
| 80 | if test `$i --version 2>/dev/null |grep -c GNU` -gt 0; then |
| 81 | echo $i |
| 82 | return |
| 83 | fi |
| 84 | fi |
| 85 | done |
| 86 | printf "${RED}ERROR:${red} Missing toolchain: $1${NC}\n" >&2 |
| 87 | exit 1 |
| 88 | } |
| 89 | |
| 90 | TAR=`searchgnu tar` |
| 91 | PATCH=`searchgnu patch` |
| 92 | MAKE=`searchgnu make` |
| 93 | |
| 94 | cleanup() |
| 95 | { |
| 96 | printf "Cleaning up temporary files... " |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 97 | rm -rf build-* combined gcc-* gmp-* mpfr-* mpc-* libelf-* binutils-* gdb-* w32api-* mingwrt-* |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 98 | printf "${green}ok${NC}\n" |
| 99 | } |
| 100 | |
| 101 | myhelp() |
| 102 | { |
| 103 | printf "Usage: $0 [-V] [-c] [-p <platform>] [-d <target directory>] [-D <dest dir>]\n" |
| 104 | printf " $0 [-V|--version]\n" |
| 105 | printf " $0 [-h|--help]\n\n" |
| 106 | |
| 107 | printf "Options:\n" |
| 108 | printf " [-V|--version] print version number and exit\n" |
| 109 | printf " [-h|--help] print this help and exit\n" |
| 110 | printf " [-c|--clean] remove temporary files before build\n" |
| 111 | printf " [-t|--savetemps] don't remove temporary files after build\n" |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 112 | printf " [-j|--jobs <num>] run <num> jobs in parallel in make\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 113 | printf " [-p|--platform <platform>] target platform to build cross compiler for\n" |
| 114 | printf " (defaults to $TARGETARCH)\n" |
| 115 | printf " [-d|--directory <target dir>] target directory to install cross compiler to\n" |
| 116 | printf " (defaults to $TARGETDIR)\n\n" |
| 117 | printf " [-D|--destdir <dest dir>] destination directory to install cross compiler to\n" |
| 118 | printf " (for RPM builds, default unset)\n\n" |
| 119 | } |
| 120 | |
| 121 | myversion() |
| 122 | { |
| 123 | # version tag is always printed, so just print the license here |
| 124 | |
| 125 | cat << EOF |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 126 | Copyright (C) 2008-2010 by coresystems GmbH |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 127 | |
| 128 | This program is free software; you can redistribute it and/or modify |
| 129 | it under the terms of the GNU General Public License as published by |
| 130 | the Free Software Foundation; version 2 of the License. |
| 131 | |
| 132 | This program is distributed in the hope that it will be useful, |
| 133 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 134 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 135 | GNU General Public License for more details. |
| 136 | |
| 137 | EOF |
| 138 | } |
| 139 | |
| 140 | printf "${blue}Welcome to the ${red}coresystems${blue} cross toolchain builder v$CROSSGCC_VERSION ($CROSSGCC_DATE)${NC}\n\n" |
| 141 | |
Patrick Georgi | 6bba29f | 2010-01-29 17:40:52 +0000 | [diff] [blame] | 142 | # Look if we have getopt. If not, build it. |
| 143 | export PATH=$PATH:. |
| 144 | getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c |
| 145 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 146 | # parse parameters.. try to find out whether we're running GNU getopt |
| 147 | getoptbrand="`getopt -V`" |
| 148 | if [ "${getoptbrand:0:6}" == "getopt" ]; then |
| 149 | # Detected GNU getopt that supports long options. |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 150 | args=`getopt -l version,help,clean,directory:,platform:,jobs:,destdir:,savetemps Vhcd:p:j:D:t -- "$@"` |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 151 | eval set "$args" |
| 152 | else |
| 153 | # Detected non-GNU getopt |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 154 | args=`getopt Vhcd:p:j:D:t $*` |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 155 | set -- $args |
| 156 | fi |
| 157 | |
| 158 | if [ $? != 0 ]; then |
| 159 | myhelp |
| 160 | exit 1 |
| 161 | fi |
| 162 | |
| 163 | while true ; do |
| 164 | case "$1" in |
| 165 | -V|--version) shift; myversion; exit 0;; |
| 166 | -h|--help) shift; myhelp; exit 0;; |
| 167 | -c|--clean) shift; cleanup;; |
| 168 | -t|--savetemps) shift; SAVETEMPS=1;; |
| 169 | -d|--directory) shift; TARGETDIR="$1"; shift;; |
| 170 | -p|--platform) shift; TARGETARCH="$1"; shift;; |
| 171 | -D|--destdir) shift; DESTDIR="$1"; shift;; |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 172 | -j|--jobs) shift; JOBS="-j $1"; shift;; |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 173 | --) shift; break;; |
| 174 | -*) printf "Invalid option\n\n"; myhelp; exit 1;; |
| 175 | *) break;; |
| 176 | esac |
| 177 | done |
| 178 | |
Stefan Reinauer | 6ade161 | 2010-01-16 16:44:20 +0000 | [diff] [blame] | 179 | MINGW_ARCHIVES="" |
| 180 | if [ "$TARGETARCH" = "i386-mingw32" ]; then |
| 181 | MINGW_ARCHIVES="$W32API_ARCHIVE $MINGWRT_ARCHIVE" |
| 182 | fi |
| 183 | |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 184 | if [ ${GCC_VERSION} == "4.5.0" -o ${GCC_VERSION} == "4.6.0" ]; then |
| 185 | # coreboot does not like the GOLD linker |
| 186 | # USE_GOLD="--enable-gold" |
| 187 | USE_GOLD="" |
| 188 | GCC_OPTIONS="--enable-lto" |
| 189 | fi |
| 190 | |
| 191 | if [ ${GCC_VERSION} == "4.6.0" ]; then |
| 192 | if [ ! -r tarballs/gcc-core-${GCC_VERSION}.tar.bz2 ]; then |
| 193 | printf "Pre-Release GCC ${GCC_VERSION}, checking out subversion trunk\n" |
| 194 | mkdir -p tarballs/.tmp |
| 195 | cd tarballs/.tmp |
| 196 | rm -rf gcc-${GCC_VERSION} |
| 197 | svn export -q svn://gcc.gnu.org/svn/gcc/trunk gcc-${GCC_VERSION} |
| 198 | printf "done. Now creating tar ball...\n" |
| 199 | tar cjf ../gcc-core-${GCC_VERSION}.tar.bz2 gcc-${GCC_VERSION} |
| 200 | printf "done. Now cleaning up...\n" |
| 201 | cd .. |
| 202 | rm -rf .tmp |
| 203 | cd .. |
| 204 | printf "done.\n" |
| 205 | fi |
| 206 | fi |
| 207 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 208 | printf "Downloading tar balls ... \n" |
| 209 | mkdir -p tarballs |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 210 | for ARCHIVE in $GMP_ARCHIVE $MPFR_ARCHIVE $MPC_ARCHIVE $LIBELF_ARCHIVE $GCC_ARCHIVE $BINUTILS_ARCHIVE $GDB_ARCHIVE $MINGW_ARCHIVES; do |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 211 | FILE=`basename $ARCHIVE` |
| 212 | printf " * $FILE " |
| 213 | test -f tarballs/$FILE && printf "(cached)" || ( |
| 214 | printf "(downloading)" |
| 215 | cd tarballs |
| 216 | wget -q $ARCHIVE |
| 217 | ) |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 218 | test -f tarballs/$FILE || printf "\n${RED}Failed to download $FILE.${red}\n" |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 219 | test -f tarballs/$FILE || exit 1 |
| 220 | printf "\n" |
| 221 | done |
| 222 | printf "Downloaded tar balls ... " |
| 223 | printf "${green}ok${NC}\n" |
| 224 | |
Stefan Reinauer | 6ade161 | 2010-01-16 16:44:20 +0000 | [diff] [blame] | 225 | MINGW_PACKAGES="" |
| 226 | if [ "$TARGETARCH" = "i386-mingw32" ]; then |
| 227 | MINGW_PACKAGES="W32API MINGWRT" |
| 228 | fi |
| 229 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 230 | printf "Unpacking and patching ... \n" |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 231 | for PACKAGE in GMP MPFR MPC LIBELF GCC BINUTILS GDB $MINGW_PACKAGES; do |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 232 | archive=$PACKAGE"_ARCHIVE" |
| 233 | archive=${!archive} |
| 234 | dir=$PACKAGE"_DIR" |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 235 | test -d ${!dir} || ( |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 236 | printf " * `basename $archive`\n" |
| 237 | FLAGS=zxf |
| 238 | test ${archive:${#archive}-2:2} = "gz" && FLAGS=zxf |
| 239 | test ${archive:${#archive}-3:3} = "bz2" && FLAGS=jxf |
| 240 | $TAR $FLAGS tarballs/`basename $archive` |
Stefan Reinauer | 6ade161 | 2010-01-16 16:44:20 +0000 | [diff] [blame] | 241 | for patch in patches/${!dir}_*.patch; do |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 242 | test -r $patch || continue |
| 243 | printf " o `basename $patch`\n" |
Patrick Georgi | 6bba29f | 2010-01-29 17:40:52 +0000 | [diff] [blame] | 244 | $PATCH -s -N -p0 < `echo $patch` |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 245 | done |
| 246 | ) |
| 247 | done |
| 248 | printf "Unpacked and patched ... " |
| 249 | printf "${green}ok${NC}\n" |
| 250 | |
Stefan Reinauer | 6ade161 | 2010-01-16 16:44:20 +0000 | [diff] [blame] | 251 | if [ "$TARGETARCH" = "i386-mingw32" ]; then |
| 252 | mkdir -p $TARGETDIR/i386-mingw32/sys-include |
| 253 | mv $MINGWRT_DIR/include/* $W32API_DIR/include/* $TARGETDIR/i386-mingw32/sys-include |
| 254 | fi |
| 255 | |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 256 | if [ `uname` = "Darwin" ]; then |
| 257 | #GCC_OPTIONS="$GCC_OPTIONS --enable-threads=posix" |
| 258 | |
| 259 | # generally the OS X compiler can create x64 binaries. |
| 260 | # Per default it generated i386 binaries in 10.5 and x64 |
| 261 | # binaries in 10.6 (even if the kernel is 32bit) |
| 262 | # For some weird reason, 10.5 autodetects an ABI=64 though |
| 263 | # so we're setting the ABI explicitly here. |
| 264 | if [ `sysctl -n hw.optional.x86_64` -eq 1 ]; then |
| 265 | OPTIONS="ABI=64" |
| 266 | else |
| 267 | OPTIONS="ABI=32" |
| 268 | fi |
| 269 | # old check: |
| 270 | #OPTIONS="ABI=32" |
| 271 | #touch .architecture_check.c |
| 272 | #gcc .architecture_check.c -c -o .architecture_check.o |
| 273 | #ARCH=`file .architecture_check.o |cut -f5 -d\ ` |
| 274 | #test "$ARCH" = "x86_64" && OPTIONS="ABI=64" |
| 275 | #rm .architecture_check.c .architecture_check.o |
| 276 | fi |
| 277 | |
| 278 | mkdir -p build-gmp build-mpfr build-mpc build-libelf build-binutils build-gcc build-gdb |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 279 | if [ -f build-gmp/.success ]; then |
| 280 | printf "Skipping GMP as it is already built\n" |
| 281 | else |
| 282 | printf "Building GMP ${GMP_VERSION} ... " |
| 283 | ( |
| 284 | cd build-gmp |
| 285 | rm -f .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 286 | ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \ |
| 287 | || touch .failed |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 288 | $MAKE $JOBS || touch .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 289 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 290 | if [ ! -f .failed ]; then touch .success; fi |
| 291 | ) &> build-gmp/crossgcc-build.log |
| 292 | test -r build-gmp/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n" |
| 293 | test -r build-gmp/.failed && exit 1 |
| 294 | fi |
| 295 | |
| 296 | #if [ "$DESTDIR" != "" -a ! -x $TARGETDIR ]; then |
| 297 | # # create compat link |
| 298 | # ln -s $DESTDIR$TARGETDIR $TARGETDIR |
| 299 | #fi |
| 300 | |
| 301 | # Now set CFLAGS to match GMP CFLAGS. |
| 302 | HOSTCFLAGS=`grep __GMP_CFLAGS $DESTDIR$TARGETDIR/include/gmp.h |cut -d\" -f2` |
| 303 | |
| 304 | if [ -f build-mpfr/.success ]; then |
| 305 | printf "Skipping MPFR as it is already built\n" |
| 306 | else |
| 307 | printf "Building MPFR ${MPFR_VERSION} ... " |
| 308 | ( |
| 309 | test `uname` = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL" |
| 310 | cd build-mpfr |
| 311 | rm -f .failed |
| 312 | ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \ |
| 313 | --infodir=$TARGETDIR/info \ |
| 314 | --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || touch .failed |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 315 | $MAKE $JOBS || touch .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 316 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 317 | |
| 318 | # work around build problem of libgmp.la |
| 319 | if [ "$DESTDIR" != "" ]; then |
| 320 | perl -pi -e "s,$DESTDIR,," $DESTDIR$TARGETDIR/libgmp.la |
| 321 | fi |
| 322 | |
| 323 | if [ ! -f .failed ]; then touch .success; fi |
| 324 | ) &> build-mpfr/crossgcc-build.log |
| 325 | test -r build-mpfr/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n" |
| 326 | test -r build-mpfr/.failed && exit 1 |
| 327 | fi |
| 328 | |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 329 | if [ -f build-mpc/.success ]; then |
| 330 | printf "Skipping MPC as it is already built\n" |
| 331 | else |
| 332 | printf "Building MPC ${MPC_VERSION} ... " |
| 333 | ( |
| 334 | #test `uname` = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL" |
| 335 | cd build-mpc |
| 336 | rm -f .failed |
| 337 | ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \ |
| 338 | --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \ |
| 339 | --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || touch .failed |
| 340 | $MAKE $JOBS || touch .failed |
| 341 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 342 | |
| 343 | if [ ! -f .failed ]; then touch .success; fi |
| 344 | ) &> build-mpc/crossgcc-build.log |
| 345 | test -r build-mpc/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n" |
| 346 | test -r build-mpc/.failed && exit 1 |
| 347 | fi |
| 348 | |
| 349 | if [ -f build-libelf/.success ]; then |
| 350 | printf "Skipping libelf as it is already built\n" |
| 351 | else |
| 352 | printf "Building libelf ${LIBELF_VERSION} ... " |
| 353 | ( |
| 354 | cd build-libelf |
| 355 | rm -f .failed |
| 356 | echo "$HOSTCFLAGS" |
Marc Jones | 3693266 | 2010-12-03 00:45:56 +0000 | [diff] [blame^] | 357 | CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \ |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 358 | --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed |
| 359 | $MAKE $JOBS || touch .failed |
| 360 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 361 | |
| 362 | if [ ! -f .failed ]; then touch .success; fi |
| 363 | ) &> build-libelf/crossgcc-build.log |
| 364 | test -r build-libelf/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n" |
| 365 | test -r build-libelf/.failed && exit 1 |
| 366 | fi |
| 367 | |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 368 | if [ -f build-binutils/.success ]; then |
| 369 | printf "Skipping binutils as it is already built\n" |
| 370 | else |
| 371 | printf "Building binutils ${BINUTILS_VERSION} ... " |
| 372 | ( |
| 373 | cd build-binutils |
| 374 | rm -f .failed |
| 375 | ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR --target=${TARGETARCH} \ |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 376 | --disable-werror --disable-nls $USE_GOLD \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 377 | CFLAGS="$HOSTCFLAGS" || touch .failed |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 378 | $MAKE $JOBS || touch .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 379 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 380 | if [ ! -f .failed ]; then touch .success; fi |
| 381 | ) &> build-binutils/crossgcc-build.log |
| 382 | test -r build-binutils/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n" |
| 383 | test -r build-binutils/.failed && exit 1 |
| 384 | fi |
| 385 | |
| 386 | if [ -f build-gcc/.success ]; then |
| 387 | printf "Skipping GCC as it is already built\n" |
| 388 | else |
| 389 | printf "Building GCC ${GCC_VERSION} ... " |
| 390 | ( |
| 391 | cd build-gcc |
Patrick Georgi | ba3b0eb | 2010-09-03 08:53:06 +0000 | [diff] [blame] | 392 | export PATH=$PATH:$DESTDIR$TARGETDIR/bin |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 393 | rm -f .failed |
| 394 | # GCC does not honour HOSTCFLAGS at all. CFLAGS are used for |
| 395 | # both target and host object files. This is pretty misdesigned. |
| 396 | # There's a work-around called CFLAGS_FOR_BUILD and CFLAGS_FOR_TARGET |
| 397 | # but it does not seem to work properly. At least the host library |
| 398 | # libiberty is not compiled with CFLAGS_FOR_BUILD. |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 399 | CFLAGS_FOR_TARGET="-O2" CFLAGS="$HOSTCFLAGS" CFLAGS_FOR_BUILD="$HOSTCFLAGS" ../gcc-${GCC_VERSION}/configure \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 400 | --prefix=$TARGETDIR --libexecdir=$TARGETDIR/lib \ |
Stefan Reinauer | 6ade161 | 2010-01-16 16:44:20 +0000 | [diff] [blame] | 401 | --target=${TARGETARCH} --disable-werror --disable-shared \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 402 | --disable-libssp --disable-bootstrap --disable-nls \ |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 403 | $GCC_OPTIONS --enable-languages="c" $USE_GOLD \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 404 | --with-gmp=$DESTDIR$TARGETDIR --with-mpfr=$DESTDIR$TARGETDIR \ |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 405 | --with-mpc=$DESTDIR$TARGETDIR --with-libelf=$DESTDIR$TARGETDIR \ |
| 406 | --with-pkgversion="coreboot toolchain v$CROSSGCC_VERSION $CROSSGCC_DATE" \ |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 407 | || touch .failed |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 408 | $MAKE $JOBS CFLAGS_FOR_BUILD="$HOSTCFLAGS" || touch .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 409 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 410 | if [ ! -f .failed ]; then touch .success; fi |
| 411 | ) &> build-gcc/crossgcc-build.log |
| 412 | test -r build-gcc/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n" |
| 413 | test -r build-gcc/.failed && exit 1 |
| 414 | fi |
| 415 | |
| 416 | if [ -f build-gdb/.success ]; then |
| 417 | printf "Skipping GDB as it is already built\n" |
| 418 | else |
| 419 | printf "Building GDB ${GDB_VERSION} ... " |
| 420 | ( |
| 421 | cd build-gdb |
Patrick Georgi | ba3b0eb | 2010-09-03 08:53:06 +0000 | [diff] [blame] | 422 | export PATH=$PATH:$DESTDIR$TARGETDIR/bin |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 423 | rm -f .failed |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 424 | CFLAGS="$HOSTCFLAGS" ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR --target=${TARGETARCH} \ |
| 425 | --without-python --disable-werror --disable-nls |
Patrick Georgi | 73166c7 | 2010-04-14 20:42:42 +0000 | [diff] [blame] | 426 | $MAKE $JOBS || touch .failed |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 427 | $MAKE install DESTDIR=$DESTDIR || touch .failed |
| 428 | if [ ! -f .failed ]; then touch .success; fi |
| 429 | ) &> build-gdb/crossgcc-build.log |
| 430 | test -r build-gdb/.failed && printf "${RED}failed${NC}\n" || printf "${green}ok${NC}\n" |
| 431 | test -r build-gdb/.failed && exit 1 |
| 432 | fi |
| 433 | |
| 434 | if [ $SAVETEMPS -eq 0 ]; then |
| 435 | printf "Cleaning up... " |
| 436 | rm -rf ${GMP_DIR} build-gmp |
| 437 | rm -rf ${MPFR_DIR} build-mpfr |
Stefan Reinauer | 5f1ad89 | 2010-05-17 11:02:25 +0000 | [diff] [blame] | 438 | rm -rf ${MPC_DIR} build-mpc |
| 439 | rm -rf ${LIBELF_DIR} build-libelf |
Stefan Reinauer | 074d913 | 2009-09-26 16:43:17 +0000 | [diff] [blame] | 440 | rm -rf ${BINUTILS_DIR} build-binutils |
| 441 | rm -rf ${GCC_DIR} build-gcc |
| 442 | rm -rf ${GDB_DIR} build-gdb |
| 443 | printf "${green}ok${NC}\n" |
| 444 | else |
| 445 | printf "Leaving temporary files around... ${green}ok${NC}\n" |
| 446 | fi |
| 447 | |
| 448 | printf "\n${green}You can now run your $TARGETARCH cross toolchain from $TARGETDIR.${NC}\n" |
| 449 | |
| 450 | |