version=5.3.0
source=(\
http://ftp.gnu.org/gnu/gmp/gmp-6.1.0.tar.xz \
http://www.mpfr.org/mpfr-current/mpfr-3.1.3.tar.xz \
http://www.multiprecision.org/mpc/download/mpc-1.0.3.tar.gz \
ftp://gcc.gnu.org/pub/gcc/releases/gcc-$version/gcc-$version.tar.bz2)

derle()
{
cd  gcc-$version
mv ../mpfr-3.1.3 mpfr
mv ../gmp-6.1.0 gmp
mv ../mpc-1.0.3 mpc

for file in \
 $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
  cp -uv $file{,.orig}
  sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
      -e 's@/usr@/tools@g' $file.orig > $file
  echo '
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
  touch $file.orig
done

mkdir -v build
cd build

../configure         \
    --target=$LFS_TGT          \
    --prefix=/tools            \
    --with-glibc-version=2.11  \
    --with-sysroot=$LFS        \
    --with-newlib              \
    --without-headers          \
    --with-local-prefix=/tools \
    --with-native-system-header-dir=/tools/include \
    --disable-nls              \
    --disable-shared           \
    --disable-multilib         \
    --disable-decimal-float    \
    --disable-threads          \
    --disable-libatomic        \
    --disable-libgomp          \
    --disable-libquadmath      \
    --disable-libssp           \
    --disable-libvtv           \
    --disable-libstdcxx        \
    --enable-languages=c,c++
make

make install

}