#---------------------------------------------------------------------------------
# Source and Install directories
#---------------------------------------------------------------------------------

GCC_VERSION=gcc-4.1.1-2
NEWLIB_VERSION=newlib-1.14.0-2

SRCDIR=../../source/$GCC_VERSION             # the sourcecode dir for gcc
                                             # This must be specified in the format shown here
                                             # as one of the tools built during the process will fail
                                             # if absolute paths are specified
                                             # the example here assumes that the gcc source directory
                                             # is at the same level as the script

prefix=/c/MinGW/cross-gcc/powerpc-rtems4.7   # installation directory
                                             # This must be specified in the format shown here
                                             # or gcc won't be able to find it's libraries and includes
                                             # if you move the installation

#----------------------------------------------------
# link newlib directories into gcc tree
#----------------------------------------------------
#cd source/$GCC_VERSION
#ln -s ../${NEWLIB_VERSION}/newlib   .
#ln -s ../${NEWLIB_VERSION}/libgloss .
#cd ../..

#----------------------------------------------------
# set the path for the installed binutils
#----------------------------------------------------

export PATH=${PATH}:/c/cross-gcc/powerpc-rtems4.7/bin

#----------------------------------------------------
# set the target and compiler flags
#----------------------------------------------------

target=powerpc-rtems4.7

export CFLAGS='-O2 -pipe'
export CXXFLAGS='-O2 -pipe'
export LDFLAGS='-s'
export DEBUG_FLAGS=''

#---------------------------------------------------------------------------------
# build and install just the c compiler
#---------------------------------------------------------------------------------

mkdir -p $target/gcc
cd $target/gcc

echo $target

$SRCDIR/configure \
        --enable-languages=c                \
        --disable-multilib                  \
        --with-gnu-as                       \
        --with-gnu-ld                       \
        --enable-threads=rtems              \
        --disable-nls                       \
        --with-newlib                       \
        --verbose                           \
        --with-system-zlib                  \
        --enable-version-specific-runtime-libs \
        --disable-win32-registry               \
        --target=$target                       \
        --prefix=$prefix                       \
        2>&1 | tee gcc_configure.log

#make | tee make-gcc.log 2>&1
#make install | tee install-gcc.log 2>&1

echo "start making the compiler"
make all-gcc | tee make-c-only.log 2>&1

echo "make done.  installing..."
make install-gcc | tee install-c-only.log 2>&1
