Makefile.fpc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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.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),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. CLEANOPTS=FPC=$(PPNEW)
  161. BUILDOPTS=FPC=$(PPNEW) FPCFPMAKE=$(FPCFPMAKENEW) RELEASE=1
  162. INSTALLOPTS=FPC=$(PPNEW) ZIPDESTDIR=$(BASEDIR) FPCMAKE=$(FPCMAKENEW)
  163. # Compile also IDE (check for ide and fv dir)
  164. # Skipped by default for cross compiles, because it depends on libc
  165. ifndef CROSSCOMPILE
  166. ifneq ($(wildcard ide),)
  167. IDETARGETS=go32v2 win32 win64 linux freebsd os2 emx beos haiku
  168. ifneq ($(findstring $(OS_TARGET),$(IDETARGETS)),)
  169. IDE=1
  170. endif
  171. endif
  172. endif
  173. # CPU targets for which we only build the compiler/rtl
  174. BuildOnlyBaseCPUs=jvm
  175. ifneq ($(wildcard utils),)
  176. NOUTILSTARGETS=embedded gba $(BuildOnlyBaseCPUs)
  177. ifeq ($(findstring $(OS_TARGET),$(NOUTILSTARGETS)),)
  178. ifdef BUILDFULLNATIVE
  179. UTILS=1
  180. endif
  181. endif
  182. endif
  183. [rules]
  184. .NOTPARALLEL:
  185. # These values can change
  186. unexport FPC_VERSION FPC_COMPILERINFO OS_SOURCE
  187. # Only process directories that really exists
  188. override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))
  189. #####################################################################
  190. # Main targets
  191. #####################################################################
  192. .PHONY: help
  193. help:
  194. @$(ECHO)
  195. @$(ECHO) Targets
  196. @$(ECHO) all Alias for build
  197. @$(ECHO) build Build a new compiler and all packages
  198. @$(ECHO) install Install newly build files
  199. @$(ECHO) zipinstall Create zip/tar of installed files
  200. @$(ECHO) singlezipinstall Alias for zipinstall
  201. @$(ECHO)
  202. @exit
  203. #####################################################################
  204. # Dependencies
  205. #####################################################################
  206. #######################################
  207. # Compiler
  208. #######################################
  209. .PHONY: compiler_cycle
  210. compiler_cycle:
  211. $(MAKE) -C compiler cycle
  212. ##########################################################################
  213. # Packaging
  214. ##########################################################################
  215. BUILDSTAMP=build-stamp.$(FULL_TARGET)
  216. .PHONY: all clean distclean build buildbase install installbase
  217. .PHONY: installother zipinstallbase zipinstallotherzipinstall
  218. .PHONY: singlezipinstall versioncheckstartingcompiler
  219. versioncheckstartingcompiler:
  220. ifndef CROSSCOMPILE
  221. ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
  222. ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
  223. ifndef OVERRIDEVERSIONCHECK
  224. $(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 )
  225. else
  226. @$(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.
  227. endif
  228. endif
  229. endif
  230. endif
  231. ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
  232. all: versioncheckstartingcompiler build
  233. install: installall
  234. zipinstall: zipinstallall
  235. else
  236. all: versioncheckstartingcompiler buildbase
  237. install: installbase
  238. zipinstall: zipinstallbase
  239. endif
  240. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  241. -$(DEL) build-stamp.*
  242. -$(DEL) base.build-stamp.*
  243. distclean: clean
  244. build: $(BUILDSTAMP)
  245. $(BUILDSTAMP):
  246. # create new compiler
  247. $(MAKE) compiler_cycle RELEASE=1
  248. ifdef CROSSCOMPILE
  249. # Buld a new native fpcmake when cross-compiling.
  250. # Fresh native compiler and RTL are ready at this stage.
  251. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  252. endif
  253. # clean
  254. $(MAKE) rtl_clean $(CLEANOPTS)
  255. $(MAKE) packages_clean $(CLEANOPTS)
  256. ifdef UTILS
  257. $(MAKE) utils_clean $(CLEANOPTS)
  258. endif
  259. ifdef IDE
  260. $(MAKE) ide_clean $(CLEANOPTS)
  261. $(MAKE) installer_clean $(CLEANOPTS)
  262. endif
  263. # build everything
  264. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  265. $(MAKE) packages_$(ALLTARGET) $(BUILDOPTS)
  266. ifdef UTILS
  267. $(MAKE) utils_all $(BUILDOPTS)
  268. endif
  269. ifdef IDE
  270. $(MAKE) ide_all $(BUILDOPTS)
  271. $(MAKE) installer_all $(BUILDOPTS)
  272. endif
  273. $(ECHOREDIR) Build > $(BUILDSTAMP)
  274. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  275. buildbase: base.$(BUILDSTAMP)
  276. base.$(BUILDSTAMP):
  277. # create new compiler
  278. $(MAKE) compiler_cycle RELEASE=1
  279. ifdef CROSSCOMPILE
  280. # Buld a new native fpcmake when cross-compiling.
  281. # Fresh native compiler and RTL are ready at this stage.
  282. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  283. endif
  284. # clean
  285. $(MAKE) rtl_clean $(CLEANOPTS)
  286. # build everything
  287. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  288. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  289. installbase: base.$(BUILDSTAMP)
  290. # create dirs
  291. $(MKDIR) $(INSTALL_BASEDIR)
  292. $(MKDIR) $(INSTALL_BINDIR)
  293. # install compiler+rtl
  294. $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
  295. $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)
  296. installother:
  297. $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
  298. ifdef UTILS
  299. $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
  300. endif
  301. ifdef IDE
  302. $(MAKE) ide_$(INSTALLTARGET) $(BUILDOPTS)
  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. ifdef IDE
  312. $(MAKE) ide_zip$(INSTALLTARGET) $(INSTALLOPTS)
  313. endif
  314. installall: $(BUILDSTAMP)
  315. $(MAKE) installbase $(INSTALLOPTS)
  316. ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
  317. $(MAKE) installother $(INSTALLOPTS)
  318. endif
  319. singlezipinstall: zipinstallall
  320. zipinstallall: $(BUILDSTAMP)
  321. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)
  322. ##########################################################################
  323. # Cross installation (installation of cross compiler and units)
  324. ##########################################################################
  325. .PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall
  326. crossall:
  327. $(MAKE) all CROSSINSTALL=1
  328. crossinstall:
  329. $(MAKE) install CROSSINSTALL=1
  330. crosszipinstall:
  331. $(MAKE) zipinstall CROSSINSTALL=1
  332. crosssinglezipinstall:
  333. $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall ZIPNAME=fpc $(INSTALLOPTS)