Makefile.fpc 9.6 KB

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