#!/bin/sh

. config/options

$SCRIPTS/build binutils
$SCRIPTS/build gmp
$SCRIPTS/build mpfr
$SCRIPTS/build mpc
$SCRIPTS/build ppl
$SCRIPTS/build cloog-ppl
$SCRIPTS/build libelf
$SCRIPTS/build eglibc
$SCRIPTS/unpack gcc

setup_toolchain host

cd $BUILD/gcc*
mkdir -p objdir-$1
cd objdir-$1
LDFLAGS="-Wl,-rpath,$ROOT/$TOOLCHAIN/lib" \
../configure --host=$HOST_NAME \
             --build=$HOST_NAME \
             --target=$TARGET_NAME \
             --prefix=$ROOT/$TOOLCHAIN \
             --with-sysroot=$SYSROOT_PREFIX \
             --with-gmp=$ROOT/$TOOLCHAIN \
             --with-mpfr=$ROOT/$TOOLCHAIN \
             --with-mpc=$ROOT/$TOOLCHAIN \
             --with-ppl=$ROOT/$TOOLCHAIN \
             --with-cloog=$ROOT/$TOOLCHAIN \
             --with-libelf=$ROOT/$TOOLCHAIN \
             --enable-languages=${TOOLCHAIN_LANGUAGES} \
             --enable-__cxa_atexit \
             --disable-libada \
             --enable-decimal-float \
             --disable-libmudflap \
             --disable-libssp \
             --disable-multilib \
             --enable-tls \
             --enable-shared \
             --enable-c99 \
             --enable-long-long \
             --enable-threads=posix \
             --disable-nls

make

make install
cp -PR $TARGET_NAME/libstdc++-v3/src/.libs/libstdc++.so* $SYSROOT_PREFIX/usr/lib

