Advertisement
Guest User

arm-elf cross compiler for chdk thumb2

a guest
Mar 16th, 2014
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. #!/bin/sh
  2. # Builds a arm-elf cross compiler for use on linux
  3. # host systems. This target has no file system or kernel.
  4. #
  5. TARGET="arm-elf"
  6. BUILDDIR=`pwd`
  7. BUILDDIR="${BUILDDIR}/build-dir"
  8. mkdir ${BUILDDIR}
  9. SRC="${BUILDDIR}/packages" # package directory
  10. PREFIX="${BUILDDIR}/arm/toolchain" # final toolchain directory
  11. PARALLEL="-j 5"
  12. #PARALLEL=
  13. BINUTILS=binutils-2.24
  14. GCC=gcc-4.6.4
  15. GMP=gmp-5.0.1
  16. #MPFR=mpfr-3.1.2
  17. MPFR=mpfr-3.0.1
  18. MPC=mpc-0.8.2
  19. NEWLIB=newlib-2.1.0
  20. export PATH="$PATH:$PREFIX/bin"
  21. # Before we do anything we need all the source files.
  22. # We keep them in one place and we never need to
  23. # download them twice if this build fails.
  24. mkdir $SRC
  25. cd $SRC
  26. echo "Downloading source packages. This may take a while."
  27. echo
  28. wget -c http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2
  29. wget -c ftp://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.bz2
  30. wget -c ftp://ftp.gmplib.org/pub/$GMP/$GMP.tar.bz2
  31. #wget -c http://www.mpfr.org/mpfr-current/$MPFR.tar.bz2
  32. # http://stackoverflow.com/questions/9297933/cannot-configure-gcc-mpfr-not-found
  33. wget -c http://ftp.gnu.org/gnu/mpfr/$MPFR.tar.bz2
  34. wget -c http://www.multiprecision.org/mpc/download/$MPC.tar.gz
  35. wget -c ftp://sources.redhat.com/pub/newlib/$NEWLIB.tar.gz
  36. cd ..
  37. echo "Starting Build..."
  38. echo
  39. mkdir build
  40. echo "Building binutils"
  41. echo
  42. tar xfj $SRC/$BINUTILS.tar.bz2
  43. cd $BINUTILS
  44. ./configure --target=$TARGET --prefix=$PREFIX --disable-werror
  45. # --enable-interwork --disable-multilib --with-gnu-as
  46. # --with-gnu-ld --disable-nls --disable-werror
  47. make $PARALLEL
  48. make install
  49. cd ..
  50. rm -rf build/* $BINUTILS
  51. echo "Building GCC pass 1"
  52. tar xfj $SRC/$GCC.tar.bz2
  53. # the compiler math prereqs
  54. tar -jxf $SRC/$GMP.tar.bz2
  55. tar -jxf $SRC/$MPFR.tar.bz2
  56. tar -zxf $SRC/$MPC.tar.gz
  57. cd $GCC
  58. mv ../$GMP gmp
  59. mv ../$MPFR mpfr
  60. mv ../$MPC mpc
  61. cd ../build
  62. #
  63. ed ../$GCC/gcc/config/arm/t-arm-elf << EOF
  64. /MULTILIB_OPTIONS/s/^M/# M/
  65. /MULTILIB_DIRNAMES/s/^M/# M/
  66. /mno-thumb-interwork/s/^# //
  67. /normal interwork/s/^# //
  68. wq
  69. EOF
  70. #
  71. ../$GCC/configure --target=$TARGET --prefix=$PREFIX --enable-interwork \
  72. --enable-multilib --enable-languages="c" --with-newlib \
  73. --with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs \
  74. --without-headers --disable-shared --disable-nls --with-gnu-as --with-gnu-ld
  75. make $PARALLEL all-gcc
  76. make install-gcc
  77. cd ..
  78. rm -rf build/* # (We retain the GCC directory for pass 2)
  79. echo "Building Newlib"
  80. echo
  81. tar xfz $SRC/$NEWLIB.tar.gz
  82. cd build
  83. ../$NEWLIB/configure --target=$TARGET --prefix=$PREFIX --enable-interwork \
  84. --enable-multilib --with-gnu-as --with-gnu-ld --disable-nls
  85. make $PARALLEL
  86. make install
  87. cd ..
  88. rm -rf build/* $NEWLIB
  89. echo " Building GCC pass 2"
  90. echo
  91. cd build
  92. ../$GCC/configure --target=$TARGET --prefix=$PREFIX --enable-interwork \
  93. --enable-multilib --enable-languages="c" --with-newlib \
  94. --with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs \
  95. --without-headers --disable-libssp --disable-nls --disable-zlib --disable-libc --disable-libm --disable-intl \
  96. --disable-hardfloat --disable-threads --with-gnu-as --with-gnu-ld
  97. make $PARALLEL
  98. make install
  99. cd ..
  100. rm -rf build/* $GCC
  101. echo "Compiler Finished for "$TARGET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement