Makefile.modules 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #
  2. # $Id$
  3. #
  4. # module Makefile
  5. #(to be included from each module)
  6. #
  7. # History:
  8. # --------
  9. # 2007-03-29 if a module depends on SER_LIBS, it will be rebuilt on install
  10. # with the proper rpath; libraries will be automatically
  11. # installed if needed (andrei)
  12. # 2008-06-23 added the README & man targets (andrei)
  13. # 2008-06-27 make cfg / config.mak support (andrei)
  14. # 2009-03-10 replaced DEFS with C_DEFS and INCLUDES with C_INCLUDES (DEFS
  15. # and INCLUDES are now used only for "temporary" defines/includes
  16. # inside modules or libs) (andrei)
  17. #
  18. MOD_NAME=$(NAME:.so=)
  19. # allow placing modules in separate directory apart from ser core
  20. COREPATH ?=../..
  21. ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
  22. $(COREPATH)/Makefile.modules $(COREPATH)/config.mak
  23. #override modules value, a module cannot have submodules
  24. override modules=
  25. override static_modules=
  26. override static_modules_path=
  27. # should be set in the Makefile of each module
  28. # INCLUDES += -I$(COREPATH)
  29. # temporary def (visible only in the module, not exported)
  30. DEFS += -DMOD_NAME='"$(MOD_NAME)"'
  31. ifneq ($(makefile_defs_included),1)
  32. $(error "the local makefile does not include Makefile.defs!")
  33. endif
  34. ifeq ($(MAKELEVEL), 0)
  35. # make called directly in the module dir!
  36. #$(warning "you should run make from the main ser directory")
  37. else
  38. # called by the main Makefile
  39. ALLDEP+=$(COREPATH)/Makefile
  40. endif
  41. include $(COREPATH)/Makefile.sources
  42. # if config was not loaded (makefile_defs!=1) ignore
  43. # the rest of makefile and try only to remake the config
  44. ifeq ($(makefile_defs),1)
  45. ifeq (,$(filter $(MOD_NAME), $(static_modules)))
  46. CFLAGS:=$(MOD_CFLAGS)
  47. LDFLAGS:=$(MOD_LDFLAGS)
  48. endif
  49. include $(COREPATH)/Makefile.targets
  50. include $(COREPATH)/Makefile.rules
  51. $(modules_prefix)/$(modules_dir):
  52. mkdir -p $(modules_prefix)/$(modules_dir)
  53. LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
  54. .PHONY: install
  55. .PHONY: install-libs
  56. install: $(NAME) $(modules_prefix)/$(modules_dir) install-libs
  57. $(INSTALL_TOUCH) $(modules_prefix)/$(modules_dir)/$(NAME)
  58. $(INSTALL_MODULES) $(NAME) $(modules_prefix)/$(modules_dir)
  59. install-libs:
  60. @for lib in $(dir $(SER_LIBS)); do \
  61. $(MAKE) -C "$${lib}" install-if-newer ;\
  62. done
  63. # README build rules
  64. ifneq (,$(wildcard doc/Makefile))
  65. #doc/Makefile present => we can generate README
  66. README: doc/*.xml
  67. $(MAKE) -C doc $(MOD_NAME).txt
  68. cp doc/$(MOD_NAME).txt $@
  69. else
  70. # do nothing
  71. README:
  72. endif
  73. #man page build rules
  74. ifneq (,$(wildcard $(MOD_NAME).xml))
  75. $(MOD_NAME).7: $(MOD_NAME).xml
  76. docbook2x-man -s ../../doc/stylesheets/serdoc2man.xsl $<
  77. man: $(MOD_NAME).7
  78. else
  79. man:
  80. endif
  81. endif # ifeq($(makefile_defs),1)
  82. include $(COREPATH)/Makefile.cfg