Home | History | Annotate | Download | only in scripts
      1 #!/bin/bash
      2 
      3 # Make sure that libgmp and libmpfr are installed before you run this script.
      4 # On Debian systems, e.g. Ubuntu, you can install these libraries as follows:
      5 # sudo apt-get install libgmp3-dev libmpfr-dev. In openSUSE these packages
      6 # are called gmp-devel and mpfr-devel.
      7 
      8 
      9 GCC_VERSION=4.5.0
     10 FSF_MIRROR=ftp://ftp.easynet.be/gnu
     11 SRCDIR=$HOME/software
     12 DOWNLOADS=$SRCDIR/downloads
     13 SRC=$HOME/software/gcc-${GCC_VERSION}
     14 BUILD=${SRC}-build
     15 TAR=gcc-${GCC_VERSION}.tar.bz2
     16 PREFIX=$HOME/gcc-${GCC_VERSION}
     17 GMP_PREFIX=/usr
     18 #GMP_PREFIX=$HOME/gmp-5.0.1
     19 MPFR_PREFIX=/usr
     20 #MPFR_PREFIX=$HOME/mpfr-2.4.2
     21 MPC_PREFIX=/usr
     22 #MPC_PREFIX=$HOME/mpc-0.8.1
     23 export LC_ALL=C
     24 export MAKEFLAGS="-j$(($(grep -c '^processor' /proc/cpuinfo) + 1))"
     25 
     26 if [ ! -e $GMP_PREFIX/include/gmp.h ]; then
     27   echo "Please install the gmp library development package first."
     28   exit 1
     29 fi
     30 
     31 if [ ! -e $MPFR_PREFIX/include/mpfr.h ]; then
     32   echo "Please install the mpfr library development package first."
     33   exit 1
     34 fi
     35 
     36 if [ ! -e $MPC_PREFIX/include/mpc.h ]; then
     37   echo "Please install the mpc library development package first."
     38   exit 1
     39 fi
     40 
     41 rm -rf   ${BUILD}     || exit $?
     42 rm -rf   ${PREFIX}    || exit $?
     43 mkdir -p ${DOWNLOADS} || exit $?
     44 mkdir -p ${BUILD}     || exit $?
     45 cd       ${BUILD}     || exit $?
     46 
     47 if [ ! -e $DOWNLOADS/$TAR ]; then
     48 (
     49   if cd $DOWNLOADS; then
     50     wget -q $FSF_MIRROR/gcc/gcc-${GCC_VERSION}/$TAR \
     51     || { wget -q -O- $FSF_MIRROR/gcc/gcc-${GCC_VERSION}/${TAR%bz2}gz \
     52          | gzip -cd | bzip2 -9 >${TAR}; }
     53   fi
     54 )
     55 fi
     56 
     57 if [ ! -e $SRC ]; then
     58   ( cd $SRCDIR && tar -xjf $DOWNLOADS/$TAR )
     59 fi
     60 
     61 ${SRC}/configure            \
     62   --disable-linux-futex     \
     63   --disable-mudflap         \
     64   --disable-nls             \
     65   --enable-languages=c,c++  \
     66   --enable-threads=posix    \
     67   --enable-tls              \
     68   --prefix=$PREFIX          \
     69   --with-gmp=$GMP_PREFIX    \
     70   --with-mpfr=$MPFR_PREFIX  \
     71   --with-mpc=$MPC_PREFIX
     72 
     73 time { make -s && make -s install; }
     74