arm-none-eabi.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #!/bin/sh
  2. # file: arm-none-eabi.sh
  3. #
  4. # This script downloads, compiles and installs an ARM toolchain for
  5. # building QCA PLC Hosted Applications;
  6. #
  7. # This script is my version of http://blog.tan-ce.com/gcc-bare-metal/
  8. # charles maier <cmaier@qca.qualcomm.com>
  9. #
  10. # ====================================================================
  11. # install packages;
  12. # --------------------------------------------------------------------
  13. apt-get install texinfo
  14. # ====================================================================
  15. # define folders
  16. # --------------------------------------------------------------------
  17. tmp=~
  18. opt=/opt
  19. pkg=arm-none-eabi
  20. # ====================================================================
  21. # define toolchain programs
  22. # --------------------------------------------------------------------
  23. GCC=gcc-4.7.1
  24. BIN=binutils-2.22
  25. GDB=gdb-7.4
  26. LIB=newlib-1.20.0
  27. # ====================================================================
  28. #
  29. # --------------------------------------------------------------------
  30. mkdir ${tmp}/${pkg} ${opt}/${pkg}
  31. cd ${tmp}/${pkg}
  32. mkdir src bld
  33. # ====================================================================
  34. # download tools;
  35. # --------------------------------------------------------------------
  36. cd ${tmp}/${pkg}/src
  37. if [ ! -f ${GCC}.tar.bz2 ]; then
  38. wget ftp://ftp.gnu.org/gnu/gcc/${GCC}/${GCC}.tar.bz2
  39. fi
  40. if [ ! -f ${BIN}.tar.bz2 ]; then
  41. wget ftp://ftp.gnu.org/gnu/binutils/${BIN}.tar.bz2
  42. fi
  43. if [ ! -f ${GDB}.tar.bz2 ]; then
  44. wget ftp://ftp.gnu.org/gnu/gdb/${GDB}.tar.bz2
  45. fi
  46. if [ ! -f ${LIB}.tar.gz ]; then
  47. wget ftp://sources.redhat.com/pub/newlib/${LIB}.tar.gz
  48. fi
  49. # ====================================================================
  50. # unpack tools;
  51. # --------------------------------------------------------------------
  52. cd ${tmp}/${pkg}/src
  53. if [ ! -d ${GCC} ]; then
  54. tar -xf ${GCC}.tar.bz2
  55. fi
  56. if [ ! -d ${BIN} ]; then
  57. tar -xf ${BIN}.tar.bz2
  58. fi
  59. if [ ! -d ${GDB} ]; then
  60. tar -xf ${GDB}.tar.bz2
  61. fi
  62. if [ ! -d ${LIB} ]; then
  63. tar -xf ${LIB}.tar.gz
  64. fi
  65. # ====================================================================
  66. # build binutils
  67. # --------------------------------------------------------------------
  68. cd ${tmp}/${pkg}/bld
  69. mkdir ${BIN}
  70. cd ${BIN}
  71. ../../src/${BIN}/configure \
  72. --target=${pkg} \
  73. --prefix=${opt}/${pkg} \
  74. --enable-interwork \
  75. --enable-multilib
  76. make all install
  77. # ====================================================================
  78. # build gcc
  79. # --------------------------------------------------------------------
  80. cd ${tmp}/${pkg}/bld
  81. mkdir ${GCC}
  82. cd ${GCC}
  83. ../../src/${GCC}/configure
  84. --target=${pkg} \
  85. --prefix=${opt}/${pkg} \
  86. --enable-interwork \
  87. --enable-multilib \
  88. --enable-languages="c,c++" \
  89. --with-newlib \
  90. --with-headers=../../src/${LIB}/newlib/libc/include \
  91. --with-system-zlib
  92. make all-gcc install-gcc
  93. # ====================================================================
  94. # build newlib
  95. # --------------------------------------------------------------------
  96. cd ${tmp}/${pkg}/bld
  97. mkdir ${LIB}
  98. cd ${LIB}
  99. ../../src/${LIB}/configure \
  100. --target=${pkg} \
  101. --prefix=${opt}/${pkg} \
  102. --enable-interwork \
  103. --enable-multilib \
  104. --disable-newlib-supplied-syscalls
  105. make all install
  106. # ====================================================================
  107. # complete gcc build
  108. # --------------------------------------------------------------------
  109. cd ${tmp}/${pkg}/bld/${GCC}
  110. make all install
  111. # ====================================================================
  112. # build gdb
  113. # --------------------------------------------------------------------
  114. cd ${tmp}/${pkg}/bld
  115. mkdir ${GDB}
  116. cd ${GDB}
  117. ../../src/${GDB}/configure \
  118. --target=${pkg} \
  119. --prefix=${opt}/${pkg} \
  120. --enable-interwork \
  121. --enable-multilib
  122. make all install
  123. # ====================================================================
  124. # export PATH
  125. # --------------------------------------------------------------------
  126. export PATH="$PATH:${opt}/${pkg}/bin"