Makefile.fpc 9.3 KB

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