# Inspired by http://linuxfromscratch.org/blfs/view/stable/general/gcc.html

# Exit on error:
set -e

wget http://ftpmirror.gnu.org/gcc/gcc-4.9.2/gcc-4.9.2.tar.bz2
tar xf gcc-4.9.2.tar.bz2

mkdir gcc-build
cd gcc-build

../gcc-4.9.2/configure \
    --prefix=/usr/local \
    --libdir=/usr/local/lib \
    --enable-shared \
    --enable-threads=posix \
    --enable-__cxa_atexit \
    --enable-clocale=gnu \
    --disable-multilib \
    --with-system-zlib \
    --with-abi=n32 \
    --enable-languages=c,c++ \
    --disable-bootstrap
# --disable-bootstrap to spare a lot of time

make -j4
make install
ln -sv gcc /usr/local/bin/cc

cd ..
exit 0
