Makefile.fpc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #
  2. # Makefile.fpc for running fpmake
  3. #
  4. [require]
  5. packages=rtl fpmkunit
  6. [install]
  7. fpcpackage=y
  8. fpcsubdir=ide
  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. # do not add -d$(CPU_TARGET)
  29. override NOCPUDEF=1
  30. # This list should be the same as in fpcbuild/Makefile.fpc and in fpcsrc/Makefile.fpc
  31. GDBMI_DEFAULT_OS_LIST=aix darwin freebsd haiku linux netbsd openbsd solaris win32 win64
  32. [rules]
  33. # Do not pass the Makefile's unit and binary target locations. Fpmake uses it's own.
  34. override FPCOPT:=$(filter-out -FU%,$(FPCOPT))
  35. override FPCOPT:=$(filter-out -FE%,$(FPCOPT))
  36. # Do not pass the package-unitdirectories. Fpmake adds those and this way they don't apear in the .fpm
  37. override FPCOPT:=$(filter-out $(addprefix -Fu,$(COMPILER_UNITDIR)),$(FPCOPT))# Compose general fpmake-parameters
  38. # Compose general fpmake-parameters
  39. ifdef FPMAKEOPT
  40. FPMAKE_OPT+=$(FPMAKEOPT)
  41. endif
  42. FPMAKE_OPT+=--localunitdir=../..
  43. FPMAKE_OPT+=--globalunitdir=../../packages
  44. FPMAKE_OPT+=$(FPC_TARGETOPT)
  45. FPMAKE_OPT+=$(addprefix -o ,$(FPCOPT))
  46. FPMAKE_OPT+=--compiler=$(FPC)
  47. FPMAKE_OPT+=-bu
  48. ifdef NOGDB
  49. FPMAKE_OPT+=--NoGDB=1
  50. else
  51. ifndef NOGDBMI
  52. ifneq ($(findstring $(OS_TARGET),$(GDBMI_DEFAULT_OS_LIST)),)
  53. GDBMI=1
  54. endif
  55. endif # NOGDBMI
  56. ifdef NOGDBMI
  57. FPMAKE_OPT+=--NOGDBMI=1
  58. endif
  59. ifdef GDBMI
  60. FPMAKE_OPT+=--GDBMI=1
  61. # If the rtl does not require libc, then
  62. # IDE compiled with GDBMI should be a static executable
  63. # and can thus be cross-compiled
  64. ifeq ($(findstring $(OS_TARGET),aix beos darwin haiku solaris),)
  65. GDBMI_IS_STATIC=1
  66. endif
  67. endif
  68. endif # NOGDB
  69. ifndef GDBMI_IS_STATIC
  70. ifndef BUILDFULLNATIVE
  71. # Omit executable is only required if generated executable is not static
  72. FPMAKE_OPT+=-scp
  73. endif
  74. endif # GDBMI_IS_STATIC
  75. ifdef PPC_TARGET
  76. FPMAKE_OPT+=--CompilerTarget=$(PPC_TARGET)
  77. endif
  78. .NOTPARALLEL:
  79. PPC_TARGETS=i386 m68k powerpc sparc arm x86_64 powerpc64 mips mipsel avr jvm i8086 aarch64 sparc64
  80. CLEAN_TARGETS=$(addsuffix _clean,$(sort $(PPC_TARGETS)))
  81. DISTCLEAN_TARGETS=$(addsuffix _distclean,$(sort $(PPC_TARGETS)))
  82. INSTALL_TARGETS=$(addsuffix _exe_install,$(sort $(PPC_TARGETS)))
  83. .PHONY: $(PPC_TARGETS) $(CLEAN_TARGETS) $(DISTCLEAN_TARGETS) $(INSTALL_TARGETS)
  84. $(PPC_TARGETS):
  85. $(MAKE) PPC_TARGET=$@ all
  86. $(CLEAN_TARGETS):
  87. $(MAKE) clean PPC_TARGET=$(subst _clean,,$@)
  88. $(DISTCLEAN_TARGETS):
  89. $(MAKE) distclean PPC_TARGET=$(subst _distclean,,$@)
  90. $(INSTALL_TARGETS):
  91. $(MAKE) all install PPC_TARGET=$(subst _exe_install,,$@)
  92. all_targets: $(PPC_TARGETS)
  93. all_targets_install: $(INSTALL_TARGETS)
  94. fpmake$(SRCEXEEXT): fpmake.pp
  95. $(FPCFPMAKE) fpmake.pp $(FPMAKE_SKIP_CONFIG) $(addprefix -Fu,$(COMPILER_FPMAKE_UNITDIR)) $(FPCMAKEOPT) $(OPT)
  96. all: fpmake$(SRCEXEEXT)
  97. $(LOCALFPMAKE) compile $(FPMAKE_OPT)
  98. smart: fpmake$(SRCEXEEXT)
  99. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -XX -o -CX
  100. release: fpmake$(SRCEXEEXT)
  101. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dRELEASE
  102. debug: fpmake$(SRCEXEEXT)
  103. $(LOCALFPMAKE) compile $(FPMAKE_OPT) -o -dDEBUG
  104. # If no fpmake exists and (dist)clean is called, do not try to build fpmake, it will
  105. # most often fail because the dependencies are cleared.
  106. # In case of a clean, simply do nothing
  107. ifeq ($(FPMAKE_BIN_CLEAN),)
  108. clean:
  109. else
  110. clean:
  111. $(FPMAKE_BIN_CLEAN) clean $(FPMAKE_OPT)
  112. endif
  113. CLEAN_TARGET_DIRS=$(subst /Makefile.fpc, ,$(wildcard */Makefile.fpc))
  114. %_distclean:
  115. $(MAKE) -C $* distclean
  116. # In case of a distclean, perform an 'old'-style distclean. This to avoid problems
  117. # when the package is compiled using fpcmake prior to running this clean using fpmake
  118. ifeq ($(FPMAKE_BIN_CLEAN),)
  119. distclean: fpc_cleanall $(addsuffix _distclean,$(CLEAN_TARGET_DIRS))
  120. else
  121. distclean:
  122. ifdef inUnix
  123. { $(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; }
  124. else
  125. $(FPMAKE_BIN_CLEAN) distclean $(FPMAKE_OPT)
  126. endif
  127. -$(DEL) $(LOCALFPMAKE)
  128. -$(DEL) fpmake.o
  129. -$(DEL) fpmake.dbg
  130. endif
  131. cleanall: distclean
  132. install: fpmake$(SRCEXEEXT)
  133. ifdef UNIXHier
  134. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT)
  135. else
  136. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT)
  137. endif
  138. # distinstall also installs the example-sources and omits the location of the source-
  139. # files from the fpunits.cfg files.
  140. distinstall: fpmake$(SRCEXEEXT)
  141. ifdef UNIXHier
  142. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_PREFIX) --baseinstalldir=$(INSTALL_LIBDIR)/fpc/$(FPC_VERSION) $(FPMAKE_INSTALL_OPT) -ie -fsp 0
  143. else
  144. $(LOCALFPMAKE) install $(FPMAKE_OPT) --prefix=$(INSTALL_BASEDIR) --baseinstalldir=$(INSTALL_BASEDIR) $(FPMAKE_INSTALL_OPT) -ie -fsp 0
  145. endif
  146. zipinstall: fpmake$(SRCEXEEXT)
  147. $(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX)
  148. zipdistinstall: fpmake$(SRCEXEEXT)
  149. $(LOCALFPMAKE) zipinstall $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) -ie -fsp 0
  150. zipsourceinstall: fpmake$(SRCEXEEXT)
  151. ifdef UNIXHier
  152. $(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=share/src/fpc-\$$\(PACKAGEVERSION\)/$(INSTALL_FPCSUBDIR)/\$$\(PACKAGEDIRECTORY\)
  153. else
  154. $(LOCALFPMAKE) archive $(FPMAKE_OPT) --zipprefix=$(DIST_DESTDIR)/$(ZIPPREFIX) --prefix=source\\$(INSTALL_FPCSUBDIR)\\\$$\(PACKAGEDIRECTORY\)
  155. endif