# Originally created by John Murga (cf. http://gcc.gnu.org/ml/java/2003-01/msg00299.html)
# Adapted by Mohan Embar (http://www.thisiscool.com/) for GCC 3.3
# Check that we appear to have set the environment up

. buildenv.sh

if [ ! $BUILD_ROOT_DIR  ]
then
    echo "You must set the enviroment before runing this script..."
    exit
fi

if [ ! -d $BUILD_ROOT_DIR  ]
then
    echo Setting up build directory...
    mkdir $BUILD_ROOT_DIR
    cd $BUILD_ROOT_DIR
fi

if [ ! -d $NATGCC_DIR ]
then
    echo Setting up native compiler build directory...

    mkdir $NATGCC_DIR
    cd $NATGCC_DIR
fi

# If GCC isn't configured this make sure it is all set-up ready for a "make"

if [ ! -d $NATGCC_BUILD_DIR ]
then
    echo Setting up native gcc build directory...
    mkdir $NATGCC_BUILD_DIR
    cd $NATGCC_BUILD_DIR
    sh $BUILD_SCRIPTS_DIR/cfgnatgcc.sh
fi

# If all else has been done the only thing this script will do is attempt to
# make GCC, this way if you have applied any patches it'll incorporate them.

echo "About to build native GCC... <<Press enter>>"
read dummyVar

cd $NATGCC_BUILD_DIR
sh $BUILD_SCRIPTS_DIR/mknatgcc.sh

echo
echo "All done !"
