Makefile.fpc 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. #
  2. # Makefile.fpc for Free Pascal Source Tree
  3. #
  4. [package]
  5. name=fpc
  6. version=3.1.1
  7. [target]
  8. dirs=compiler rtl utils packages ide installer
  9. [require]
  10. nortl=y
  11. [install]
  12. fpcpackage=y
  13. [default]
  14. fpcdir=.
  15. rule=help
  16. [prerules]
  17. REQUIREDVERSION=2.6.4
  18. # Accept 3.0.0, without requiring to using OVERRIDEVERSIONCHECK=1
  19. # 3.0.0 should become REQUIREDVERSION after 3.0.0 final release
  20. # and 2.6.4 should be moved to REQUIREDVERSION2
  21. REQUIREDVERSION2=3.0.0
  22. # make versions < 3.77 (OS2 version) are buggy
  23. ifndef inOS2
  24. override FPCDIR:=$(BASEDIR)
  25. export FPCDIR
  26. endif
  27. # Build dir
  28. ifndef BUILDDIR
  29. BUILDDIR=$(BASEDIR)/build
  30. endif
  31. # New ppc386 (or ppc68k if on m68k machine !)
  32. ifndef PPNEW
  33. ifeq ($(CPU_TARGET),m68k)
  34. PPSUF=68k
  35. endif
  36. ifeq ($(CPU_TARGET),i386)
  37. PPSUF=386
  38. endif
  39. ifeq ($(CPU_TARGET),x86_64)
  40. PPSUF=x64
  41. endif
  42. ifeq ($(CPU_TARGET),sparc)
  43. PPSUF=sparc
  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. # Compile also IDE (check for ide and fv dir)
  176. # Skipped by default for cross compiles, because it depends on libc
  177. ifndef CROSSCOMPILE
  178. ifneq ($(wildcard ide),)
  179. IDETARGETS=go32v2 win32 win64 linux freebsd os2 emx beos haiku
  180. ifneq ($(findstring $(OS_TARGET),$(IDETARGETS)),)
  181. IDE=1
  182. endif
  183. endif
  184. endif
  185. # CPU targets for which we only build the compiler/rtl
  186. BuildOnlyBaseCPUs=jvm
  187. ifneq ($(wildcard utils),)
  188. NOUTILSTARGETS=embedded gba nds msdos win16 $(BuildOnlyBaseCPUs)
  189. ifeq ($(findstring $(OS_TARGET),$(NOUTILSTARGETS)),)
  190. ifdef BUILDFULLNATIVE
  191. UTILS=1
  192. endif
  193. endif
  194. endif
  195. [rules]
  196. .NOTPARALLEL:
  197. # These values can change
  198. unexport FPC_VERSION FPC_COMPILERINFO OS_SOURCE
  199. # Only process directories that really exists
  200. override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))
  201. #####################################################################
  202. # Main targets
  203. #####################################################################
  204. .PHONY: help
  205. help:
  206. @$(ECHO)
  207. @$(ECHO) Targets
  208. @$(ECHO) all Alias for build
  209. @$(ECHO) build Build a new compiler and all packages
  210. @$(ECHO) install Install newly build files
  211. @$(ECHO) zipinstall Create zip/tar of installed files
  212. @$(ECHO) singlezipinstall Alias for zipinstall
  213. @$(ECHO)
  214. @exit
  215. #####################################################################
  216. # Dependencies
  217. #####################################################################
  218. #######################################
  219. # Compiler
  220. #######################################
  221. .PHONY: compiler_cycle
  222. compiler_cycle:
  223. $(MAKE) -C compiler cycle
  224. ##########################################################################
  225. # Packaging
  226. ##########################################################################
  227. BUILDSTAMP=build-stamp.$(FULL_TARGET)
  228. .PHONY: all clean distclean build buildbase install installbase
  229. .PHONY: installother zipinstallbase zipinstallotherzipinstall
  230. .PHONY: singlezipinstall versioncheckstartingcompiler
  231. versioncheckstartingcompiler:
  232. ifndef CROSSCOMPILE
  233. ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
  234. ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
  235. ifndef OVERRIDEVERSIONCHECK
  236. $(error The only supported starting compiler version is $(REQUIREDVERSION). You are trying to build with $(FPC_VERSION).)
  237. else
  238. @$(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.
  239. endif
  240. endif
  241. endif
  242. endif
  243. ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
  244. all: versioncheckstartingcompiler build
  245. install: installall
  246. zipinstall: zipinstallall
  247. else
  248. all: versioncheckstartingcompiler buildbase
  249. install: installbase
  250. zipinstall: zipinstallbase
  251. endif
  252. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  253. -$(DEL) build-stamp.*
  254. -$(DEL) base.build-stamp.*
  255. distclean: clean
  256. build: $(BUILDSTAMP)
  257. $(BUILDSTAMP):
  258. # create new compiler
  259. $(MAKE) compiler_cycle RELEASE=1
  260. ifdef CROSSCOMPILE
  261. # Buld a new native fpcmake when cross-compiling.
  262. # Fresh native compiler and RTL are ready at this stage.
  263. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  264. endif
  265. # clean
  266. $(MAKE) rtl_clean $(CLEANOPTS)
  267. $(MAKE) packages_clean $(CLEANOPTS)
  268. ifdef UTILS
  269. $(MAKE) utils_clean $(CLEANOPTS)
  270. endif
  271. ifdef IDE
  272. $(MAKE) ide_clean $(CLEANOPTS)
  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 IDE
  282. $(MAKE) ide_all $(BUILDOPTS)
  283. $(MAKE) installer_all $(BUILDOPTS)
  284. endif
  285. $(ECHOREDIR) Build > $(BUILDSTAMP)
  286. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  287. buildbase: base.$(BUILDSTAMP)
  288. base.$(BUILDSTAMP):
  289. # create new compiler
  290. $(MAKE) compiler_cycle RELEASE=1
  291. ifdef CROSSCOMPILE
  292. # Buld a new native fpcmake when cross-compiling.
  293. # Fresh native compiler and RTL are ready at this stage.
  294. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  295. endif
  296. # clean
  297. $(MAKE) rtl_clean $(CLEANOPTS)
  298. # build everything
  299. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  300. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  301. installbase: base.$(BUILDSTAMP)
  302. # create dirs
  303. $(MKDIR) $(INSTALL_BASEDIR)
  304. $(MKDIR) $(INSTALL_BINDIR)
  305. # install compiler+rtl
  306. $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
  307. $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)
  308. installother:
  309. $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
  310. ifdef UTILS
  311. $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
  312. endif
  313. ifdef IDE
  314. $(MAKE) ide_$(INSTALLTARGET) $(BUILDOPTS)
  315. endif
  316. zipinstallbase:
  317. $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base $(INSTALLOPTS)
  318. zipinstallother:
  319. $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
  320. ifdef UTILS
  321. $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
  322. endif
  323. ifdef IDE
  324. $(MAKE) ide_zip$(INSTALLTARGET) $(INSTALLOPTS)
  325. endif
  326. installall: $(BUILDSTAMP)
  327. $(MAKE) installbase $(INSTALLOPTS)
  328. ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
  329. $(MAKE) installother $(INSTALLOPTS)
  330. endif
  331. singlezipinstall: zipinstallall
  332. zipinstallall: $(BUILDSTAMP)
  333. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)
  334. ##########################################################################
  335. # Cross installation (installation of cross compiler and units)
  336. ##########################################################################
  337. .PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall
  338. crossall:
  339. $(MAKE) all CROSSINSTALL=1
  340. crossinstall:
  341. $(MAKE) install CROSSINSTALL=1
  342. crosszipinstall:
  343. $(MAKE) zipinstall CROSSINSTALL=1
  344. crosssinglezipinstall:
  345. $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall ZIPNAME=fpc $(INSTALLOPTS)