Makefile.fpc 9.7 KB

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