Makefile.fpc 8.7 KB

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