Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2024
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.43 KB | None | 0 0
  1. #!/bin/sh
  2. # based on: https://blogs.coreboot.org/blog/2009/03/04/building-an-arm-cross-toolchain-with-binutils-gcc-newlib-and-gdb-from-source/
  3. # and https://wiki.osdev.org/GCC_Cross-Compiler#GCC
  4.  
  5. # after Debian Lenny/Squeeze/Wheezy(at least <Jessie) install
  6. #   su root
  7. #   root
  8. #   apt-get install build-essential bzip2 flex
  9. #   exit
  10.  
  11. TARGET=arm-elf                         # Or: TARGET=arm-none-eabi
  12. PREFIX=$HOME/$TARGET-toolchain    # Install location of your final toolchain
  13. #PREFIX=/usr/dennis/$TARGET-toolchain   # Install location of your final toolchain
  14. PARALLEL="-j 4"                        # Or: PARALLEL=""
  15.  
  16. BINUTILS=binutils-2.15
  17. GCC=gcc-3.4.0
  18. NEWLIB=newlib-1.12.0
  19.  
  20. export PATH="$PATH:$PREFIX/bin"
  21.  
  22. #-----------
  23.  
  24. wget -c http://192.168.56.1:8000/$BINUTILS.tar.bz2
  25. wget -c http://192.168.56.1:8000/$GCC.tar.gz
  26. wget -c http://192.168.56.1:8000/$NEWLIB.tar.gz
  27.  
  28. #-----------
  29. if true; then
  30. # TODO extract directly from downloads
  31. cp ./downloads/$BINUTILS.tar.bz2 .
  32. cp ./downloads/$GCC.tar.gz .
  33. cp ./downloads/$NEWLIB.tar.gz .
  34. #-----------
  35. tar xfvj $BINUTILS.tar.bz2
  36. tar xfvz $GCC.tar.gz
  37. tar xfvz $NEWLIB.tar.gz
  38. fi
  39.  
  40. rm ./_build -rf
  41. mkdir ./_build
  42.  
  43. mkdir ./_build/binutils
  44. mkdir ./_build/gcc_stage1
  45. mkdir ./_build/gcc_stage2
  46. mkdir ./_build/newlib
  47.  
  48. if true; then
  49. cd ./_build/binutils
  50. ../../$BINUTILS/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib \
  51.   --with-gnu-as --with-gnu-ld --disable-nls
  52. make $PARALLEL
  53. make install
  54. cd ../..
  55.  
  56. cd ./_build/gcc_stage1
  57. ../../$GCC/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib \
  58.   --enable-languages="c" --with-newlib --without-headers --disable-shared --with-gnu-as --with-gnu-ld
  59. make $PARALLEL all-gcc
  60. make $PARALLEL install-gcc
  61. cd ../..
  62.  
  63. fi
  64. cd ./_build/newlib
  65. ../../$NEWLIB/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib \
  66.   --with-gnu-as --with-gnu-ld --disable-nls
  67. make $PARALLEL
  68. make install
  69. cd ../..
  70.  
  71. # Yes, you need to build gcc again!
  72. cd ./_build/gcc_stage2
  73. ../../$GCC/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib \
  74.   --enable-languages="c,c++" --with-newlib --disable-shared --with-gnu-as --with-gnu-ld \
  75.   --disable-libstdcxx-pch
  76. # --disable-libstdcxx-pch prevents a bug with PCHs (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26596) when building with net+os-6.3/cygwin340/gcc 3.3.1
  77. make $PARALLEL
  78. make install
  79. cd ../..
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement