• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
9GCC_VERSION=4.5.0
10FSF_MIRROR=ftp://ftp.easynet.be/gnu
11SRCDIR=$HOME/software
12DOWNLOADS=$SRCDIR/downloads
13SRC=$HOME/software/gcc-${GCC_VERSION}
14BUILD=${SRC}-build
15TAR=gcc-${GCC_VERSION}.tar.bz2
16PREFIX=$HOME/gcc-${GCC_VERSION}
17GMP_PREFIX=/usr
18#GMP_PREFIX=$HOME/gmp-5.0.1
19MPFR_PREFIX=/usr
20#MPFR_PREFIX=$HOME/mpfr-2.4.2
21MPC_PREFIX=/usr
22#MPC_PREFIX=$HOME/mpc-0.8.1
23export LC_ALL=C
24export MAKEFLAGS="-j$(($(grep -c '^processor' /proc/cpuinfo) + 1))"
25
26if [ ! -e $GMP_PREFIX/include/gmp.h ]; then
27  echo "Please install the gmp library development package first."
28  exit 1
29fi
30
31if [ ! -e $MPFR_PREFIX/include/mpfr.h ]; then
32  echo "Please install the mpfr library development package first."
33  exit 1
34fi
35
36if [ ! -e $MPC_PREFIX/include/mpc.h ]; then
37  echo "Please install the mpc library development package first."
38  exit 1
39fi
40
41rm -rf   ${BUILD}     || exit $?
42rm -rf   ${PREFIX}    || exit $?
43mkdir -p ${DOWNLOADS} || exit $?
44mkdir -p ${BUILD}     || exit $?
45cd       ${BUILD}     || exit $?
46
47if [ ! -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)
55fi
56
57if [ ! -e $SRC ]; then
58  ( cd $SRCDIR && tar -xjf $DOWNLOADS/$TAR )
59fi
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
73time { make -s && make -s install; }
74