Makefile.fpc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #
  2. # Makefile.fpc for Free Pascal Packages
  3. #
  4. [require]
  5. packages=rtl
  6. [install]
  7. fpcpackage=y
  8. fpcsubdir=packages
  9. [default]
  10. fpcdir=..
  11. [prerules]
  12. # Translate INSTALL_UNITDIR to fpmake's --unitinstalldir parameter
  13. ifdef INSTALL_UNITDIR
  14. FPMAKE_INSTALL_OPT+=--unitinstalldir=$(INSTALL_UNITDIR)
  15. endif
  16. ifdef INSTALL_BINDIR
  17. FPMAKE_INSTALL_OPT+=--bininstalldir=$(INSTALL_BINDIR)
  18. endif
  19. # Translate OS_TARGET and CPU_TARGET to fpmake's --os and --cpu parameters
  20. ifdef OS_TARGET
  21. FPC_TARGETOPT+=--os=$(OS_TARGET)
  22. endif
  23. ifdef CPU_TARGET
  24. FPC_TARGETOPT+=--cpu=$(CPU_TARGET)
  25. endif
  26. FPMAKE_BIN_CLEAN=$(wildcard ./fpmake$(SRCEXEEXT))
  27. LOCALFPMAKE=./fpmake$(SRCEXEEXT)
  28. # Get the location of the bootstrap-fpmkunit units
  29. PACKAGEDIR_FPMKUNIT:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fpmkunit/Makefile.fpc,$(PACKAGESDIR))))))
  30. ifneq ($(PACKAGEDIR_FPMKUNIT),)
  31. UNITDIR_FPMAKE_FPMKUNIT=$(PACKAGEDIR_FPMKUNIT)/units_bs/$(SOURCESUFFIX)
  32. else
  33. PACKAGEDIR_FPMKUNIT=
  34. UNITDIR_FPMKUNIT:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /fpmkunit/Package.fpc,$(UNITSDIR)))))
  35. ifneq ($(UNITDIR_FPMKUNIT),)
  36. UNITDIR_FPMKUNIT:=$(firstword $(UNITDIR_FPMKUNIT))
  37. else
  38. UNITDIR_FPMKUNIT=
  39. endif
  40. endif
  41. ifdef UNITDIR_FPMAKE_FPMKUNIT
  42. override COMPILER_FPMAKE_UNITDIR=$(UNITDIR_FPMAKE_FPMKUNIT)
  43. endif
  44. ifdef INSTALL_LIBDIR
  45. FPMAKE_INSTALL_OPT+=--libinstalldir=$(INSTALL_LIBDIR)
  46. endif
  47. SUB_FPMAKE_SRCS=$(wildcard */fpmake.pp)
  48. [rules]
  49. # Do not pass the Makefile's unit and binary target locations. Fpmake uses it's own.
  50. override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
  51. override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
  52. # Do not pass the package-unitdirectories. Fpmake adds those and this way they don't apear in the .fpm
  53. override FPCOPT:=$(filter-out $(addprefix -Fu,$(COMPILER_UNITDIR)),$(FPCOPT))# Compose general fpmake-parameters
  54. # Compose general fpmake-parameters
  55. ifdef FPMAKEOPT
  56. FPMAKE_OPT+=$(FPMAKEOPT)
  57. endif
  58. FPMAKE_OPT+=--localunitdir=..
  59. FPMAKE_OPT+=$(FPC_TARGETOPT)
  60. FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
  61. FPMAKE_OPT+=--compiler=$(FPC)
  62. ifndef DISABLE_FPMAKE_BUILD_UNIT
  63. FPMAKE_OPT+=-bu
  64. endif
  65. ifdef FPC_DOTTEDUNITS
  66. FPMAKE_OPT+=-ns
  67. FPMAKE_OPT+=-ns -o -dFPC_DOTTEDUNITS
  68. endif
  69. ifndef BUILDFULLNATIVE
  70. FPMAKE_OPT+=-scp
  71. endif
  72. ifdef LLVM
  73. FPMAKE_OPT+=--LLVM=1
  74. endif
  75. fpmkunit_clean_bootstrap:
  76. $(MAKE) -C fpmkunit clean_bootstrap
  77. fpmake$(SRCEXEEXT): fpmake.pp $(SUB_FPMAKE_SRCS) fpmake_add.inc fpmake_proc.inc
  78. $(MAKE) -C ../rtl all FPC=$(FPCFPMAKE)
  79. $(MAKE) -C fpmkunit bootstrap FPC=$(FPCFPMAKE)
  80. $(FPCFPMAKE) fpmake.pp $(FPMAKE_SKIP_CONFIG) $(addprefix -Fu,$(COMPILER_FPMAKE_UNITDIR)) $(FPCMAKEOPT) $(OPT)
  81. all: fpmake$(SRCEXEEXT)
  82. $(LOCALFPMAKE) compile $(FPMAKE_OPT)
  83. smart: fpmake$(SRCEXEEXT)
  84. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -XX -o -CX
  85. release: fpmake$(SRCEXEEXT)
  86. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dRELEASE
  87. debug: fpmake$(SRCEXEEXT)
  88. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dDEBUG
  89. # If no fpmake exists and (dist)clean is called, do not try to build fpmake, it will
  90. # most often fail because the dependencies are cleared.
  91. # In case of a clean, simply do nothing
  92. ifeq ($(FPMAKE_BIN_CLEAN),)
  93. clean: fpmkunit_clean_bootstrap
  94. else
  95. clean: fpmkunit_clean_bootstrap
  96. $(FPMAKE_BIN_CLEAN) clean $(FPMAKE_OPT)
  97. endif
  98. CLEAN_TARGET_DIRS=$(subst /Makefile, ,$(wildcard */Makefile))
  99. %_distclean:
  100. $(MAKE) -C $* distclean
  101. # In case of a distclean, perform an 'old'-style distclean. This to avoid problems
  102. # when the package is compiled using fpcmake prior to running this clean using fpmake
  103. ifeq ($(FPMAKE_BIN_CLEAN),)
  104. distclean: fpc_cleanall $(addsuffix _distclean,$(CLEAN_TARGET_DIRS)) fpmkunit_clean_bootstrap
  105. else
  106. distclean: fpmkunit_clean_bootstrap
  107. ifdef inUnix
  108. { $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT); if [ $$? != "0" ]; then { echo Something wrong with fpmake exectable. Remove the executable and call make recursively to recover.; $(DEL) $(FPMAKE_BIN_CLEAN); $(MAKE) fpc_cleanall; }; fi; }
  109. else
  110. $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT)
  111. endif
  112. -$(DEL) $(LOCALFPMAKE)
  113. -$(DEL) fpmake.o
  114. -$(DEL) fpmake.dbg
  115. endif
  116. install: fpmake$(SRCEXEEXT)
  117. ifdef UNIXHier
  118. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT)
  119. else
  120. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT)
  121. endif
  122. # distinstall also installs the example-sources and omits the location of the source-
  123. # files from the fpunits.cfg files.
  124. distinstall: fpmake$(SRCEXEEXT)
  125. ifdef UNIXHier
  126. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT) -ie -fsp 0
  127. else
  128. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT) -ie -fsp 0
  129. endif
  130. zipinstall: fpmake$(SRCEXEEXT)
  131. $(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX)
  132. zipdistinstall: fpmake$(SRCEXEEXT)
  133. $(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) -ie -fsp 0
  134. zipsourceinstall: fpmake$(SRCEXEEXT)
  135. ifdef UNIXHier
  136. $(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=share/src/fpc-\$$\(PACKAGEVERSION\)/$(INSTALL_FPCSUBDIR)/\$$\(PACKAGEDIRECTORY\)
  137. else
  138. $(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=source\\$(INSTALL_FPCSUBDIR)\\\$$\(PACKAGEDIRECTORY\)
  139. endif
  140. #####################################################################
  141. # PPU testing targets
  142. #####################################################################
  143. PPULIST:=$(wildcard */units/$(TARGETSUFFIX)/*.ppu)
  144. PPULOGLIST:=$(subst .ppu,.log-ppu,$(PPULIST))
  145. ALLPPUDIRS:=$(wildcard */units/*)
  146. # Only remove existing log-ppu files
  147. RMPPULOGLIST:=$(subst .log-ppu,.rm-log-ppu,$(wildcard $(PPULOGLIST)))
  148. .PHONY : ppulogs cleanppulogs testppudump $(RMPPULOGLIST)
  149. ppulogs : $(PPULOGLIST)
  150. # Do not try to recompile ppudump, as this does not work if trying to test cross-compiled units
  151. %.log-ppu : %.ppu
  152. ppudump -VA -M $< > $@
  153. %.rm-log-ppu : %.ppu
  154. -$(RMPROG) $<
  155. ../compiler/utils/ppudump$(EXEEXT):
  156. $(MAKE) -C $(COMPILERDIR)/utils ppudump$(EXEEXT)
  157. ppuinfo :
  158. echo list of PPU directories is "$(ALLPPUDIRS)"
  159. echo PPU list is "$(PPULIST)"
  160. echo PPULOG list is "$(PPULOGLIST)"
  161. echo RMPPULOG list is "$(RMPPULOGLIST)"
  162. cleanppulogs : $(RMPPULOGLIST)
  163. testppudump :
  164. $(MAKE) cleanppulogs
  165. $(MAKE) ppulogs