Makefile.fpc 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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. # cross compilers uses full cpu_target, not just ppc-suffix
  94. # (except if the target cannot run a native compiler)
  95. ifdef CROSSCOMPILE
  96. ifneq ($(CPU_TARGET),jvm)
  97. PPPRE=ppcross
  98. else
  99. PPPRE=ppc
  100. endif
  101. else
  102. PPPRE=ppc
  103. endif
  104. PPNEW=$(BASEDIR)/compiler/$(PPPRE)$(PPSUF)$(SRCEXEEXT)
  105. endif
  106. # Use FPCFPMAKENEW to explicitly specify FPCFPMAKE.
  107. # Otherwise fpmkunit build will use wrong (starting) compiler
  108. # if there has been no compiler binary available in the compiler
  109. # dir before running make.
  110. ifndef FPCFPMAKENEW
  111. ifdef CROSSCOMPILE
  112. FPCFPMAKENEW=$(BASEDIR)/compiler/ppc$(SRCEXEEXT)
  113. else
  114. FPCFPMAKENEW=$(PPNEW)
  115. endif
  116. endif
  117. # Check if install/ subdir is available
  118. ifneq ($(wildcard install),)
  119. CVSINSTALL=install
  120. else
  121. CVSINSTALL=.
  122. endif
  123. # Install target, for snapshots we don't install examples.
  124. # Cross installation only needs the .ppu files
  125. ifdef SNAPSHOT
  126. INSTALLTARGET=install
  127. else
  128. ifdef CROSSINSTALL
  129. INSTALLTARGET=install
  130. else
  131. INSTALLTARGET=distinstall
  132. endif
  133. endif
  134. # All target
  135. ifdef SNAPSHOT
  136. ALLTARGET=all
  137. else
  138. ifndef ALLTARGET
  139. SHAREDTARGETS=
  140. SMARTTARGETS=win32 go32v2 linux freebsd netbsd openbsd netware netwlibc darwin
  141. ifneq ($(findstring $(OS_TARGET),$(SHAREDTARGETS)),)
  142. ALLTARGET=shared
  143. else
  144. ifneq ($(findstring $(OS_TARGET),$(SMARTTARGETS)),)
  145. ALLTARGET=smart
  146. else
  147. ALLTARGET=all
  148. endif
  149. endif
  150. endif
  151. endif
  152. # Prefix for units
  153. ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
  154. PKGUNITSPRE=u
  155. else
  156. PKGUNITSPRE=units-
  157. endif
  158. # Cross compile needs a prefix to not conflict with original packages
  159. ifdef CROSSINSTALL
  160. PKGPRE=$(FULL_TARGET)-
  161. else
  162. PKGPRE=
  163. endif
  164. # Always compile for release
  165. override RELEASE=1
  166. export RELEASE
  167. # We want to have the resulting .zips in the current dir
  168. ifndef DIST_DESTDIR
  169. export DIST_DESTDIR:=$(BASEDIR)
  170. endif
  171. # Temporary path to pack a file
  172. BASEPACKDIR=$(BASEDIR)/basepack
  173. # Always use newly created fpcmake
  174. ifndef FPCMAKENEW
  175. ifdef CROSSCOMPILE
  176. # Use bootstrapped fpcmake when cross-compiling
  177. FPCMAKENEW=$(BASEDIR)/utils/fpcm/fpcmake$(SRCEXEEXT)
  178. else
  179. # Use normal fpcmake
  180. FPCMAKENEW=$(BASEDIR)/utils/fpcm/bin/$(SOURCESUFFIX)/fpcmake$(SRCEXEEXT)
  181. endif
  182. endif
  183. # Build/install options
  184. ifneq ($(OPT),)
  185. OPTNEW+=$(OPT)
  186. endif
  187. # some targets do not generate PIC by default so we have select explicitly
  188. # the general threading model when compiling the final versions of rtl and packages
  189. ifneq ($(findstring $(OS_TARGET),linux),)
  190. ifneq ($(findstring $(CPU_TARGET),i386 arm),)
  191. override OPTNEW+=-CVglobal-dynamic
  192. endif
  193. endif
  194. CLEANOPTS=FPC=$(PPNEW)
  195. BUILDOPTS=FPC=$(PPNEW) FPCFPMAKE=$(FPCFPMAKENEW) RELEASE=1 'OPT=$(OPTNEW)' 'FPCMAKEOPT=$(OPT)'
  196. INSTALLOPTS=FPC=$(PPNEW) ZIPDESTDIR=$(BASEDIR) FPCMAKE=$(FPCMAKENEW)
  197. # CPU targets for which we only build the compiler/rtl
  198. BuildOnlyBaseCPUs=jvm
  199. ifneq ($(wildcard utils),)
  200. NOUTILSTARGETS=embedded gba nds msdos win16 macosclassic $(BuildOnlyBaseCPUs) freertos
  201. ifeq ($(findstring $(OS_TARGET),$(NOUTILSTARGETS)),)
  202. ifdef BUILDFULLNATIVE
  203. UTILS=1
  204. endif
  205. endif
  206. endif
  207. INSTALLERTARGETS=emx go32v2 msdos os2
  208. ifneq ($(findstring $(OS_TARGET),$(INSTALLERTARGETS)),)
  209. INSTALLER=1
  210. endif
  211. [rules]
  212. # These values can change
  213. unexport FPC_VERSION FPC_COMPILERINFO OS_SOURCE
  214. # Only process directories that really exists
  215. override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))
  216. #####################################################################
  217. # Main targets
  218. #####################################################################
  219. .PHONY: help
  220. help:
  221. @$(ECHO)
  222. @$(ECHO) Targets
  223. @$(ECHO) all Build a new compiler and all packages
  224. @$(ECHO) install Install newly build files
  225. @$(ECHO) zipinstall Create zip/tar of installed files
  226. @$(ECHO) singlezipinstall Alias for zipinstall
  227. @$(ECHO)
  228. @exit
  229. #####################################################################
  230. # Dependencies
  231. #####################################################################
  232. #######################################
  233. # Compiler
  234. #######################################
  235. .PHONY: compiler_cycle
  236. compiler_cycle:
  237. $(MAKE) -C compiler cycle
  238. ##########################################################################
  239. # Packaging
  240. ##########################################################################
  241. BUILDSTAMP=build-stamp.$(FULL_TARGET)
  242. .PHONY: all clean distclean build buildbase install installbase
  243. .PHONY: installother zipinstallbase zipinstallotherzipinstall
  244. .PHONY: singlezipinstall versioncheckstartingcompiler
  245. versioncheckstartingcompiler:
  246. ifndef CROSSCOMPILE
  247. ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
  248. ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
  249. ifndef OVERRIDEVERSIONCHECK
  250. $(error The only supported starting compiler version is $(REQUIREDVERSION). You are trying to build with $(FPC_VERSION).)
  251. else
  252. @$(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.
  253. endif
  254. endif
  255. endif
  256. endif
  257. ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
  258. all: versioncheckstartingcompiler build
  259. install: installall
  260. zipinstall: zipinstallall
  261. else
  262. all: versioncheckstartingcompiler buildbase
  263. install: installbase
  264. zipinstall: zipinstallbase
  265. endif
  266. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  267. -$(DEL) build-stamp.*
  268. -$(DEL) base.build-stamp.*
  269. distclean: clean
  270. build: $(BUILDSTAMP)
  271. $(BUILDSTAMP):
  272. # create new compiler
  273. $(MAKE) compiler_cycle RELEASE=1
  274. ifdef CROSSCOMPILE
  275. # Buld a new native fpcmake when cross-compiling.
  276. # Fresh native compiler and RTL are ready at this stage.
  277. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  278. endif
  279. # clean
  280. $(MAKE) rtl_clean $(CLEANOPTS)
  281. $(MAKE) packages_clean $(CLEANOPTS)
  282. ifdef UTILS
  283. $(MAKE) utils_clean $(CLEANOPTS)
  284. endif
  285. ifdef INSTALLER
  286. $(MAKE) installer_clean $(CLEANOPTS)
  287. endif
  288. # build everything
  289. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  290. $(MAKE) packages_$(ALLTARGET) $(BUILDOPTS)
  291. ifdef UTILS
  292. $(MAKE) utils_all $(BUILDOPTS)
  293. endif
  294. ifdef INSTALLER
  295. $(MAKE) installer_all $(BUILDOPTS)
  296. endif
  297. $(ECHOREDIR) Build > $(BUILDSTAMP)
  298. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  299. buildbase: base.$(BUILDSTAMP)
  300. base.$(BUILDSTAMP):
  301. # create new compiler
  302. $(MAKE) compiler_cycle RELEASE=1
  303. ifdef CROSSCOMPILE
  304. # Buld a new native fpcmake when cross-compiling.
  305. # Fresh native compiler and RTL are ready at this stage.
  306. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  307. endif
  308. # clean
  309. $(MAKE) rtl_clean $(CLEANOPTS)
  310. # build everything
  311. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  312. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  313. installbase: base.$(BUILDSTAMP)
  314. # create dirs
  315. $(MKDIR) $(INSTALL_BASEDIR)
  316. $(MKDIR) $(INSTALL_BINDIR)
  317. # install compiler+rtl
  318. $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
  319. $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)
  320. installother:
  321. $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
  322. ifdef UTILS
  323. $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
  324. endif
  325. zipinstallbase:
  326. $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base $(INSTALLOPTS)
  327. zipinstallother:
  328. $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
  329. ifdef UTILS
  330. $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
  331. endif
  332. installall: $(BUILDSTAMP)
  333. $(MAKE) installbase $(INSTALLOPTS)
  334. ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
  335. $(MAKE) installother $(INSTALLOPTS)
  336. endif
  337. singlezipinstall: zipinstallall
  338. zipinstallall: $(BUILDSTAMP)
  339. ifeq ($(FULL_SOURCE),$(FULL_TARGET))
  340. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)
  341. else
  342. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX).built.on.$(SOURCESUFFIX) $(INSTALLOPTS)
  343. endif
  344. ##########################################################################
  345. # Cross installation (installation of cross compiler and units)
  346. ##########################################################################
  347. .PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall
  348. crossall:
  349. $(MAKE) all CROSSINSTALL=1
  350. crossinstall:
  351. $(MAKE) install CROSSINSTALL=1
  352. crosszipinstall:
  353. $(MAKE) zipinstall CROSSINSTALL=1
  354. crosssinglezipinstall:
  355. $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(SOURCESUFFIX).cross.$(TARGETSUFFIX) $(INSTALLOPTS)