Makefile.fpc 8.9 KB

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