Makefile.fpc 8.1 KB

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