Makefile.fpc 9.2 KB

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