Makefile.fpc 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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 installother zipinstallbase zipinstallotherzipinstall singlezipinstall
  211. versioncheckstartingcompiler:
  212. ifndef CROSSCOMPILE
  213. ifndef OVERRIDEVERSIONCHECK
  214. ifneq ($(FPC_VERSION),$(REQUIREDVERSION))
  215. ifneq ($(FPC_VERSION),$(REQUIREDVERSION2))
  216. $(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 )
  217. endif
  218. endif
  219. endif
  220. endif
  221. ifeq ($(findstring $(CPU_TARGET),$(BuildOnlyBaseCPUs)),)
  222. all: versioncheckstartingcompiler build
  223. install: installall
  224. zipinstall: zipinstallall
  225. else
  226. all: versioncheckstartingcompiler buildbase
  227. install: installbase
  228. zipinstall: zipinstallbase
  229. endif
  230. clean: $(addsuffix _distclean,$(TARGET_DIRS))
  231. -$(DEL) build-stamp.*
  232. -$(DEL) base.build-stamp.*
  233. distclean: clean
  234. build: $(BUILDSTAMP)
  235. $(BUILDSTAMP):
  236. # create new compiler
  237. $(MAKE) compiler_cycle RELEASE=1
  238. ifdef CROSSCOMPILE
  239. # Buld a new native fpcmake when cross-compiling.
  240. # Fresh native compiler and RTL are ready at this stage.
  241. $(MAKE) -C utils/fpcm bootstrap $(BUILDOPTS)
  242. endif
  243. # clean
  244. $(MAKE) rtl_clean $(CLEANOPTS)
  245. $(MAKE) packages_clean $(CLEANOPTS)
  246. ifdef UTILS
  247. $(MAKE) utils_clean $(CLEANOPTS)
  248. endif
  249. ifdef IDE
  250. $(MAKE) ide_clean $(CLEANOPTS)
  251. $(MAKE) installer_clean $(CLEANOPTS)
  252. endif
  253. # build everything
  254. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  255. $(MAKE) packages_$(ALLTARGET) $(BUILDOPTS)
  256. ifdef UTILS
  257. $(MAKE) utils_all $(BUILDOPTS)
  258. endif
  259. ifdef IDE
  260. $(MAKE) ide_all $(BUILDOPTS)
  261. $(MAKE) installer_all $(BUILDOPTS)
  262. endif
  263. $(ECHOREDIR) Build > $(BUILDSTAMP)
  264. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  265. buildbase: base.$(BUILDSTAMP)
  266. base.$(BUILDSTAMP):
  267. # create new compiler
  268. $(MAKE) compiler_cycle RELEASE=1
  269. # clean
  270. $(MAKE) rtl_clean $(CLEANOPTS)
  271. # build everything
  272. $(MAKE) rtl_$(ALLTARGET) $(BUILDOPTS)
  273. $(ECHOREDIR) Build > base.$(BUILDSTAMP)
  274. installbase: base.$(BUILDSTAMP)
  275. # create dirs
  276. $(MKDIR) $(INSTALL_BASEDIR)
  277. $(MKDIR) $(INSTALL_BINDIR)
  278. # install compiler+rtl
  279. $(MAKE) compiler_$(INSTALLTARGET) $(INSTALLOPTS)
  280. $(MAKE) rtl_$(INSTALLTARGET) $(INSTALLOPTS)
  281. installother:
  282. $(MAKE) packages_$(INSTALLTARGET) $(INSTALLOPTS)
  283. ifdef UTILS
  284. $(MAKE) utils_$(INSTALLTARGET) $(INSTALLOPTS)
  285. endif
  286. ifdef IDE
  287. $(MAKE) ide_$(INSTALLTARGET) $(BUILDOPTS)
  288. endif
  289. zipinstallbase:
  290. $(MAKE) fpc_zipinstall ZIPTARGET=installbase ZIPNAME=base $(INSTALLOPTS)
  291. zipinstallother:
  292. $(MAKE) packages_zip$(INSTALLTARGET) $(INSTALLOPTS) ZIPPREFIX=$(PKGUNITSPRE)
  293. ifdef UTILS
  294. $(MAKE) utils_zip$(INSTALLTARGET) $(INSTALLOPTS)
  295. endif
  296. ifdef IDE
  297. $(MAKE) ide_zip$(INSTALLTARGET) $(INSTALLOPTS)
  298. endif
  299. installall: $(BUILDSTAMP)
  300. $(MAKE) installbase $(INSTALLOPTS)
  301. ifeq ($(findstring $(CPU_TARGET), $(BuildOnlyBaseCPUs)),)
  302. $(MAKE) installother $(INSTALLOPTS)
  303. endif
  304. singlezipinstall: zipinstallall
  305. zipinstallall: $(BUILDSTAMP)
  306. $(MAKE) fpc_zipinstall ZIPTARGET=install FULLZIPNAME=fpc-$(PACKAGE_VERSION).$(TARGETSUFFIX) $(INSTALLOPTS)
  307. ##########################################################################
  308. # Cross installation (installation of cross compiler and units)
  309. ##########################################################################
  310. .PHONY: crossall crossinstall crosszipinstall crosssinglezipinstall
  311. crossall:
  312. $(MAKE) all CROSSINSTALL=1
  313. crossinstall:
  314. $(MAKE) install CROSSINSTALL=1
  315. crosszipinstall:
  316. $(MAKE) zipinstall CROSSINSTALL=1
  317. crosssinglezipinstall:
  318. $(MAKE) fpc_zipinstall ZIPTARGET=crossinstall ZIPNAME=fpc $(INSTALLOPTS)