Makefile.fpc 9.3 KB

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