arm7tdmi toolchain (binutils, gcc, newlib, gdb)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. # build arch:
  2. BUILDARCH=i686-linux-gnu
  3. #TARGETARCH=arm-none-eabi
  4. TARGETARCH=arm-none-eabi
  5. # output dir:
  6. TOOLCHAIN=/opt/$(TARGETARCH)
  7. MAKEOPTS=-j4
  8. # #####################################################################
  9. # MAIN TARGETS (binutils, gcc, g++, newlib, gdb for arm7tdmi)
  10. # #####################################################################
  11. toolchain: binutils gcc newlib gdb openocd
  12. # #####################################################################
  13. BASE=$(shell /bin/pwd)
  14. DOWNLOADS=$(BASE)/download
  15. SOURCE=$(BASE)/source
  16. PATH:=$(PATH):$(TOOLCHAIN)/bin
  17. WGET:=/usr/bin/wget --passive-ftp -nd
  18. # #####################################################################
  19. BINUTILS_VERSION=2.22
  20. BINUTILS_PACKAGE=binutils-$(BINUTILS_VERSION).tar.bz2
  21. BINUTILS_DOWNLOAD=http://ftp.gnu.org/gnu/binutils/$(BINUTILS_PACKAGE)
  22. BINUTILS_SOURCE=$(SOURCE)/binutils-$(BINUTILS_VERSION)
  23. BINUTILS_BUILD=$(BINUTILS_SOURCE)-build-$(TARGETARCH)
  24. # #####################################################################
  25. GCC_VERSION=4.6.3
  26. GCC_PACKAGE=gcc-$(GCC_VERSION).tar.bz2
  27. GCC_DOWNLOAD=http://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/$(GCC_PACKAGE)
  28. GCC_SOURCE=$(SOURCE)/gcc-$(GCC_VERSION)
  29. GCC_BUILD=$(GCC_SOURCE)-build-$(TARGETARCH)
  30. # #####################################################################
  31. MPC_VERSION=0.9
  32. MPC_PACKAGE=mpc-$(MPC_VERSION).tar.gz
  33. MPC_DOWNLOAD=http://www.multiprecision.org/mpc/download/$(MPC_PACKAGE)
  34. MPC_SOURCE=$(SOURCE)/mpc-$(MPC_VERSION)
  35. # #####################################################################
  36. GMP_VERSION=5.0.5
  37. GMP_PACKAGE=gmp-$(GMP_VERSION).tar.bz2
  38. GMP_DOWNLOAD=http://ftp.gnu.org/gnu/gmp/$(GMP_PACKAGE)
  39. GMP_SOURCE=$(SOURCE)/gmp-$(GMP_VERSION)
  40. # #####################################################################
  41. MPFR_VERSION=3.1.0
  42. MPFR_PACKAGE=mpfr-$(MPFR_VERSION).tar.bz2
  43. MPFR_DOWNLOAD=http://www.mpfr.org/mpfr-$(MPFR_VERSION)/$(MPFR_PACKAGE)
  44. MPFR_SOURCE=$(SOURCE)/mpfr-$(MPFR_VERSION)
  45. # #####################################################################
  46. NEWLIB_VERSION=1.20.0
  47. NEWLIB_PACKAGE=newlib-$(NEWLIB_VERSION).tar.gz
  48. NEWLIB_DOWNLOAD=ftp://sources.redhat.com/pub/newlib/$(NEWLIB_PACKAGE)
  49. NEWLIB_SOURCE=$(SOURCE)/newlib-$(NEWLIB_VERSION)
  50. NEWLIB_BUILD=$(NEWLIB_SOURCE)-build-$(TARGETARCH)
  51. # #####################################################################
  52. GDB_VERSION=7.4
  53. GDB_PACKAGE=gdb-$(GDB_VERSION).tar.bz2
  54. GDB_DOWNLOAD=http://ftp.gnu.org/gnu/gdb/$(GDB_PACKAGE)
  55. GDB_SOURCE=$(SOURCE)/gdb-$(GDB_VERSION)
  56. GDB_BUILD=$(GDB_SOURCE)-build-$(TARGETARCH)
  57. # #####################################################################
  58. OOCD_VERSION=0.5.0
  59. OOCD_PACKAGE=openocd-$(OOCD_VERSION).tar.bz2
  60. OOCD_DOWNLOAD=http://downloads.sourceforge.net/project/openocd/openocd/$(OOCD_VERSION)/$(OOCD_PACKAGE)
  61. OOCD_SOURCE=$(SOURCE)/openocd-$(OOCD_VERSION)
  62. OOCD_BUILD=$(OOCD_SOURCE)
  63. # #####################################################################
  64. FTD2XX_VERSION=1.1.10
  65. FTD2XX_PACKAGE=libftd2xx$(FTD2XX_VERSION).tar.gz
  66. FTD2XX_DOWNLOAD=http://www.ftdichip.com/Drivers/D2XX/Linux/$(FTD2XX_PACKAGE)
  67. FTD2XX_SOURCE=$(SOURCE)/ftd2xx-$(FTD2XX_VERSION)
  68. # #####################################################################
  69. binutils: $(BINUTILS_BUILD)/.installed
  70. $(DOWNLOADS)/$(BINUTILS_PACKAGE):
  71. $(WGET) -P $(DOWNLOADS) $(BINUTILS_DOWNLOAD)
  72. $(BINUTILS_SOURCE)/.unpacked: $(DOWNLOADS)/$(BINUTILS_PACKAGE)
  73. tar -C $(SOURCE) -xjf $^
  74. touch $@
  75. $(BINUTILS_BUILD)/.configured: $(BINUTILS_SOURCE)/.unpacked
  76. mkdir -p $(BINUTILS_BUILD)
  77. (cd $(BINUTILS_BUILD); $(BINUTILS_SOURCE)/configure \
  78. --build=$(BUILDARCH) --host=$(BUILDARCH) --target=$(TARGETARCH) \
  79. --prefix=$(TOOLCHAIN) \
  80. --enable-interwork \
  81. --enable-target-optspace \
  82. --disable-nls \
  83. --disable-werror \
  84. );
  85. touch $@
  86. $(BINUTILS_BUILD)/.compiled: $(BINUTILS_BUILD)/.configured
  87. $(MAKE) -C $(BINUTILS_BUILD) $(MAKEOPTS) all
  88. touch $@
  89. $(BINUTILS_BUILD)/.installed: $(BINUTILS_BUILD)/.compiled
  90. $(MAKE) -C $(BINUTILS_BUILD) install
  91. touch $@
  92. # #####################################################################
  93. gcc: $(GCC_BUILD)/.installed
  94. $(DOWNLOADS)/$(GCC_PACKAGE):
  95. $(WGET) -P $(DOWNLOADS) $(GCC_DOWNLOAD)
  96. $(GCC_SOURCE)/.unpacked: $(DOWNLOADS)/$(GCC_PACKAGE)
  97. tar -C $(SOURCE) -xjf $^
  98. touch $@
  99. $(GCC_SOURCE)/mpc: $(MPC_SOURCE)/.unpacked
  100. ln -s $(MPC_SOURCE) $@
  101. $(GCC_SOURCE)/gmp: $(GMP_SOURCE)/.unpacked
  102. ln -s $(GMP_SOURCE) $@
  103. $(GCC_SOURCE)/mpfr: $(MPFR_SOURCE)/.unpacked
  104. ln -s $(MPFR_SOURCE) $@
  105. $(GCC_BUILD)/.configured: $(GCC_SOURCE)/.unpacked $(GCC_SOURCE)/mpc $(GCC_SOURCE)/gmp $(GCC_SOURCE)/mpfr $(NEWLIB_SOURCE)/.unpacked
  106. mkdir -p $(GCC_BUILD)
  107. (cd $(GCC_BUILD); $(GCC_SOURCE)/configure \
  108. --build=$(BUILDARCH) --host=$(BUILDARCH) --target=$(TARGETARCH) \
  109. --prefix=$(TOOLCHAIN) \
  110. --enable-languages="c,c++" \
  111. --enable-interwork \
  112. --disable-libssp \
  113. --enable-target-optspace \
  114. --with-cpu=arm7tdmi \
  115. --with-cpu=cortex-m3 \
  116. --with-cpu=cortex-m4 \
  117. --with-cpu=arm966e-s \
  118. --with-gmp-include=$(GCC_BUILD)/gmp \
  119. --with-gmp-lib=$(GCC_BUILD)/gmp/.libs \
  120. --with-mpfr-include=$(GCC_SOURCE)/mpfr/src \
  121. --with-mpfr-lib=$(GCC_BUILD)/mpfr/src/.libs \
  122. --with-newlib --with-headers=$(NEWLIB_SOURCE)/newlib/libc/include \
  123. --disable-nls \
  124. );
  125. touch $@
  126. $(GCC_BUILD)/.stage1.compiled: $(GCC_BUILD)/.configured $(BINUTILS_BUILD)/.installed
  127. $(MAKE) -C $(GCC_BUILD) $(MAKEOPTS) all-gcc
  128. touch $@
  129. $(GCC_BUILD)/.stage1.installed: $(GCC_BUILD)/.stage1.compiled
  130. $(MAKE) -C $(GCC_BUILD) install-gcc
  131. touch $@
  132. $(GCC_BUILD)/.stage2.compiled: $(GCC_BUILD)/.stage1.installed $(NEWLIB_BUILD)/.installed
  133. $(MAKE) -C $(GCC_BUILD) $(MAKEOPTS) all
  134. touch $@
  135. $(GCC_BUILD)/.stage2.installed: $(GCC_BUILD)/.stage2.compiled
  136. $(MAKE) -C $(GCC_BUILD) install
  137. touch $@
  138. $(GCC_BUILD)/.installed: $(GCC_BUILD)/.stage1.installed $(GCC_BUILD)/.stage2.installed
  139. touch $@
  140. # #####################################################################
  141. $(DOWNLOADS)/$(MPC_PACKAGE):
  142. $(WGET) -P $(DOWNLOADS) $(MPC_DOWNLOAD)
  143. $(MPC_SOURCE)/.unpacked: $(DOWNLOADS)/$(MPC_PACKAGE)
  144. tar -C $(SOURCE) -xzf $(DOWNLOADS)/$(MPC_PACKAGE)
  145. touch $@
  146. # #####################################################################
  147. $(DOWNLOADS)/$(GMP_PACKAGE):
  148. $(WGET) -P $(DOWNLOADS) $(GMP_DOWNLOAD)
  149. $(GMP_SOURCE)/.unpacked: $(DOWNLOADS)/$(GMP_PACKAGE)
  150. tar -C $(SOURCE) -xjf $(DOWNLOADS)/$(GMP_PACKAGE)
  151. touch $@
  152. # #####################################################################
  153. $(DOWNLOADS)/$(MPFR_PACKAGE):
  154. $(WGET) -P $(DOWNLOADS) $(MPFR_DOWNLOAD)
  155. $(MPFR_SOURCE)/.unpacked: $(DOWNLOADS)/$(MPFR_PACKAGE)
  156. tar -C $(SOURCE) -xjf $(DOWNLOADS)/$(MPFR_PACKAGE)
  157. touch $@
  158. # #####################################################################
  159. newlib: $(NEWLIB_BUILD)/.installed
  160. $(DOWNLOADS)/$(NEWLIB_PACKAGE):
  161. $(WGET) -P $(DOWNLOADS) $(NEWLIB_DOWNLOAD)
  162. $(NEWLIB_SOURCE)/.unpacked: $(DOWNLOADS)/$(NEWLIB_PACKAGE)
  163. tar -C $(SOURCE) -xzf $^
  164. touch $@
  165. $(NEWLIB_BUILD)/.configured: $(NEWLIB_SOURCE)/.unpacked $(GCC_BUILD)/.stage1.installed
  166. mkdir -p $(NEWLIB_BUILD)
  167. (cd $(NEWLIB_BUILD); $(NEWLIB_SOURCE)/configure \
  168. --build=$(BUILDARCH) --host=$(BUILDARCH) --target=$(TARGETARCH) \
  169. --prefix=$(TOOLCHAIN) \
  170. --enable-interwork \
  171. --disable-newlib-io-float \
  172. --disable-newlib-supplied-syscalls \
  173. --disable-nls \
  174. );
  175. touch $@
  176. $(NEWLIB_BUILD)/.compiled: $(NEWLIB_BUILD)/.configured
  177. $(MAKE) -C $(NEWLIB_BUILD) $(MAKEOPTS) all
  178. touch $@
  179. $(NEWLIB_BUILD)/.installed: $(NEWLIB_BUILD)/.compiled
  180. $(MAKE) -C $(NEWLIB_BUILD) install
  181. touch $@
  182. # #####################################################################
  183. gdb: $(GDB_BUILD)/.installed
  184. $(DOWNLOADS)/$(GDB_PACKAGE):
  185. $(WGET) -P $(DOWNLOADS) $(GDB_DOWNLOAD)
  186. $(GDB_SOURCE)/.unpacked: $(DOWNLOADS)/$(GDB_PACKAGE)
  187. tar -C $(SOURCE) -xjf $^
  188. touch $@
  189. $(GDB_BUILD)/.configured: $(GDB_SOURCE)/.unpacked $(GCC_BUILD)/.installed
  190. mkdir -p $(GDB_BUILD)
  191. (cd $(GDB_BUILD); $(GDB_SOURCE)/configure \
  192. --build=$(BUILDARCH) --host=$(BUILDARCH) --target=$(TARGETARCH) \
  193. --prefix=$(TOOLCHAIN) \
  194. --enable-interwork \
  195. --disable-nls \
  196. );
  197. touch $@
  198. $(GDB_BUILD)/.compiled: $(GDB_BUILD)/.configured
  199. $(MAKE) -C $(GDB_BUILD) $(MAKEOPTS) all
  200. touch $@
  201. $(GDB_BUILD)/.installed: $(GDB_BUILD)/.compiled
  202. $(MAKE) -C $(GDB_BUILD) install
  203. touch $@
  204. # #####################################################################
  205. openocd: $(OOCD_BUILD)/.installed
  206. $(DOWNLOADS)/$(OOCD_PACKAGE):
  207. $(WGET) -P $(DOWNLOADS) $(OOCD_DOWNLOAD)
  208. $(OOCD_SOURCE)/.unpacked: $(DOWNLOADS)/$(OOCD_PACKAGE)
  209. tar -C $(SOURCE) -xjf $^
  210. touch $@
  211. $(OOCD_BUILD)/.configured: $(OOCD_SOURCE)/.unpacked $(FTD2XX_SOURCE)/.unpacked
  212. mkdir -p $(OOCD_BUILD)
  213. (cd $(OOCD_BUILD); $(OOCD_SOURCE)/configure \
  214. --prefix=$(TOOLCHAIN) \
  215. --disable-static \
  216. --disable-doxygen-html \
  217. --enable-parport \
  218. --enable-ft2232_ftd2xx \
  219. --enable-usbprog \
  220. --enable-jlink \
  221. --enable-arm-jtag-ew \
  222. --with-ftd2xx-linux-tardir=$(FTD2XX_SOURCE)/release \
  223. );
  224. touch $@
  225. $(OOCD_BUILD)/.compiled: $(OOCD_BUILD)/.configured
  226. $(MAKE) -C $(OOCD_BUILD) $(MAKEOPTS) all
  227. touch $@
  228. $(OOCD_BUILD)/.installed: $(OOCD_BUILD)/.compiled
  229. $(MAKE) -C $(OOCD_BUILD) install
  230. touch $@
  231. # #####################################################################
  232. $(DOWNLOADS)/$(FTD2XX_PACKAGE):
  233. $(WGET) -P $(DOWNLOADS) $(FTD2XX_DOWNLOAD)
  234. $(FTD2XX_SOURCE)/.unpacked: $(DOWNLOADS)/$(FTD2XX_PACKAGE)
  235. mkdir -p $(FTD2XX_SOURCE)
  236. tar -C $(FTD2XX_SOURCE) -xzf $^
  237. touch $@