#!/bin/sh

#
# See setup for user tweakables.
#
. ./setup

if test "z$SYSTEM_GCC" != "z"; then
    echo "Not building gcc / binutils";
else
    # build binutils
    if test "z$BINUTILS_VER" != "z"; then
	echo "Building $BINUTILS_VER";
	cd $BUILDDIR/$BINUTILS_VER
	./configure --prefix=$BUILDDIR || exit 1;
	make && make install || exit 1;
    fi

    echo "Building $GCC_VER";
    cd $BUILDDIR/$GCC_VER
    ./configure --prefix=$BUILDDIR --enable-languages=c++ || exit 1;
    MAKE_FLAGS=
    if test "z$ENABLE_ICECREAM" != "z"; then
	MAKE_FLAGS="-j$ICECREAM_JOBS"
    fi
    make $MAKE_FLAGS && make install || exit 1;
fi
