Makefile.fpc 8.6 KB

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