Makefile.fpc 9.2 KB

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