2
0

Makefile.fpc 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. #
  2. # Makefile.fpc for Free Pascal Source Tree
  3. #
  4. [package]
  5. name=fpc
  6. version=3.3.1
  7. [target]
  8. dirs=compiler rtl utils packages installer
  9. [require]
  10. nortl=y
  11. [install]
  12. fpcpackage=y
  13. [default]
  14. fpcdir=.
  15. rule=help
  16. [prerules]
  17. REQUIREDVERSION=3.2.2
  18. REQUIREDVERSION2=3.2.0
  19. # make versions < 3.77 (OS2 version) are buggy
  20. ifndef inOS2
  21. override FPCDIR:=$(BASEDIR)
  22. export FPCDIR
  23. endif
  24. # Build dir
  25. ifndef BUILDDIR
  26. BUILDDIR=$(BASEDIR)/build
  27. endif
  28. # New ppc386 (or ppc68k if on m68k machine !)
  29. ifndef PPNEW
  30. ifeq ($(CPU_TARGET),m68k)
  31. PPSUF=68k
  32. endif
  33. ifeq ($(CPU_TARGET),i386)
  34. PPSUF=386
  35. endif
  36. ifeq ($(CPU_TARGET),x86_64)
  37. PPSUF=x64
  38. endif
  39. ifeq ($(CPU_TARGET),sparc)
  40. PPSUF=sparc
  41. endif
  42. ifeq ($(CPU_TARGET),sparc64)
  43. PPSUF=sparc64
  44. endif
  45. ifeq ($(CPU_TARGET),powerpc)
  46. PPSUF=ppc
  47. endif
  48. ifeq ($(CPU_TARGET),powerpc64)
  49. PPSUF=ppc64
  50. endif
  51. ifeq ($(CPU_TARGET),alpha)
  52. PPSUF=axp
  53. endif
  54. ifeq ($(CPU_TARGET),arm)
  55. PPSUF=arm
  56. endif
  57. ifeq ($(CPU_TARGET),armeb)
  58. PPSUF=arm
  59. endif
  60. ifeq ($(CPU_TARGET),jvm)
  61. PPSUF=jvm
  62. endif
  63. ifeq ($(CPU_TARGET),mips)
  64. PPSUF=mips
  65. endif
  66. ifeq ($(CPU_TARGET),mipsel)
  67. PPSUF=mipsel
  68. endif
  69. ifeq ($(CPU_TARGET),i8086)
  70. PPSUF=8086
  71. endif
  72. ifeq ($(CPU_TARGET),avr)
  73. PPSUF=avr
  74. endif
  75. ifeq ($(CPU_TARGET),aarch64)
  76. PPSUF=a64
  77. endif
  78. ifeq ($(CPU_TARGET),riscv32)
  79. PPSUF=rv32
  80. endif
  81. ifeq ($(CPU_TARGET),riscv64)
  82. PPSUF=rv64
  83. endif
  84. ifeq ($(CPU_TARGET),xtensa)
  85. PPSUF=xtensa
  86. endif
  87. ifeq ($(CPU_TARGET),z80)
  88. PPSUF=z80
  89. endif
  90. ifeq ($(CPU_TARGET),wasm32)
  91. PPSUF=wasm32
  92. endif
  93. ifeq ($(CPU_TARGET),loongarch64)
  94. PPSUF=loongarch64
  95. endif
  96. # cross compilers uses full cpu_target, not just ppc-suffix
  97. # (except if the target cannot run a native compiler)
  98. ifdef CROSSCOMPILE
  99. ifneq ($(CPU_TARGET),jvm)
  100. PPPRE=ppcross
  101. else
  102. PPPRE=ppc
  103. endif
  104. else
  105. PPPRE=ppc
  106. endif
  107. PPNEW=$(BASEDIR)/compiler/$(PPPRE)$(PPSUF)$(SRCEXEEXT)
  108. endif
  109. # Use FPCFPMAKENEW to explicitly specify FPCFPMAKE.
  110. # Otherwise fpmkunit build will use wrong (starting) compiler
  111. # if there has been no compiler binary available in the compiler
  112. # dir before running make.
  113. ifndef FPCFPMAKENEW
  114. ifdef CROSSCOMPILE
  115. FPCFPMAKENEW=$(BASEDIR)/compiler/ppc$(SRCEXEEXT)
  116. else
  117. FPCFPMAKENEW=$(PPNEW)
  118. endif
  119. endif
  120. # Check if install/ subdir is available
  121. ifneq ($(wildcard install),)
  122. CVSINSTALL=install
  123. else
  124. CVSINSTALL=.
  125. endif
  126. # Install target, for snapshots we don't install examples.
  127. # Cross installation only needs the .ppu files
  128. ifdef SNAPSHOT
  129. INSTALLTARGET=install
  130. else
  131. ifdef CROSSINSTALL
  132. INSTALLTARGET=install
  133. else
  134. INSTALLTARGET=distinstall
  135. endif
  136. endif
  137. # All target
  138. ifdef SNAPSHOT
  139. ALLTARGET=all
  140. else
  141. ifndef ALLTARGET
  142. SHAREDTARGETS=
  143. SMARTTARGETS=win32 go32v2 linux freebsd netbsd openbsd netware netwlibc darwin
  144. ifneq ($(findstring $(OS_TARGET),$(SHAREDTARGETS)),)
  145. ALLTARGET=shared
  146. else
  147. ifneq ($(findstring $(OS_TARGET),$(SMARTTARGETS)),)
  148. ALLTARGET=smart
  149. else
  150. ALLTARGET=all
  151. endif
  152. endif
  153. endif
  154. endif
  155. # Prefix for units
  156. ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
  157. PKGUNITSPRE=u
  158. else
  159. PKGUNITSPRE=units-
  160. endif
  161. # Cross compile needs a prefix to not conflict with original packages
  162. ifdef CROSSINSTALL
  163. PKGPRE=$(FULL_TARGET)-
  164. else
  165. PKGPRE=
  166. endif
  167. # Always compile for release
  168. override RELEASE=1
  169. export RELEASE
  170. # We want to have the resulting .zips in the current dir
  171. ifndef DIST_DESTDIR
  172. export DIST_DESTDIR:=$(BASEDIR)
  173. endif
  174. # Temporary path to pack a file
  175. BASEPACKDIR=$(BASEDIR)/basepack
  176. # Always use newly created fpcmake
  177. ifndef FPCMAKENEW
  178. ifdef CROSSCOMPILE
  179. # Use bootstrapped fpcmake when cross-compiling
  180. FPCMAKENEW=$(BASEDIR)/utils/fpcm/fpcmake$(SRCEXEEXT)
  181. else
  182. # Use normal fpcmake
  183. FPCMAKENEW=$(BASEDIR)/utils/fpcm/bin/$(SOURCESUFFIX)/fpcmake$(SRCEXEEXT)
  184. endif
  185. endif
  186. # Build/install options
  187. ifneq ($(OPT),)
  188. OPTNEW+=$(OPT)
  189. endif
  190. # some targets do not generate PIC by default so we have select explicitly
  191. # the general threading model when compiling the final versions of rtl and packages
  192. ifneq ($(findstring $(OS_TARGET),linux),)
  193. ifneq ($(findstring $(CPU_TARGET),i386 arm),)
  194. override OPTNEW+=-CVglobal-dynamic
  195. endif
  196. endif
  197. CLEANOPTS=FPC=$(PPNEW)
  198. BUILDOPTS=FPC=$(PPNEW) FPCFPMAKE=$(FPCFPMAKENEW) RELEASE=1 'OPT=$(OPTNEW)' 'FPCMAKEOPT=$(OPT)'
  199. ifdef CROSSCOMPILE
  200. ifneq ($(CROSSASPROG),)
  201. BUILDOPTS+=ASPROG=$(CROSSASPROG)
  202. endif
  203. ifneq ($(CROSSASTARGET),)
  204. BUILDOPTS+=ASTARGET=$(CROSSASTARGET)
  205. endif
  206. endif
  207. INSTALLOPTS=FPC=$(PPNEW) ZIPDESTDIR=$(BASEDIR) FPCMAKE=$(FPCMAKENEW)
  208. # CPU targets for which we only build the compiler/rtl
  209. BuildOnlyBaseCPUs=jvm
  210. ifneq ($(wildcard utils),)
  211. NOUTILSTARGETS=embedded gba nds msdos win16 macosclassic $(BuildOnlyBaseCPUs) freertos
  212. ifeq ($(findstring $(OS_TARGET),$(NOUTILSTARGETS)),)
  213. ifdef BUILDFULLNATIVE
  214. UTILS=1
  215. endif
  216. endif
  217. endif
  218. INSTALLERTARGETS=emx go32v2 msdos os2
  219. ifneq ($(findstring $(OS_TARGET),$(INSTALLERTARGETS)),)
  220. INSTALLER=1
  221. endif
  222. [rules]
  223. # These values can change
  224. unexport FPC_VERSION FPC_COMPILERINFO OS_SOURCE
  225. # Only process directories that really exists
  226. override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))
  227. #####################################################################
  228. # Main targets
  229. #####################################################################
  230. .PHONY: help
  231. help:
  232. @$(ECHO)
  233. @$(ECHO) Targets
  234. @$(ECHO) all Build a new compiler and all packages
  235. @$(ECHO) install Install newly build files
  236. @$(ECHO) zipinstall Create zip/tar of installed files
  237. @$(ECHO) singlezipinstall Alias for zipinstall
  238. @$(ECHO)
  239. @exit
  240. #####################################################################
  241. # Dependencies
  242. #####################################################################
  243. #######################################
  244. # Compiler
  245. #######################################
  246. .PHONY: compiler_cycle
  247. compiler_cycle:
  248. $(MAKE) -C compiler cycle
  249. ##########################################################################
  250. # Packaging
  251. ##########################################################################
  252. BUILDSTAMP=build-stamp.$(FULL_TARGET)
  253. .PHONY: all clean distclean build buildbase install installbase
  254. .PHONY: installother zipinstallbase zipinstallotherzipinstall
  255. .PHONY: singlezipinstall versioncheckstartingcompiler
  256. versioncheckstartingcompiler:
  257. ifndef CROSSCOMPILE
  258. ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
  259. ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
  260. ifndef OVERRIDEVERSIONCHECK
  261. $(error The only supported starting compiler version is $(REQUIREDVERSION). You are trying to build with $(FPC_VERSION).)
  262. else
  263. @$(ECHO) You have overriden the starting compiler versioncheck while using starting compiler version $(FPC_VERSION). This situation is not supported and strange things and errors may happen. Remove OVERRIDEVERSIONCHECK=1 to fix this.
  264. endif
  265. endif
  266. endif
  267. endif
  268. ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
  269. all: versioncheckstartingcompiler build
  270. install: installall
  271. zipinstall: zipinstallall
  272. else
  273. all: versioncheckstartingcompiler buildbase
  274. install: installbase
  275. zipinstall: zipinstallbase
  276. endif
  277. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  278. -$(DEL) build-stamp.*
  279. -$(DEL) base.build-stamp.*
  280. distclean: clean
  281. build: $(BUILDSTAMP)
  282. $(BUILDSTAMP):
  283. # create new compiler
  284. $(MAKE) compiler_cycle RELEASE=1
  285. ifdef CROSSCOMPILE
  286. # Buld a new native fpcmake when cross-compiling.
  287. # Fresh native compiler and RTL are ready at this stage.
  288. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  289. endif
  290. # clean
  291. $(MAKE) rtl_clean $(CLEANOPTS)
  292. $(MAKE) packages_clean $(CLEANOPTS)
  293. ifdef UTILS
  294. $(MAKE) utils_clean $(CLEANOPTS)
  295. endif
  296. ifdef INSTALLER
  297. $(MAKE) installer_clean $(CLEANOPTS)
  298. endif
  299. # build everything
  300. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  301. $(MAKE) packages_$(ALLTARGET) $(BUILDOPTS)
  302. ifdef UTILS
  303. $(MAKE) utils_all $(BUILDOPTS)
  304. endif
  305. ifdef INSTALLER
  306. $(MAKE) installer_all $(BUILDOPTS)
  307. endif
  308. $(ECHOREDIR) Build > $(BUILDSTAMP)
  309. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  310. buildbase: base.$(BUILDSTAMP)
  311. base.$(BUILDSTAMP):
  312. # create new compiler
  313. $(MAKE) compiler_cycle RELEASE=1
  314. ifdef CROSSCOMPILE
  315. # Buld a new native fpcmake when cross-compiling.
  316. # Fresh native compiler and RTL are ready at this stage.
  317. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  318. endif
  319. # clean
  320. $(MAKE) rtl_clean $(CLEANOPTS)
  321. # build everything
  322. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  323. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  324. installbase: base.$(BUILDSTAMP)
  325. # create dirs
  326. $(MKDIR) $(INSTALL_BASEDIR)
  327. $(MKDIR) $(INSTALL_BINDIR)
  328. # install compiler+rtl
  329. $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
  330. $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)
  331. installother:
  332. $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
  333. ifdef UTILS
  334. $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
  335. endif
  336. zipinstallbase:
  337. $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base $(INSTALLOPTS)
  338. zipinstallother:
  339. $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
  340. ifdef UTILS
  341. $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
  342. endif
  343. installall: $(BUILDSTAMP)
  344. $(MAKE) installbase $(INSTALLOPTS)
  345. ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
  346. $(MAKE) installother $(INSTALLOPTS)
  347. endif
  348. singlezipinstall: zipinstallall
  349. zipinstallall: $(BUILDSTAMP)
  350. ifeq ($(FULL_SOURCE),$(FULL_TARGET))
  351. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)
  352. else
  353. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX).built.on.$(SOURCESUFFIX) $(INSTALLOPTS)
  354. endif
  355. ##########################################################################
  356. # Cross installation (installation of cross compiler and units)
  357. ##########################################################################
  358. .PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall
  359. crossall:
  360. $(MAKE) all CROSSINSTALL=1
  361. crossinstall:
  362. $(MAKE) install CROSSINSTALL=1
  363. crosszipinstall:
  364. $(MAKE) zipinstall CROSSINSTALL=1
  365. crosssinglezipinstall:
  366. $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(SOURCESUFFIX).cross.$(TARGETSUFFIX) $(INSTALLOPTS)