Makefile.fpc 8.6 KB

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