Makefile.fpc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. #
  2. # Makefile.fpc for Free Pascal Source Tree
  3. #
  4. [package]
  5. name=fpc
  6. version=2.7.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.2
  18. REQUIREDVERSION2=2.6.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),powerpc)
  43. PPSUF=ppc
  44. endif
  45. ifeq ($(CPU_TARGET),powerpc64)
  46. PPSUF=ppc64
  47. endif
  48. ifeq ($(CPU_TARGET),alpha)
  49. PPSUF=axp
  50. endif
  51. ifeq ($(CPU_TARGET),arm)
  52. PPSUF=arm
  53. endif
  54. ifeq ($(CPU_TARGET),armeb)
  55. PPSUF=arm
  56. endif
  57. ifeq ($(CPU_TARGET),jvm)
  58. PPSUF=jvm
  59. endif
  60. ifeq ($(CPU_TARGET),mips)
  61. PPSUF=mips
  62. endif
  63. ifeq ($(CPU_TARGET),mipsel)
  64. PPSUF=mipsel
  65. endif
  66. ifeq ($(CPU_TARGET),i8086)
  67. PPSUF=8086
  68. endif
  69. # cross compilers uses full cpu_target, not just ppc-suffix
  70. # (except if the target cannot run a native compiler)
  71. ifdef CROSSCOMPILE
  72. ifneq ($(CPU_TARGET),jvm)
  73. PPPRE=ppcross
  74. else
  75. PPPRE=ppc
  76. endif
  77. else
  78. PPPRE=ppc
  79. endif
  80. PPNEW=$(BASEDIR)/compiler/$(PPPRE)$(PPSUF)$(SRCEXEEXT)
  81. endif
  82. # Use FPCFPMAKENEW to explicitly specify FPCFPMAKE.
  83. # Otherwise fpmkunit build will use wrong (starting) compiler
  84. # if there has been no compiler binary available in the compiler
  85. # dir before running make.
  86. ifndef FPCFPMAKENEW
  87. ifdef CROSSCOMPILE
  88. FPCFPMAKENEW=$(BASEDIR)/compiler/ppc$(SRCEXEEXT)
  89. else
  90. FPCFPMAKENEW=$(PPNEW)
  91. endif
  92. endif
  93. # Check if install/ subdir is available
  94. ifneq ($(wildcard install),)
  95. CVSINSTALL=install
  96. else
  97. CVSINSTALL=.
  98. endif
  99. # Install target, for snapshots we don't install examples.
  100. # Cross installation only needs the .ppu files
  101. ifdef SNAPSHOT
  102. INSTALLTARGET=install
  103. else
  104. ifdef CROSSINSTALL
  105. INSTALLTARGET=install
  106. else
  107. INSTALLTARGET=distinstall
  108. endif
  109. endif
  110. # All target
  111. ifdef SNAPSHOT
  112. ALLTARGET=all
  113. else
  114. ifndef ALLTARGET
  115. SHAREDTARGETS=
  116. SMARTTARGETS=win32 go32v2 linux freebsd netbsd openbsd netware netwlibc darwin
  117. ifneq ($(findstring $(OS_TARGET),$(SHAREDTARGETS)),)
  118. ALLTARGET=shared
  119. else
  120. ifneq ($(findstring $(OS_TARGET),$(SMARTTARGETS)),)
  121. ALLTARGET=smart
  122. else
  123. ALLTARGET=all
  124. endif
  125. endif
  126. endif
  127. endif
  128. # Prefix for units
  129. ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
  130. PKGUNITSPRE=u
  131. else
  132. PKGUNITSPRE=units-
  133. endif
  134. # Cross compile needs a prefix to not conflict with original packages
  135. ifdef CROSSINSTALL
  136. PKGPRE=$(FULL_TARGET)-
  137. else
  138. PKGPRE=
  139. endif
  140. # Always compile for release
  141. override RELEASE=1
  142. export RELEASE
  143. # We want to have the resulting .zips in the current dir
  144. ifndef DIST_DESTDIR
  145. export DIST_DESTDIR:=$(BASEDIR)
  146. endif
  147. # Temporary path to pack a file
  148. BASEPACKDIR=$(BASEDIR)/basepack
  149. # Always use newly created fpcmake
  150. ifndef FPCMAKENEW
  151. ifdef CROSSCOMPILE
  152. # Use bootstrapped fpcmake when cross-compiling
  153. FPCMAKENEW=$(BASEDIR)/utils/fpcm/fpcmake$(SRCEXEEXT)
  154. else
  155. # Use normal fpcmake
  156. FPCMAKENEW=$(BASEDIR)/utils/fpcm/bin/$(SOURCESUFFIX)/fpcmake$(SRCEXEEXT)
  157. endif
  158. endif
  159. # Build/install options
  160. ifneq ($(OPT),)
  161. OPTNEW+=$(OPT)
  162. endif
  163. CLEANOPTS=FPC=$(PPNEW)
  164. BUILDOPTS=FPC=$(PPNEW) FPCFPMAKE=$(FPCFPMAKENEW) RELEASE=1 'OPT=$(OPTNEW)'
  165. INSTALLOPTS=FPC=$(PPNEW) ZIPDESTDIR=$(BASEDIR) FPCMAKE=$(FPCMAKENEW)
  166. # Compile also IDE (check for ide and fv dir)
  167. # Skipped by default for cross compiles, because it depends on libc
  168. ifndef CROSSCOMPILE
  169. ifneq ($(wildcard ide),)
  170. IDETARGETS=go32v2 win32 win64 linux freebsd os2 emx beos haiku
  171. ifneq ($(findstring $(OS_TARGET),$(IDETARGETS)),)
  172. IDE=1
  173. endif
  174. endif
  175. endif
  176. # CPU targets for which we only build the compiler/rtl
  177. BuildOnlyBaseCPUs=jvm
  178. ifneq ($(wildcard utils),)
  179. NOUTILSTARGETS=embedded gba $(BuildOnlyBaseCPUs)
  180. ifeq ($(findstring $(OS_TARGET),$(NOUTILSTARGETS)),)
  181. ifdef BUILDFULLNATIVE
  182. UTILS=1
  183. endif
  184. endif
  185. endif
  186. [rules]
  187. .NOTPARALLEL:
  188. # These values can change
  189. unexport FPC_VERSION FPC_COMPILERINFO OS_SOURCE
  190. # Only process directories that really exists
  191. override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))
  192. #####################################################################
  193. # Main targets
  194. #####################################################################
  195. .PHONY: help
  196. help:
  197. @$(ECHO)
  198. @$(ECHO) Targets
  199. @$(ECHO) all Alias for build
  200. @$(ECHO) build Build a new compiler and all packages
  201. @$(ECHO) install Install newly build files
  202. @$(ECHO) zipinstall Create zip/tar of installed files
  203. @$(ECHO) singlezipinstall Alias for zipinstall
  204. @$(ECHO)
  205. @exit
  206. #####################################################################
  207. # Dependencies
  208. #####################################################################
  209. #######################################
  210. # Compiler
  211. #######################################
  212. .PHONY: compiler_cycle
  213. compiler_cycle:
  214. $(MAKE) -C compiler cycle
  215. ##########################################################################
  216. # Packaging
  217. ##########################################################################
  218. BUILDSTAMP=build-stamp.$(FULL_TARGET)
  219. .PHONY: all clean distclean build buildbase install installbase
  220. .PHONY: installother zipinstallbase zipinstallotherzipinstall
  221. .PHONY: singlezipinstall versioncheckstartingcompiler
  222. versioncheckstartingcompiler:
  223. ifndef CROSSCOMPILE
  224. ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
  225. ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
  226. ifndef OVERRIDEVERSIONCHECK
  227. $(error The only supported starting compiler version is $(REQUIREDVERSION). You are trying to build with $(FPC_VERSION). If you are absolutely sure that the current compiler is built from the exact same version/revision, you can try to use OVERRIDEVERSIONCHECK=1 to override )
  228. else
  229. @$(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.
  230. endif
  231. endif
  232. endif
  233. endif
  234. ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
  235. all: versioncheckstartingcompiler build
  236. install: installall
  237. zipinstall: zipinstallall
  238. else
  239. all: versioncheckstartingcompiler buildbase
  240. install: installbase
  241. zipinstall: zipinstallbase
  242. endif
  243. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  244. -$(DEL) build-stamp.*
  245. -$(DEL) base.build-stamp.*
  246. distclean: clean
  247. build: $(BUILDSTAMP)
  248. $(BUILDSTAMP):
  249. # create new compiler
  250. $(MAKE) compiler_cycle RELEASE=1
  251. ifdef CROSSCOMPILE
  252. # Buld a new native fpcmake when cross-compiling.
  253. # Fresh native compiler and RTL are ready at this stage.
  254. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  255. endif
  256. # clean
  257. $(MAKE) rtl_clean $(CLEANOPTS)
  258. $(MAKE) packages_clean $(CLEANOPTS)
  259. ifdef UTILS
  260. $(MAKE) utils_clean $(CLEANOPTS)
  261. endif
  262. ifdef IDE
  263. $(MAKE) ide_clean $(CLEANOPTS)
  264. $(MAKE) installer_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. ifdef IDE
  273. $(MAKE) ide_all $(BUILDOPTS)
  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. ifdef IDE
  305. $(MAKE) ide_$(INSTALLTARGET) $(BUILDOPTS)
  306. endif
  307. zipinstallbase:
  308. $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base $(INSTALLOPTS)
  309. zipinstallother:
  310. $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
  311. ifdef UTILS
  312. $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
  313. endif
  314. ifdef IDE
  315. $(MAKE) ide_zip$(INSTALLTARGET) $(INSTALLOPTS)
  316. endif
  317. installall: $(BUILDSTAMP)
  318. $(MAKE) installbase $(INSTALLOPTS)
  319. ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
  320. $(MAKE) installother $(INSTALLOPTS)
  321. endif
  322. singlezipinstall: zipinstallall
  323. zipinstallall: $(BUILDSTAMP)
  324. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)
  325. ##########################################################################
  326. # Cross installation (installation of cross compiler and units)
  327. ##########################################################################
  328. .PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall
  329. crossall:
  330. $(MAKE) all CROSSINSTALL=1
  331. crossinstall:
  332. $(MAKE) install CROSSINSTALL=1
  333. crosszipinstall:
  334. $(MAKE) zipinstall CROSSINSTALL=1
  335. crosssinglezipinstall:
  336. $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall ZIPNAME=fpc $(INSTALLOPTS)