Makefile.fpc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. ifndef BUILDFULLNATIVE
  55. FPMAKE_OPT+=-sp
  56. endif
  57. .NOTPARALLEL:
  58. fpmkunit_clean_bootstrap:
  59. $(MAKE) -C fpmkunit clean_bootstrap
  60. fpmake: fpmake.pp
  61. $(MAKE) -C fpmkunit bootstrap
  62. $(FPCFPMAKE) fpmake.pp $(FPMAKE_SKIP_CONFIG) $(addprefix -Fu,$(COMPILER_FPMAKE_UNITDIR)) $(FPCMAKEOPT) $(OPT)
  63. all: fpmake
  64. $(LOCALFPMAKE) compile $(FPMAKE_OPT)
  65. smart: fpmake
  66. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -XX -o -CX
  67. release: fpmake
  68. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dRELEASE
  69. debug: fpmake
  70. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dDEBUG
  71. # If no fpmake exists and (dist)clean is called, do not try to build fpmake, it will
  72. # most often fail because the dependencies are cleared.
  73. # In case of a clean, simply do nothing
  74. ifeq ($(FPMAKE_BIN_CLEAN),)
  75. clean: fpmkunit_clean_bootstrap
  76. else
  77. clean: fpmkunit_clean_bootstrap
  78. $(FPMAKE_BIN_CLEAN) clean $(FPMAKE_OPT)
  79. endif
  80. CLEAN_TARGET_DIRS=$(subst /Makefile, ,$(wildcard */Makefile))
  81. %_distclean:
  82. $(MAKE) -C $* distclean
  83. # In case of a distclean, perform an 'old'-style distclean. This to avoid problems
  84. # when the package is compiled using fpcmake prior to running this clean using fpmake
  85. ifeq ($(FPMAKE_BIN_CLEAN),)
  86. distclean: fpc_cleanall $(addsuffix _distclean,$(CLEAN_TARGET_DIRS)) fpmkunit_clean_bootstrap
  87. else
  88. distclean: fpmkunit_clean_bootstrap
  89. ifdef inUnix
  90. { $(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; }
  91. else
  92. $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT)
  93. endif
  94. -$(DEL) $(LOCALFPMAKE)
  95. -$(DEL) fpmake.o
  96. -$(DEL) fpmake.dbg
  97. endif
  98. install: fpmake
  99. ifdef UNIXHier
  100. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT)
  101. else
  102. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT)
  103. endif
  104. # distinstall also installs the example-sources
  105. distinstall: fpmake
  106. ifdef UNIXHier
  107. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT) -ie
  108. else
  109. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT) -ie
  110. endif
  111. zipinstall: fpmake
  112. $(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX)
  113. zipdistinstall: fpmake
  114. $(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) -ie