3 # Copyright (C) 2007 Segher Boessenkool <segher@kernel.crashing.org>
4 # Copyright (C) 2009-2010 Hector Martin "marcan" <hector@marcansoft.com>
5 # Copyright (C) 2009 Andre Heider "dhewg" <dhewg@wiibrew.org>
7 # Released under the terms of the GNU GPL, version 2
8 SCRIPTDIR
=`dirname $PWD/$0`
11 BINUTILS_DIR
="binutils-$BINUTILS_VER"
12 BINUTILS_TARBALL
="binutils-$BINUTILS_VER.tar.bz2"
13 BINUTILS_URI
="http://ftp.gnu.org/gnu/binutils/$BINUTILS_TARBALL"
16 GMP_DIR
="gmp-$GMP_VER"
17 GMP_TARBALL
="gmp-$GMP_VER.tar.bz2"
18 GMP_URI
="http://ftp.gnu.org/gnu/gmp/$GMP_TARBALL"
21 MPFR_DIR
="mpfr-$MPFR_VER"
22 MPFR_TARBALL
="mpfr-$MPFR_VER.tar.bz2"
23 MPFR_URI
="http://www.mpfr.org/mpfr-$MPFR_VER/$MPFR_TARBALL"
26 GCC_DIR
="gcc-$GCC_VER"
27 GCC_CORE_TARBALL
="gcc-core-$GCC_VER.tar.bz2"
28 GCC_CORE_URI
="http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VER/$GCC_CORE_TARBALL"
32 PPU_TARGET
=powerpc64-linux
35 if [ -z $MAKEOPTS ]; then
39 # End of configuration section.
49 export PATH
=$PS3DEV/bin
:$PATH
57 [ -e $PS3DEV/$BINUTILS_DIR ] && rm -rf $PS3DEV/$BINUTILS_DIR
58 [ -e $PS3DEV/$GCC_DIR ] && rm -rf $PS3DEV/$GCC_DIR
62 [ -e $PS3DEV/build_binutils
] && rm -rf $PS3DEV/build_binutils
63 [ -e $PS3DEV/build_gcc
] && rm -rf $PS3DEV/build_gcc
68 if [ -f "$PS3DEV/$2" ]; then
70 tar tjf
"$PS3DEV/$2" >/dev
/null
2>&1 && DL
=0
73 if [ $DL -eq 1 ]; then
74 echo "Downloading $2..."
75 wget
"$1" -c -O "$PS3DEV/$2" || die
"Could not download $2"
80 echo "Extracting $1..."
81 tar xjf
"$PS3DEV/$1" -C "$2" || die
"Error unpacking $1"
85 mkdir
-p $PS3DEV/build_binutils || die
"Error making binutils build directory $PS3DEV/build_binutils"
86 mkdir
-p $PS3DEV/build_gcc || die
"Error making gcc build directory $PS3DEV/build_gcc"
92 cd $PS3DEV/build_binutils
&& \
93 $PS3DEV/$BINUTILS_DIR/configure
--target=$TARGET \
94 --prefix=$PS3DEV --disable-werror --enable-64-bit-bfd && \
95 nice
$MAKE $MAKEOPTS && \
97 ) || die
"Error building binutils for target $TARGET"
103 cd $PS3DEV/build_gcc
&& \
104 $PS3DEV/$GCC_DIR/configure
--target=$TARGET --enable-targets=all \
106 --enable-languages=c
--without-headers \
107 --disable-nls --disable-threads --disable-shared \
108 --disable-libmudflap --disable-libssp --disable-libgomp \
109 --disable-decimal-float \
110 --enable-checking=release
$EXTRA_CONFIG_OPTS && \
111 nice
$MAKE $MAKEOPTS && \
113 ) || die
"Error building binutils for target $TARGET"
119 echo "******* Building SPU binutils"
120 buildbinutils
$SPU_TARGET
121 echo "******* Building SPU GCC"
123 echo "******* SPU toolchain built and installed"
129 echo "******* Building PowerPC binutils"
130 buildbinutils
$PPU_TARGET
131 echo "******* Building PowerPC GCC"
132 EXTRA_CONFIG_OPTS
="--with-cpu=cell" buildgcc
$PPU_TARGET
133 echo "******* PowerPC toolchain built and installed"
136 if [ -z "$PS3DEV" ]; then
137 die
"Please set PS3DEV in your environment."
141 ppu|spu|both|clean
) ;;
143 die
"Please specify build type (ppu/spu/both/clean)"
146 die
"Unknown build type $BUILDTYPE"
150 if [ "$BUILDTYPE" = "clean" ]; then
156 download
"$BINUTILS_URI" "$BINUTILS_TARBALL"
157 download
"$GMP_URI" "$GMP_TARBALL"
158 download
"$MPFR_URI" "$MPFR_TARBALL"
159 download
"$GCC_CORE_URI" "$GCC_CORE_TARBALL"
163 extract
"$BINUTILS_TARBALL" "$PS3DEV"
164 extract
"$GCC_CORE_TARBALL" "$PS3DEV"
165 extract
"$GMP_TARBALL" "$PS3DEV/$GCC_DIR"
166 extract
"$MPFR_TARBALL" "$PS3DEV/$GCC_DIR"
168 # in-tree gmp and mpfr
169 mv "$PS3DEV/$GCC_DIR/$GMP_DIR" "$PS3DEV/$GCC_DIR/gmp" || die
"Error renaming $GMP_DIR -> gmp"
170 mv "$PS3DEV/$GCC_DIR/$MPFR_DIR" "$PS3DEV/$GCC_DIR/mpfr" || die
"Error renaming $MPFR_DIR -> mpfr"
172 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42424
173 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44455
174 patch -d $PS3DEV/$GCC_DIR -u -i $SCRIPTDIR/gcc.
patch || die
"Error applying gcc patch"
179 both
) buildppu
; buildspu
; cleanbuild
; cleansrc
;;