Makefile.fpc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 .$(PATHSEP)fpmake$(SRCEXEEXT))
  24. LOCALFPMAKE=.$(PATHSEP)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. [rules]
  42. # Do not pass the Makefile's unit and binary target locations. fpmake uses it's own.
  43. override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
  44. override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
  45. # Compose general fpmake-parameters
  46. ifdef FPMAKEOPT
  47. FPMAKE_OPT+=$(FPMAKEOPT)
  48. endif
  49. FPMAKE_OPT+=--localunitdir=..
  50. FPMAKE_OPT+=$(FPC_TARGETOPT)
  51. FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
  52. FPMAKE_OPT+=--compiler=$(FPC)
  53. FPMAKE_OPT+=-bu
  54. .NOTPARALLEL:
  55. fpmkunit_bootstrap:
  56. $(MAKE) -C fpmkunit bootstrap
  57. fpmkunit_clean_bootstrap:
  58. $(MAKE) -C fpmkunit clean_bootstrap
  59. fpmake: fpmake.pp fpmkunit_bootstrap
  60. $(FPCFPMAKE) fpmake.pp $(FPMAKE_SKIP_CONFIG) $(addprefix -Fu,$(COMPILER_FPMAKE_UNITDIR)) $(FPCMAKEOPT) $(OPT)
  61. all: fpmake
  62. $(LOCALFPMAKE) compile $(FPMAKE_OPT)
  63. smart: fpmake
  64. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -XX -o -CX
  65. release: fpmake
  66. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dRELEASE
  67. debug: fpmake
  68. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dDEBUG
  69. # If no fpmake exists and (dist)clean is called, do not try to build fpmake, it will
  70. # most often fail because the dependencies are cleared.
  71. # In case of a clean, simply do nothing
  72. ifeq ($(FPMAKE_BIN_CLEAN),)
  73. clean: fpmkunit_clean_bootstrap
  74. else
  75. clean: fpmkunit_clean_bootstrap
  76. $(FPMAKE_BIN_CLEAN) clean $(FPMAKE_OPT)
  77. endif
  78. CLEAN_TARGET_DIRS=$(subst /Makefile, ,$(wildcard */Makefile))
  79. %_distclean:
  80. $(MAKE) -C $* distclean
  81. # In case of a distclean, perform an 'old'-style distclean. This to avoid problems
  82. # when the package is compiled using fpcmake prior to running this clean using fpmake
  83. ifeq ($(FPMAKE_BIN_CLEAN),)
  84. distclean: fpc_cleanall $(addsuffix _distclean,$(CLEAN_TARGET_DIRS)) fpmkunit_clean_bootstrap
  85. else
  86. distclean: fpmkunit_clean_bootstrap
  87. ifdef inUnix
  88. { $(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; }
  89. else
  90. $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT)
  91. endif
  92. -$(DEL) $(LOCALFPMAKE)
  93. endif
  94. install: fpmake
  95. ifdef UNIXHier
  96. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT)
  97. else
  98. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT)
  99. endif
  100. # distinstall also installs the example-sources
  101. distinstall: fpmake
  102. ifdef UNIXHier
  103. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT) -ie
  104. else
  105. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT) -ie
  106. endif