Makefile.fpc 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. #
  2. # Makefile.fpc for Free Pascal Source Tree
  3. #
  4. [package]
  5. name=fpc
  6. version=3.2.4-rc1
  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)' 'FPCMAKEOPT=$(OPT)'
  174. ifdef CROSSCOMPILE
  175. ifneq ($(CROSSASPROG),)
  176. BUILDOPTS+=ASPROG=$(CROSSASPROG)
  177. endif
  178. ifneq ($(CROSSASTARGET),)
  179. BUILDOPTS+=ASTARGET=$(CROSSASTARGET)
  180. endif
  181. endif
  182. INSTALLOPTS=FPC=$(PPNEW) ZIPDESTDIR=$(BASEDIR) FPCMAKE=$(FPCMAKENEW)
  183. # CPU targets for which we only build the compiler/rtl
  184. BuildOnlyBaseCPUs=jvm
  185. ifneq ($(wildcard utils),)
  186. NOUTILSTARGETS=embedded gba nds msdos win16 macosclassic $(BuildOnlyBaseCPUs)
  187. ifeq ($(findstring $(OS_TARGET),$(NOUTILSTARGETS)),)
  188. ifdef BUILDFULLNATIVE
  189. UTILS=1
  190. endif
  191. endif
  192. endif
  193. INSTALLERTARGETS=emx go32v2 msdos os2
  194. ifneq ($(findstring $(OS_TARGET),$(INSTALLERTARGETS)),)
  195. INSTALLER=1
  196. endif
  197. [rules]
  198. .NOTPARALLEL:
  199. # These values can change
  200. unexport FPC_VERSION FPC_COMPILERINFO OS_SOURCE
  201. # Only process directories that really exists
  202. override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))
  203. #####################################################################
  204. # Main targets
  205. #####################################################################
  206. .PHONY: help
  207. help:
  208. @$(ECHO)
  209. @$(ECHO) Targets
  210. @$(ECHO) all Build a new compiler and all packages
  211. @$(ECHO) install Install newly build files
  212. @$(ECHO) zipinstall Create zip/tar of installed files
  213. @$(ECHO) singlezipinstall Alias for zipinstall
  214. @$(ECHO)
  215. @exit
  216. #####################################################################
  217. # Dependencies
  218. #####################################################################
  219. #######################################
  220. # Compiler
  221. #######################################
  222. .PHONY: compiler_cycle
  223. compiler_cycle:
  224. $(MAKE) -C compiler cycle
  225. ##########################################################################
  226. # Packaging
  227. ##########################################################################
  228. BUILDSTAMP=build-stamp.$(FULL_TARGET)
  229. .PHONY: all clean distclean build buildbase install installbase
  230. .PHONY: installother zipinstallbase zipinstallotherzipinstall
  231. .PHONY: singlezipinstall versioncheckstartingcompiler
  232. versioncheckstartingcompiler:
  233. ifndef CROSSCOMPILE
  234. ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
  235. ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
  236. ifndef OVERRIDEVERSIONCHECK
  237. $(error The only supported starting compiler version is $(REQUIREDVERSION). You are trying to build with $(FPC_VERSION).)
  238. else
  239. @$(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.
  240. endif
  241. endif
  242. endif
  243. endif
  244. ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
  245. all: versioncheckstartingcompiler build
  246. install: installall
  247. zipinstall: zipinstallall
  248. else
  249. all: versioncheckstartingcompiler buildbase
  250. install: installbase
  251. zipinstall: zipinstallbase
  252. endif
  253. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  254. -$(DEL) build-stamp.*
  255. -$(DEL) base.build-stamp.*
  256. distclean: clean
  257. build: $(BUILDSTAMP)
  258. $(BUILDSTAMP):
  259. # create new compiler
  260. $(MAKE) compiler_cycle RELEASE=1
  261. ifdef CROSSCOMPILE
  262. # Buld a new native fpcmake when cross-compiling.
  263. # Fresh native compiler and RTL are ready at this stage.
  264. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  265. endif
  266. # clean
  267. $(MAKE) rtl_clean $(CLEANOPTS)
  268. $(MAKE) packages_clean $(CLEANOPTS)
  269. ifdef UTILS
  270. $(MAKE) utils_clean $(CLEANOPTS)
  271. endif
  272. ifdef INSTALLER
  273. $(MAKE) installer_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. ifdef INSTALLER
  282. $(MAKE) installer_all $(BUILDOPTS)
  283. endif
  284. $(ECHOREDIR) Build > $(BUILDSTAMP)
  285. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  286. buildbase: base.$(BUILDSTAMP)
  287. base.$(BUILDSTAMP):
  288. # create new compiler
  289. $(MAKE) compiler_cycle RELEASE=1
  290. ifdef CROSSCOMPILE
  291. # Buld a new native fpcmake when cross-compiling.
  292. # Fresh native compiler and RTL are ready at this stage.
  293. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  294. endif
  295. # clean
  296. $(MAKE) rtl_clean $(CLEANOPTS)
  297. # build everything
  298. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  299. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  300. installbase: base.$(BUILDSTAMP)
  301. # create dirs
  302. $(MKDIR) $(INSTALL_BASEDIR)
  303. $(MKDIR) $(INSTALL_BINDIR)
  304. # install compiler+rtl
  305. $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
  306. $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)
  307. installother:
  308. $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
  309. ifdef UTILS
  310. $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
  311. endif
  312. zipinstallbase:
  313. $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base $(INSTALLOPTS)
  314. zipinstallother:
  315. $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
  316. ifdef UTILS
  317. $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
  318. endif
  319. installall: $(BUILDSTAMP)
  320. $(MAKE) installbase $(INSTALLOPTS)
  321. ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
  322. $(MAKE) installother $(INSTALLOPTS)
  323. endif
  324. singlezipinstall: zipinstallall
  325. zipinstallall: $(BUILDSTAMP)
  326. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)
  327. ##########################################################################
  328. # Cross installation (installation of cross compiler and units)
  329. ##########################################################################
  330. .PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall
  331. crossall:
  332. $(MAKE) all CROSSINSTALL=1
  333. crossinstall:
  334. $(MAKE) install CROSSINSTALL=1
  335. crosszipinstall:
  336. $(MAKE) zipinstall CROSSINSTALL=1
  337. crosssinglezipinstall:
  338. $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall ZIPNAME=fpc $(INSTALLOPTS)