Makefile.fpc 8.7 KB

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