#!/bin/bash -x BINUTILS_VERSION=${BINUTILS_VERSION:-"2.20"} GCC_VERSION=${GCC_VERSION:-"4.4.2"} TARGET=${TARGET:-"i586-elf"} PREFIX=${PREFIX:-"$HOME/local/$TARGET"} GNUFTP=ftp://ftp.gnu.org/gnu export PATH=$PREFIX/bin:$PATH mkdir -p build-binutils build-gcc if [ ! -f "binutils-$BINUTILS_VERSION.tar.bz2" ]; then wget "$GNUFTP/binutils/binutils-$BINUTILS_VERSION.tar.bz2" if [ $? != 0 ]; then echo "Error downloading binutils" exit 1 fi fi if [ ! -f "gcc-$GCC_VERSION.tar.bz2" ]; then wget "$GNUFTP/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.bz2" if [ $? != 0 ]; then echo "Error downloading gcc" exit 1 fi fi if [ ! -d "binutils-$BINUTILS_VERSION" ]; then tar xvjf "binutils-$BINUTILS_VERSION.tar.bz2" if [ $? != 0 ]; then echo "Error extracting binutils" exit 1 fi fi if [ ! -d "gcc-$GCC_VERSION" ]; then tar xvjf "gcc-$GCC_VERSION.tar.bz2" if [ $? != 0 ]; then echo "Error extracting gcc" exit 1 fi fi # build binutils dum=`which $TARGET-ar` if [ $? != 0 ]; then pushd build-binutils ../binutils-$BINUTILS_VERSION/configure --target=$TARGET --prefix=$PREFIX --disable-nls if [ $? != 0 ]; then echo "Error configuring binutils" exit 1 fi make all if [ $? != 0 ]; then echo "Error building binutils" exit 1 fi make install if [ $? != 0 ]; then echo "Error installing binutils" exit 1 fi popd fi # build gcc dum=`which $TARGET-gcc` if [ $? != 0 ]; then pushd build-gcc ../gcc-$GCC_VERSION/configure --target=$TARGET --prefix=$PREFIX --disable-nls --enable-languages=c,c++ --without-headers if [ $? != 0 ]; then echo "Error configuring gcc" exit 1 fi make all-gcc if [ $? != 0 ]; then echo "Error building gcc" exit 1 fi make install-gcc if [ $? != 0 ]; then echo "Error installing gcc" exit 1 fi make all-target-libgcc if [ $? != 0 ]; then echo "Error building libgcc" exit 1 fi make install-target-libgcc if [ $? != 0 ]; then echo "Error installing libgcc" exit 1 fi popd fi exit 0