build-gcc.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. $DIR/check-reqs.sh
  4. TARGET=i686-pc-toaru
  5. PREFIX="$DIR/local"
  6. TOARU_SYSROOT="$DIR/../base"
  7. cd "$DIR"
  8. mkdir -p tarballs
  9. pushd tarballs
  10. if [ ! -e "binutils-2.27.tar.gz" ]; then
  11. wget "http://ftp.gnu.org/gnu/binutils/binutils-2.27.tar.gz"
  12. fi
  13. if [ ! -e "gcc-6.4.0.tar.gz" ]; then
  14. wget "http://www.netgull.com/gcc/releases/gcc-6.4.0/gcc-6.4.0.tar.gz"
  15. fi
  16. if [ ! -d "binutils-2.27" ]; then
  17. tar -xf "binutils-2.27.tar.gz"
  18. pushd "binutils-2.27"
  19. patch -p1 < $DIR/patches/binutils.patch > /dev/null
  20. popd
  21. fi
  22. if [ ! -d "gcc-6.4.0" ]; then
  23. tar -xf "gcc-6.4.0.tar.gz"
  24. pushd "gcc-6.4.0"
  25. patch -p1 < $DIR/patches/gcc.patch > /dev/null
  26. popd
  27. fi
  28. popd
  29. mkdir -p local
  30. mkdir -p build
  31. mkdir -p build/binutils
  32. mkdir -p build/gcc
  33. pushd build
  34. unset PKG_CONFIG_LIBDIR # Just in case
  35. pushd binutils
  36. $DIR/tarballs/binutils-2.27/configure --target=$TARGET --prefix=$PREFIX --with-sysroot=$TOARU_SYSROOT --disable-werror || exit 1
  37. make -j4
  38. make install
  39. popd
  40. pushd gcc
  41. $DIR/tarballs/gcc-6.4.0/configure --target=i686-pc-toaru --prefix=$PREFIX --with-sysroot=$TOARU_SYSROOT --disable-nls --enable-languages=c,c++ --disable-libssp --with-newlib || exit 1
  42. make all-gcc all-target-libgcc
  43. make install-gcc install-target-libgcc
  44. popd
  45. popd