Makefile.fpc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. #
  2. # Makefile.fpc for Free Pascal Embedded RTL
  3. #
  4. [package]
  5. main=rtl
  6. [target]
  7. loaders=$(LOADERS)
  8. # not all targets include enough features to build all units so
  9. # the common units which are not compiled for all CPUs are stored in
  10. # CPU_SPECIFIC_COMMON_UNITS
  11. units=$(SYSTEMUNIT) $(CPU_UNITS) uuchar objpas iso7185 extpas heapmgr consoleio $(CPU_SPECIFIC_COMMON_UNITS) \
  12. # macpas iso7185 strings
  13. $(STRINGSUNIT) \
  14. $(SORTBASEUNIT) \
  15. $(DOSUNIT) \
  16. $(CTYPESUNIT) \
  17. $(CHARSETUNIT) $(CPALLUNIT) \
  18. $(SYSCONSTUNIT)
  19. #implicitunits=exeinfo \
  20. # cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 \
  21. # cp437 cp646 cp737 cp775 cp850 cp852 cp855 cp856 cp857 cp860 cp861 cp862 \
  22. # cp863 cp864 cp865 cp866 cp869 cp874 cp3021 cp8859_1 cp8859_2 cp8859_3 cp8859_4 \
  23. # cp8859_5 cp8859_6 cp8859_7 cp8859_8 cp8859_9 cp8859_10 cp8859_11 \
  24. # cp8859_13 cp8859_14 cp8859_15 cp8859_16 cpkoi8_r cpkoi8_u
  25. #rsts=math rtlconsts varutils typinfo variants classes sysconst dateutil
  26. [require]
  27. nortl=y
  28. [install]
  29. fpcpackage=y
  30. [default]
  31. target=embedded
  32. [compiler]
  33. includedir=$(INC) $(PROCINC)
  34. sourcedir=$(INC) $(PROCINC) $(COMMON) $(ARCH)
  35. [prerules]
  36. RTL=..
  37. INC=$(RTL)/inc
  38. COMMON=$(RTL)/common
  39. PROCINC=$(RTL)/$(CPU_TARGET)
  40. UNITPREFIX=rtl
  41. SYSTEMUNIT=system
  42. LOADERS=
  43. ifeq ($(ARCH),mipsel)
  44. ifeq ($(SUBARCH),pic32mx)
  45. override LOADERS=startup
  46. endif
  47. endif
  48. ifdef RELEASE
  49. override FPCOPT+=-Ur
  50. endif
  51. # Always include rtl.cfg config file for i8086
  52. ifeq ($(ARCH),i8086)
  53. override [email protected]
  54. endif
  55. CPU_UNITS=
  56. SYSINIT_UNITS=
  57. CPU_SPECIFIC_COMMON_UNITS=
  58. ifeq ($(ARCH),aarch64)
  59. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
  60. CPU_UNITS=raspi3 mmio mailbox raspiuart gpio
  61. CPU_UNITS_DEFINED=1
  62. endif
  63. ifeq ($(ARCH),arm)
  64. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
  65. ifeq ($(SUBARCH),armv7m)
  66. CPU_UNITS=lm3fury lm3tempest stm32f10x_ld stm32f10x_md stm32f10x_hd stm32f10x_xl stm32f10x_conn stm32f10x_cl lpc13xx lpc1768 sam3x8e xmc4500 cortexm3 cortexm4 # thumb2_bare
  67. CPU_UNITS_DEFINED=1
  68. endif
  69. ifeq ($(SUBARCH),armv7em)
  70. CPU_UNITS=lm4f120 xmc4500 mk20d5 mk20d7 mk22f51212 mk64f12 stm32f401xx stm32f407xx stm32f411xe stm32f429xx stm32f446xx stm32f745 stm32f746 stm32f756 nrf52 cortexm3 cortexm4 cortexm7 \
  71. samd51p19a # thumb2_bare
  72. CPU_UNITS_DEFINED=1
  73. endif
  74. ifeq ($(SUBARCH),armv4t)
  75. CPU_UNITS=lpc21x4 at91sam7x256 sc32442b
  76. CPU_UNITS_DEFINED=1
  77. endif
  78. ifeq ($(SUBARCH),armv4)
  79. CPU_UNITS=lpc21x4 at91sam7x256 sc32442b
  80. CPU_UNITS_DEFINED=1
  81. endif
  82. ifeq ($(SUBARCH),armv6m)
  83. CPU_UNITS=lpc8xx lpc11xx lpc122x stm32f0xx nrf51 cortexm0
  84. CPU_UNITS_DEFINED=1
  85. endif
  86. ifeq ($(SUBARCH),armv7a)
  87. CPU_UNITS=allwinner_a20 raspi2
  88. CPU_UNITS_DEFINED=1
  89. endif
  90. ifeq ($(CPU_UNITS_DEFINED),)
  91. $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
  92. endif
  93. endif
  94. ifeq ($(ARCH),avr)
  95. CPU_SPECIFIC_COMMON_UNITS=intrinsics
  96. ifeq ($(SUBARCH),avrtiny)
  97. CPU_UNITS=attiny4 attiny5 attiny9 attiny10 attiny20 attiny40 attiny102 attiny104
  98. CPU_UNITS_DEFINED=1
  99. endif
  100. ifeq ($(SUBARCH),avr1)
  101. CPU_UNITS=attiny11 attiny12 attiny15 attiny28
  102. CPU_UNITS_DEFINED=1
  103. endif
  104. ifeq ($(SUBARCH),avr2)
  105. CPU_UNITS=attiny26
  106. CPU_UNITS_DEFINED=1
  107. endif
  108. ifeq ($(SUBARCH),avr25)
  109. CPU_UNITS=attiny13 attiny13a attiny24 attiny24a attiny25 attiny43u \
  110. attiny44 attiny44a attiny45 attiny48 attiny84a attiny84 attiny85 \
  111. attiny87 attiny88 attiny261 attiny261a attiny441 attiny461 attiny461a attiny828 \
  112. attiny841 attiny861 attiny861a attiny2313 attiny2313a attiny4313
  113. CPU_UNITS_DEFINED=1
  114. endif
  115. ifeq ($(SUBARCH),avr35)
  116. CPU_UNITS=at90usb82 at90usb162 atmega8u2 atmega16u2 atmega32u2 attiny167 attiny1634
  117. CPU_UNITS_DEFINED=1
  118. endif
  119. ifeq ($(SUBARCH),avr4)
  120. CPU_UNITS=at90pwm1 at90pwm2b at90pwm3b at90pwm81 ata6285 ata6286 atmega8 \
  121. atmega8a atmega8hva atmega48 atmega48a atmega48p atmega48pa \
  122. atmega48pb atmega88 atmega88a atmega88p atmega88pa atmega88pb \
  123. atmega8515 atmega8535
  124. CPU_UNITS_DEFINED=1
  125. endif
  126. ifeq ($(SUBARCH),avr5)
  127. CPU_UNITS=avrsim at90can32 at90can64 at90pwm161 at90pwm216 at90pwm316 \
  128. at90usb646 at90usb647 atmega16 atmega16a atmega16hva atmega16hvb atmega16hvbrevb atmega16m1 \
  129. atmega16u4 atmega32 atmega32a atmega32c1 atmega32hvb atmega32hvbrevb atmega32m1 \
  130. atmega32u4 atmega64 atmega64a atmega64c1 atmega64hve2 atmega64m1 atmega64rfr2 atmega162 \
  131. atmega164a atmega164p atmega164pa atmega165a atmega165p atmega165pa \
  132. atmega168 atmega168a atmega168p atmega168pa atmega168pb atmega169a atmega169p \
  133. atmega169pa atmega324a atmega324p atmega324pa atmega324pb atmega325 atmega325a \
  134. atmega325p atmega325pa atmega328 atmega328p atmega328pb atmega329 atmega329a \
  135. atmega329p atmega329pa atmega406 atmega640 atmega644 atmega644a atmega644p \
  136. atmega644pa atmega644rfr2 atmega645 atmega645a atmega645p atmega649 atmega649a \
  137. atmega649p atmega3250 atmega3250a atmega3250p atmega3250pa atmega3290 \
  138. atmega3290a atmega3290p atmega3290pa atmega6450 atmega6450a \
  139. atmega6450p atmega6490 atmega6490a atmega6490p
  140. CPU_UNITS_DEFINED=1
  141. endif
  142. ifeq ($(SUBARCH),avr51)
  143. CPU_UNITS=at90can128 at90usb1286 at90usb1287 atmega128 atmega128a atmega128rfa1 atmega128rfr2 \
  144. atmega1280 atmega1281 atmega1284 atmega1284p atmega1284rfr2
  145. CPU_UNITS_DEFINED=1
  146. endif
  147. ifeq ($(SUBARCH),avr6)
  148. CPU_UNITS=avrsim atmega256rfr2 atmega2560 atmega2561 atmega2564rfr2
  149. CPU_UNITS_DEFINED=1
  150. endif
  151. ifeq ($(SUBARCH),avrxmega3)
  152. CPU_UNITS=atmega808 atmega809 atmega1608 atmega1609 atmega3208 atmega3209 \
  153. atmega4808 atmega4809 attiny202 attiny204 attiny212 attiny214 \
  154. attiny402 attiny404 attiny406 attiny412 attiny414 attiny416 \
  155. attiny416auto attiny417 attiny804 attiny806 attiny807 attiny814 \
  156. attiny816 attiny817 attiny1604 attiny1606 attiny1607 attiny1614 \
  157. attiny1616 attiny1617 attiny1624 attiny1626 attiny1627 attiny3214 attiny3216 attiny3217
  158. CPU_UNITS_DEFINED=1
  159. endif
  160. ifeq ($(CPU_UNITS_DEFINED),)
  161. $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
  162. endif
  163. endif
  164. ifeq ($(ARCH),i386)
  165. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
  166. CPU_UNITS=multiboot
  167. CPU_UNITS_DEFINED=1
  168. ifeq ($(CPU_UNITS_DEFINED),)
  169. $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
  170. endif
  171. endif
  172. ifeq ($(ARCH),x86_64)
  173. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
  174. # CPU_UNITS=multiboot
  175. endif
  176. ifeq ($(ARCH),m68k)
  177. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
  178. # CPU_UNITS=multiboot
  179. endif
  180. ifeq ($(ARCH),mipsel)
  181. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
  182. ifeq ($(SUBARCH),pic32mx)
  183. CPU_UNITS=pic32mx1xxfxxxb pic32mx2xxfxxxb pic32mx1xxfxxxc pic32mx2xxfxxxc pic32mx1xxfxxxd pic32mx2xxfxxxd pic32mx7x5fxxxl pic32mx7x5fxxxh
  184. CPU_UNITS_DEFINED=1
  185. endif
  186. ifeq ($(CPU_UNITS_DEFINED),)
  187. $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
  188. endif
  189. endif
  190. ifeq ($(ARCH),riscv32)
  191. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
  192. ifeq ($(SUBARCH),rv32imac)
  193. override FPCOPT+=-Cprv32imac
  194. CPU_UNITS=fe310g000 fe310g002 gd32vf103xx
  195. CPU_UNITS_DEFINED=1
  196. endif
  197. ifeq ($(SUBARCH),rv32i)
  198. override FPCOPT+=-Cprv32i
  199. CPU_UNITS=
  200. CPU_UNITS_DEFINED=1
  201. endif
  202. ifeq ($(CPU_UNITS_DEFINED),)
  203. $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
  204. endif
  205. endif
  206. ifeq ($(ARCH),riscv64)
  207. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
  208. CPU_UNITS=
  209. CPU_UNITS_DEFINED=1
  210. ifeq ($(CPU_UNITS_DEFINED),)
  211. $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
  212. endif
  213. endif
  214. ifeq ($(ARCH),xtensa)
  215. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts lineinfo
  216. ifeq ($(SUBARCH),lx106)
  217. CPU_UNITS=esp8266
  218. CPU_UNITS_DEFINED=1
  219. endif
  220. ifeq ($(CPU_UNITS_DEFINED),)
  221. $(error No CPUs enabled for given SUBARCH, pass either a SUBARCH or set CPU_UNITS_DEFINED=1 if you know what you are doing)
  222. endif
  223. endif
  224. ifeq ($(ARCH),wasm32)
  225. CPU_SPECIFIC_COMMON_UNITS=sysutils math classes fgl macpas typinfo types rtlconsts getopts
  226. # lineinfo
  227. endif
  228. # Paths
  229. OBJPASDIR=$(RTL)/objpas
  230. GRAPHDIR=$(INC)/graph
  231. [rules]
  232. # .NOTPARALLEL:
  233. # Get the system independent include file names.
  234. # This will set the following variables :
  235. # SYSINCNAMES
  236. include $(INC)/makefile.inc
  237. SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
  238. # Get the processor dependent include file names.
  239. # This will set the following variables :
  240. # CPUINCNAMES
  241. include $(PROCINC)/makefile.cpu
  242. SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
  243. # Put system unit dependencies together.
  244. SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
  245. #
  246. # Loaders
  247. #
  248. startup$(OEXT) : $(CPU_TARGET)/startup.s
  249. $(AS) $(ASTARGET) -o $(UNITTARGETDIRPREFIX)startup$(OEXT) $(CPU_TARGET)/startup.s -mabi=32 -march=pic32mx -mtune=pic32mx -W -EL -msym32
  250. #
  251. # Base Units (System, strings, os-dependent-base-unit)
  252. #
  253. $(SYSTEMUNIT)$(PPUEXT) : $(SYSTEMUNIT).pp $(SYSDEPS) $(INC)/softfpu.pp
  254. $(COMPILER) $(FPC_SYSTEM_OPT) -Us -Sg $(SYSTEMUNIT).pp @system.cfg $(REDIR)
  255. consoleio$(PPUEXT) : consoleio.pp $(SYSTEMUNIT)$(PPUEXT)
  256. $(COMPILER) $<
  257. heapmgr$(PPUEXT) : heapmgr.pp $(SYSTEMUNIT)$(PPUEXT)
  258. $(COMPILER) $<
  259. #
  260. # Unit specific rules
  261. #
  262. define CPU_UNITS_RULE
  263. ifeq ($(ARCH),avr)
  264. $(1)$(PPUEXT): $(ARCH)/$(1).pp intrinsics$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
  265. else
  266. $(1)$(PPUEXT): $(ARCH)/$(1).pp $(SYSTEMUNIT)$(PPUEXT)
  267. endif
  268. endef
  269. $(foreach unit,$(CPU_UNITS),$(eval $(call CPU_UNITS_RULE,$(unit))))
  270. $(addsuffix $(PPUEXT),$(CPU_UNITS)):
  271. $(COMPILER) -g $<
  272. # AVR specific units
  273. avrsim$(PPUEXT): $(ARCH)/avrsim.pp heapmgr$(PPUEXT) consoleio$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
  274. $(COMPILER) $(ARCH)/avrsim.pp
  275. # ARM specific units
  276. raspi2$(PPUEXT): $(ARCH)/raspi2.pp consoleio$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
  277. $(COMPILER) $(ARCH)/raspi2.pp
  278. # AARCH64 specific units
  279. raspi3$(PPUEXT): $(ARCH)/raspi3.pp consoleio$(PPUEXT) mmio$(PPUEXT) mailbox$(PPUEXT) raspiuart$(PPUEXT) gpio$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
  280. $(COMPILER) $(ARCH)/raspi3.pp
  281. raspiuart$(PPUEXT): $(ARCH)/raspiuart.pp mmio$(PPUEXT) mailbox$(PPUEXT) gpio$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
  282. $(COMPILER) $(ARCH)/raspiuart.pp
  283. mailbox$(PPUEXT): $(ARCH)/mailbox.pp mmio$(PPUEXT) $(SYSTEMUNIT)$(PPUEXT)
  284. $(COMPILER) $(ARCH)/mailbox.pp