Makefile.fpc 8.7 KB

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