Makefile.fpc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. # Translate OS_TARGET and CPU_TARGET to fpmake's --os and --cpu parameters
  17. ifdef OS_TARGET
  18. FPC_TARGETOPT+=--os=$(OS_TARGET)
  19. endif
  20. ifdef CPU_TARGET
  21. FPC_TARGETOPT+=--cpu=$(CPU_TARGET)
  22. endif
  23. FPMAKE_BIN_CLEAN=$(wildcard ./fpmake$(SRCEXEEXT))
  24. LOCALFPMAKE=./fpmake$(SRCEXEEXT)
  25. # Get the location of the bootstrap-fpmkunit units
  26. PACKAGEDIR_FPMKUNIT:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /fpmkunit/Makefile.fpc,$(PACKAGESDIR))))))
  27. ifneq ($(PACKAGEDIR_FPMKUNIT),)
  28. UNITDIR_FPMAKE_FPMKUNIT=$(PACKAGEDIR_FPMKUNIT)/units_bs/$(SOURCESUFFIX)
  29. else
  30. PACKAGEDIR_FPMKUNIT=
  31. UNITDIR_FPMKUNIT:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /fpmkunit/Package.fpc,$(UNITSDIR)))))
  32. ifneq ($(UNITDIR_FPMKUNIT),)
  33. UNITDIR_FPMKUNIT:=$(firstword $(UNITDIR_FPMKUNIT))
  34. else
  35. UNITDIR_FPMKUNIT=
  36. endif
  37. endif
  38. ifdef UNITDIR_FPMAKE_FPMKUNIT
  39. override COMPILER_FPMAKE_UNITDIR=$(UNITDIR_FPMAKE_FPMKUNIT)
  40. endif
  41. SUB_FPMAKE_SRCS=$(wildcard */fpmake.pp)
  42. [rules]
  43. # Do not pass the Makefile's unit and binary target locations. fpmake uses it's own.
  44. override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
  45. override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
  46. # Compose general fpmake-parameters
  47. ifdef FPMAKEOPT
  48. FPMAKE_OPT+=$(FPMAKEOPT)
  49. endif
  50. FPMAKE_OPT+=--localunitdir=..
  51. FPMAKE_OPT+=$(FPC_TARGETOPT)
  52. FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
  53. FPMAKE_OPT+=--compiler=$(FPC)
  54. FPMAKE_OPT+=-bu
  55. ifndef BUILDFULLNATIVE
  56. FPMAKE_OPT+=-sp
  57. endif
  58. .NOTPARALLEL:
  59. fpmkunit_bootstrap:
  60. $(MAKE) -C fpmkunit bootstrap
  61. fpmkunit_clean_bootstrap:
  62. $(MAKE) -C fpmkunit clean_bootstrap
  63. fpmake$(SRCEXEEXT): fpmake.pp fpmkunit_bootstrap $(SUB_FPMAKE_SRCS) fpmake_add.inc fpmake_proc.inc
  64. $(FPCFPMAKE) fpmake.pp $(FPMAKE_SKIP_CONFIG) $(addprefix -Fu,$(COMPILER_FPMAKE_UNITDIR)) $(FPCMAKEOPT) $(OPT)
  65. all: fpmake$(SRCEXEEXT)
  66. $(LOCALFPMAKE) compile $(FPMAKE_OPT)
  67. smart: fpmake$(SRCEXEEXT)
  68. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -XX -o -CX
  69. release: fpmake$(SRCEXEEXT)
  70. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dRELEASE
  71. debug: fpmake$(SRCEXEEXT)
  72. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dDEBUG
  73. # If no fpmake exists and (dist)clean is called, do not try to build fpmake, it will
  74. # most often fail because the dependencies are cleared.
  75. # In case of a clean, simply do nothing
  76. ifeq ($(FPMAKE_BIN_CLEAN),)
  77. clean: fpmkunit_clean_bootstrap
  78. else
  79. clean: fpmkunit_clean_bootstrap
  80. $(FPMAKE_BIN_CLEAN) clean $(FPMAKE_OPT)
  81. endif
  82. CLEAN_TARGET_DIRS=$(subst /Makefile, ,$(wildcard */Makefile))
  83. %_distclean:
  84. $(MAKE) -C $* distclean
  85. # In case of a distclean, perform an 'old'-style distclean. This to avoid problems
  86. # when the package is compiled using fpcmake prior to running this clean using fpmake
  87. ifeq ($(FPMAKE_BIN_CLEAN),)
  88. distclean: fpc_cleanall $(addsuffix _distclean,$(CLEAN_TARGET_DIRS)) fpmkunit_clean_bootstrap
  89. else
  90. distclean: fpmkunit_clean_bootstrap
  91. ifdef inUnix
  92. { $(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; }
  93. else
  94. $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT)
  95. endif
  96. -$(DEL) $(LOCALFPMAKE)
  97. -$(DEL) fpmake.o
  98. -$(DEL) fpmake.dbg
  99. endif
  100. install: fpmake$(SRCEXEEXT)
  101. ifdef UNIXHier
  102. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT)
  103. else
  104. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT)
  105. endif
  106. # distinstall also installs the example-sources and omits the location of the source-
  107. # files from the fpunits.cfg files.
  108. distinstall: fpmake$(SRCEXEEXT)
  109. ifdef UNIXHier
  110. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT) -ie -fsp 0
  111. else
  112. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT) -ie -fsp 0
  113. endif
  114. zipinstall: fpmake$(SRCEXEEXT)
  115. $(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX)
  116. zipdistinstall: fpmake$(SRCEXEEXT)
  117. $(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) -ie -fsp 0
  118. zipsourceinstall: fpmake$(SRCEXEEXT)
  119. ifdef UNIXHier
  120. $(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=share/src/fpc-\$$\(PACKAGEVERSION\)/$(INSTALL_FPCSUBDIR)/\$$\(PACKAGEDIRECTORY\)
  121. else
  122. $(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=source\\$(INSTALL_FPCSUBDIR)\\\$$\(PACKAGEDIRECTORY\)
  123. endif
  124. #####################################################################
  125. # PPU testing targets
  126. #####################################################################
  127. PPULIST:=$(wildcard */units/*/*.ppu)
  128. PPULOGLIST:=$(subst .ppu,.log-ppu,$(PPULIST))
  129. RMPPULOGLIST:=$(subst .ppu,.rm-log-ppu,$(PPULIST))
  130. .PHONY : ppulogs cleanppulogs testppudump $(RMPPULOGLIST)
  131. ppulogs : $(PPULOGLIST)
  132. vpath %.ppu $(ALLPPUDIRS)
  133. vpath %.log-ppu $(ALLPPUDIRS)
  134. vpath %.rm-log-ppu $(ALLPPUDIRS)
  135. %.log-ppu : %.ppu ../compiler/utils/ppudump$(EXEEXT)
  136. ..$(PATHSEP)compiler$(PATHSEP)utils$(PATHSEP)ppudump -VA -M $< > $@
  137. %.rm-log-ppu : %.ppu ../compiler/utils/ppudump$(EXEEXT)
  138. -$(RMPROG) $<
  139. ../compiler/utils/ppudump$(EXEEXT):
  140. $(MAKE) -C $(COMPILERDIR)/utils ppudump$(EXEEXT)
  141. ppuinfo :
  142. echo PPU list is "$(PPULIST)"
  143. echo PPULOG list is "$(PPULOGLIST)"
  144. cleanppulogs : $(RMPPULOGLIST)
  145. testppudump :
  146. $(MAKE) cleanppulogs ppulogs