Makefile.fpc 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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. INSTALLOPTS=FPC=$(PPNEW) ZIPDESTDIR=$(BASEDIR) FPCMAKE=$(FPCMAKENEW)
  200. # CPU targets for which we only build the compiler/rtl
  201. BuildOnlyBaseCPUs=jvm
  202. ifneq ($(wildcard utils),)
  203. NOUTILSTARGETS=embedded gba nds msdos win16 macosclassic $(BuildOnlyBaseCPUs) freertos
  204. ifeq ($(findstring $(OS_TARGET),$(NOUTILSTARGETS)),)
  205. ifdef BUILDFULLNATIVE
  206. UTILS=1
  207. endif
  208. endif
  209. endif
  210. INSTALLERTARGETS=emx go32v2 msdos os2
  211. ifneq ($(findstring $(OS_TARGET),$(INSTALLERTARGETS)),)
  212. INSTALLER=1
  213. endif
  214. [rules]
  215. # These values can change
  216. unexport FPC_VERSION FPC_COMPILERINFO OS_SOURCE
  217. # Only process directories that really exists
  218. override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))
  219. #####################################################################
  220. # Main targets
  221. #####################################################################
  222. .PHONY: help
  223. help:
  224. @$(ECHO)
  225. @$(ECHO) Targets
  226. @$(ECHO) all Build a new compiler and all packages
  227. @$(ECHO) install Install newly build files
  228. @$(ECHO) zipinstall Create zip/tar of installed files
  229. @$(ECHO) singlezipinstall Alias for zipinstall
  230. @$(ECHO)
  231. @exit
  232. #####################################################################
  233. # Dependencies
  234. #####################################################################
  235. #######################################
  236. # Compiler
  237. #######################################
  238. .PHONY: compiler_cycle
  239. compiler_cycle:
  240. $(MAKE) -C compiler cycle
  241. ##########################################################################
  242. # Packaging
  243. ##########################################################################
  244. BUILDSTAMP=build-stamp.$(FULL_TARGET)
  245. .PHONY: all clean distclean build buildbase install installbase
  246. .PHONY: installother zipinstallbase zipinstallotherzipinstall
  247. .PHONY: singlezipinstall versioncheckstartingcompiler
  248. versioncheckstartingcompiler:
  249. ifndef CROSSCOMPILE
  250. ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
  251. ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
  252. ifndef OVERRIDEVERSIONCHECK
  253. $(error The only supported starting compiler version is $(REQUIREDVERSION). You are trying to build with $(FPC_VERSION).)
  254. else
  255. @$(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.
  256. endif
  257. endif
  258. endif
  259. endif
  260. ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
  261. all: versioncheckstartingcompiler build
  262. install: installall
  263. zipinstall: zipinstallall
  264. else
  265. all: versioncheckstartingcompiler buildbase
  266. install: installbase
  267. zipinstall: zipinstallbase
  268. endif
  269. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  270. -$(DEL) build-stamp.*
  271. -$(DEL) base.build-stamp.*
  272. distclean: clean
  273. build: $(BUILDSTAMP)
  274. $(BUILDSTAMP):
  275. # create new compiler
  276. $(MAKE) compiler_cycle RELEASE=1
  277. ifdef CROSSCOMPILE
  278. # Buld a new native fpcmake when cross-compiling.
  279. # Fresh native compiler and RTL are ready at this stage.
  280. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  281. endif
  282. # clean
  283. $(MAKE) rtl_clean $(CLEANOPTS)
  284. $(MAKE) packages_clean $(CLEANOPTS)
  285. ifdef UTILS
  286. $(MAKE) utils_clean $(CLEANOPTS)
  287. endif
  288. ifdef INSTALLER
  289. $(MAKE) installer_clean $(CLEANOPTS)
  290. endif
  291. # build everything
  292. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  293. $(MAKE) packages_$(ALLTARGET) $(BUILDOPTS)
  294. ifdef UTILS
  295. $(MAKE) utils_all $(BUILDOPTS)
  296. endif
  297. ifdef INSTALLER
  298. $(MAKE) installer_all $(BUILDOPTS)
  299. endif
  300. $(ECHOREDIR) Build > $(BUILDSTAMP)
  301. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  302. buildbase: base.$(BUILDSTAMP)
  303. base.$(BUILDSTAMP):
  304. # create new compiler
  305. $(MAKE) compiler_cycle RELEASE=1
  306. ifdef CROSSCOMPILE
  307. # Buld a new native fpcmake when cross-compiling.
  308. # Fresh native compiler and RTL are ready at this stage.
  309. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  310. endif
  311. # clean
  312. $(MAKE) rtl_clean $(CLEANOPTS)
  313. # build everything
  314. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  315. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  316. installbase: base.$(BUILDSTAMP)
  317. # create dirs
  318. $(MKDIR) $(INSTALL_BASEDIR)
  319. $(MKDIR) $(INSTALL_BINDIR)
  320. # install compiler+rtl
  321. $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
  322. $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)
  323. installother:
  324. $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
  325. ifdef UTILS
  326. $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
  327. endif
  328. zipinstallbase:
  329. $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base $(INSTALLOPTS)
  330. zipinstallother:
  331. $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
  332. ifdef UTILS
  333. $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
  334. endif
  335. installall: $(BUILDSTAMP)
  336. $(MAKE) installbase $(INSTALLOPTS)
  337. ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
  338. $(MAKE) installother $(INSTALLOPTS)
  339. endif
  340. singlezipinstall: zipinstallall
  341. zipinstallall: $(BUILDSTAMP)
  342. ifeq ($(FULL_SOURCE),$(FULL_TARGET))
  343. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)
  344. else
  345. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX).built.on.$(SOURCESUFFIX) $(INSTALLOPTS)
  346. endif
  347. ##########################################################################
  348. # Cross installation (installation of cross compiler and units)
  349. ##########################################################################
  350. .PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall
  351. crossall:
  352. $(MAKE) all CROSSINSTALL=1
  353. crossinstall:
  354. $(MAKE) install CROSSINSTALL=1
  355. crosszipinstall:
  356. $(MAKE) zipinstall CROSSINSTALL=1
  357. crosssinglezipinstall:
  358. $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(SOURCESUFFIX).cross.$(TARGETSUFFIX) $(INSTALLOPTS)