Makefile.fpc 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  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. REQUIREDVERSION2=3.0.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. # This list should be the same as in fpcbuild/Makefile.fpc and in ide/Makefile.fpc
  173. GDBMI_DEFAULT_OS_LIST=aix freebsd haiku linux netbsd openbsd solaris win32 win64
  174. # Determine if we should use GDBMI for Text Mode IDE compilation
  175. ifndef NOGDBMI
  176. ifneq ($(findstring $(OS_TARGET),$(GDBMI_DEFAULT_OS_LIST)),)
  177. export GDBMI=1
  178. endif
  179. endif
  180. # Compile also IDE now enabled even for cross-compilation
  181. # if GDBMI is set
  182. ifdef GDBMI
  183. ifneq ($(GDBMI),0)
  184. IDE=1
  185. endif
  186. else # not GDBMI
  187. # Skipped by default for cross compiles, because it depends on libc
  188. ifndef CROSSCOMPILE
  189. ifneq ($(wildcard ide),)
  190. IDETARGETS=go32v2 win32 win64 linux freebsd os2 emx beos haiku
  191. ifneq ($(findstring $(OS_TARGET),$(IDETARGETS)),)
  192. IDE=1
  193. endif
  194. endif
  195. endif
  196. endif # not GDBMI
  197. # CPU targets for which we only build the compiler/rtl
  198. BuildOnlyBaseCPUs=jvm
  199. ifneq ($(wildcard utils),)
  200. NOUTILSTARGETS=embedded gba nds msdos win16 $(BuildOnlyBaseCPUs)
  201. ifeq ($(findstring $(OS_TARGET),$(NOUTILSTARGETS)),)
  202. ifdef BUILDFULLNATIVE
  203. UTILS=1
  204. endif
  205. endif
  206. endif
  207. [rules]
  208. .NOTPARALLEL:
  209. # These values can change
  210. unexport FPC_VERSION FPC_COMPILERINFO OS_SOURCE
  211. # Only process directories that really exists
  212. override TARGET_DIRS:=$(wildcard $(TARGET_DIRS))
  213. #####################################################################
  214. # Main targets
  215. #####################################################################
  216. .PHONY: help
  217. help:
  218. @$(ECHO)
  219. @$(ECHO) Targets
  220. @$(ECHO) all Build a new compiler and all packages
  221. @$(ECHO) install Install newly build files
  222. @$(ECHO) zipinstall Create zip/tar of installed files
  223. @$(ECHO) singlezipinstall Alias for zipinstall
  224. @$(ECHO)
  225. @exit
  226. #####################################################################
  227. # Dependencies
  228. #####################################################################
  229. #######################################
  230. # Compiler
  231. #######################################
  232. .PHONY: compiler_cycle
  233. compiler_cycle:
  234. $(MAKE) -C compiler cycle
  235. ##########################################################################
  236. # Packaging
  237. ##########################################################################
  238. BUILDSTAMP=build-stamp.$(FULL_TARGET)
  239. .PHONY: all clean distclean build buildbase install installbase
  240. .PHONY: installother zipinstallbase zipinstallotherzipinstall
  241. .PHONY: singlezipinstall versioncheckstartingcompiler
  242. versioncheckstartingcompiler:
  243. ifndef CROSSCOMPILE
  244. ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
  245. ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
  246. ifndef OVERRIDEVERSIONCHECK
  247. $(error The only supported starting compiler version is $(REQUIREDVERSION). You are trying to build with $(FPC_VERSION).)
  248. else
  249. @$(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.
  250. endif
  251. endif
  252. endif
  253. endif
  254. ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
  255. all: versioncheckstartingcompiler build
  256. install: installall
  257. zipinstall: zipinstallall
  258. else
  259. all: versioncheckstartingcompiler buildbase
  260. install: installbase
  261. zipinstall: zipinstallbase
  262. endif
  263. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  264. -$(DEL) build-stamp.*
  265. -$(DEL) base.build-stamp.*
  266. distclean: clean
  267. build: $(BUILDSTAMP)
  268. $(BUILDSTAMP):
  269. # create new compiler
  270. $(MAKE) compiler_cycle RELEASE=1
  271. ifdef CROSSCOMPILE
  272. # Buld a new native fpcmake when cross-compiling.
  273. # Fresh native compiler and RTL are ready at this stage.
  274. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  275. endif
  276. # clean
  277. $(MAKE) rtl_clean $(CLEANOPTS)
  278. $(MAKE) packages_clean $(CLEANOPTS)
  279. ifdef UTILS
  280. $(MAKE) utils_clean $(CLEANOPTS)
  281. endif
  282. ifdef IDE
  283. $(MAKE) ide_clean $(CLEANOPTS)
  284. $(MAKE) installer_clean $(CLEANOPTS)
  285. endif
  286. # build everything
  287. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  288. $(MAKE) packages_$(ALLTARGET) $(BUILDOPTS)
  289. ifdef UTILS
  290. $(MAKE) utils_all $(BUILDOPTS)
  291. endif
  292. ifdef IDE
  293. $(MAKE) ide_all $(BUILDOPTS)
  294. $(MAKE) installer_all $(BUILDOPTS)
  295. endif
  296. $(ECHOREDIR) Build > $(BUILDSTAMP)
  297. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  298. buildbase: base.$(BUILDSTAMP)
  299. base.$(BUILDSTAMP):
  300. # create new compiler
  301. $(MAKE) compiler_cycle RELEASE=1
  302. ifdef CROSSCOMPILE
  303. # Buld a new native fpcmake when cross-compiling.
  304. # Fresh native compiler and RTL are ready at this stage.
  305. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  306. endif
  307. # clean
  308. $(MAKE) rtl_clean $(CLEANOPTS)
  309. # build everything
  310. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  311. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  312. installbase: base.$(BUILDSTAMP)
  313. # create dirs
  314. $(MKDIR) $(INSTALL_BASEDIR)
  315. $(MKDIR) $(INSTALL_BINDIR)
  316. # install compiler+rtl
  317. $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
  318. $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)
  319. installother:
  320. $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
  321. ifdef UTILS
  322. $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
  323. endif
  324. ifdef IDE
  325. $(MAKE) ide_$(INSTALLTARGET) $(BUILDOPTS)
  326. endif
  327. zipinstallbase:
  328. $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base $(INSTALLOPTS)
  329. zipinstallother:
  330. $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
  331. ifdef UTILS
  332. $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
  333. endif
  334. ifdef IDE
  335. $(MAKE) ide_zip$(INSTALLTARGET) $(INSTALLOPTS)
  336. endif
  337. installall: $(BUILDSTAMP)
  338. $(MAKE) installbase $(INSTALLOPTS)
  339. ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
  340. $(MAKE) installother $(INSTALLOPTS)
  341. endif
  342. singlezipinstall: zipinstallall
  343. zipinstallall: $(BUILDSTAMP)
  344. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)
  345. ##########################################################################
  346. # Cross installation (installation of cross compiler and units)
  347. ##########################################################################
  348. .PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall
  349. crossall:
  350. $(MAKE) all CROSSINSTALL=1
  351. crossinstall:
  352. $(MAKE) install CROSSINSTALL=1
  353. crosszipinstall:
  354. $(MAKE) zipinstall CROSSINSTALL=1
  355. crosssinglezipinstall:
  356. $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall ZIPNAME=fpc $(INSTALLOPTS)