Makefile.modules
30351861
 # Kamailio build system
247c2b65
 #
 # module Makefile
 #(to be included from each module)
 #
3922c022
 #
 
6bfac69a
 #
 # Variables that should be defined in the modules, prior to including
 # this makefile:
 #
 # NAME - module binary name, complete with .so and no path (MUST).
 #
 # COREPATH - path to the main/core directory (OPTIONAL, default ../..)
 #
 # DEFS - per module extra defines (OPTIONAL)
 #
 # LIBS - per module extra libs (OPTIONAL)
 #
 # SER_LIBS - ser/sr libs that should be compiled, linked against and installed
 #           along the module. The format is: <path>/<shortname>, e.g.
 #           SER_LIBS=../../lib/srdb2/srdb2 for libsrdb2 with the sources
 #            in ../../lib/srdb2. (OPTIONAL)
 #
 # MOD_INSTALL_UTILS - list of utils directories that should be compiled and
 #                     installed along the module. The utils must know how to
 #                     install themselves (make install).
 #                     E.g.: MOD_INSTALL_UTILS=../../utils/sercmd
 #                     (OPTIONAL)
 #
 # MOD_INSTALL_SCRIPTS - list of scripts (complete path including the file name)
 #                       that should be installed along the module.
 #                       E.g.: MOD_INSTALL_SCRIPTS=../../scripts/foo/foo.sh
 #                       (OPTIONAL)
 #
 # MOD_INSTALL_CFGS - list of extra config files that should be installed in
 #                    the main config directory, along the module (OPTIONAL).
80c36172
 #
 # MOD_INSTALL_SHARE - list of files to install into the arch-independent
 #                     shared directory (by default
 #                     /usr/local/share/$(MAIN_NAME))
 #
6bfac69a
 
404073d3
 MOD_NAME=$(NAME:.so=)
247c2b65
 
5f4d291d
 # allow placing modules in separate directory apart from ser core
ad1e3e5c
 COREPATH ?=../..
 
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
27cdfd2c
  $(COREPATH)/Makefile.modules $(COREPATH)/Makefile.dirs $(COREPATH)/config.mak
247c2b65
 
3431bcad
 #override modules value, a module cannot have submodules
 override modules=
 override static_modules=
 override static_modules_path=
 
f072585d
 # should be set in the Makefile of each module
0973fee7
 # INCLUDES += -I$(COREPATH)
3431bcad
 
f072585d
 # temporary def (visible only in the module, not exported)
bf79b581
 DEFS += -DMOD_NAME='"$(MOD_NAME)"'
 
6fb2e27d
 
 ifeq (,$(findstring -DSER_MOD_INTERFACE, $(DEFS)))
5e886dbb
 	MODIFACE=-DKAMAILIO_MOD_INTERFACE
6fb2e27d
 else
 	MODIFACE=-DSER_MOD_INTERFACE
 endif
 
 
7742b1d2
 ifneq ($(makefile_defs_included),1)
 $(error "the local makefile does not include Makefile.defs!")
 endif
 
247c2b65
 ifeq ($(MAKELEVEL), 0)
 # make called directly in the module dir!
 
3922c022
 #$(warning "you should run make from the main ser directory")
247c2b65
 
 else
 # called by the main Makefile
 
5f4d291d
 ALLDEP+=$(COREPATH)/Makefile
247c2b65
 
 endif
 
ad1e3e5c
 include $(COREPATH)/Makefile.sources
247c2b65
 
7742b1d2
 
 # if config was not loaded (makefile_defs!=1) ignore
 # the rest of makefile and try only to remake the config
 ifeq ($(makefile_defs),1)
 
404073d3
 ifeq (,$(filter $(MOD_NAME), $(static_modules)))
247c2b65
 CFLAGS:=$(MOD_CFLAGS)
 LDFLAGS:=$(MOD_LDFLAGS)
404073d3
 endif
247c2b65
 
3922c022
 
f3749500
 err_fail?=1
7742b1d2
 
27cdfd2c
 include $(COREPATH)/Makefile.dirs
eefcb29d
 include $(COREPATH)/Makefile.targets
ad1e3e5c
 include $(COREPATH)/Makefile.rules
f3749500
 include $(COREPATH)/Makefile.shared
3922c022
 
27cdfd2c
 # default: if not overwritten by the main Makefile, install in modules
 mods_dst=$(modules_prefix)/$(modules_dir)/modules
3922c022
 
27cdfd2c
 $(mods_dst):
 		mkdir -p $(mods_dst)
28b28d2c
 
a9ef1060
 LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
3922c022
 
 
 .PHONY: install
da33ba73
 .PHONY: install-libs
6bfac69a
 .PHONY: install-utils
 .PHONY: install-scripts
 .PHONY: install-cfgs
 install: $(NAME) $(mods_dst) install-libs install-utils install-scripts \
80c36172
 		install-cfg install-share
27cdfd2c
 	$(INSTALL_TOUCH) $(mods_dst)/$(NAME)
 	$(INSTALL_MODULES)  $(NAME)  $(mods_dst)
da33ba73
 
6bfac69a
 ifneq (,$(SER_LIBS))
da33ba73
 install-libs:
6bfac69a
 	@for lib in $(dir $(SER_LIBS)) ; do \
f3749500
 		$(call try_err, $(MAKE) -C "$${lib}" install-if-newer ) ;\
6bfac69a
 	done; true
 
 else
 install-libs:
 
 endif # $(SER_LIBS)
 
b8e67fd6
 .PHONY: utils
 .PHONY: clean-utils
 .PHONY: proper-utils
 .PHONY: distclean-utils
 .PHONY: realclean-utils
 .PHONY: maintainer-clean-utils
6bfac69a
 ifneq (,$(MOD_INSTALL_UTILS))
 install-utils:
 	@for ut in $(MOD_INSTALL_UTILS) ; do \
 		$(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
 	done; true
 
b8e67fd6
 utils:
 	@for r in $(MOD_INSTALL_UTILS) ; do \
 		$(call try_err, $(MAKE) -C "$$r" ) ;\
 	done; true
 
 clean-utils:
 	@for r in $(MOD_INSTALL_UTILS) ; do \
 		if [ -d "$$r" ]; then \
 			 $(MAKE) -C "$$r" clean ; \
 		fi ; \
 	done
 
 proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
  clean_target=$(patsubst %-utils,%,$@)
 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
 	@for r in $(MOD_INSTALL_UTILS) ; do \
 		if [ -d "$$r" ]; then \
 			 $(MAKE) -C "$$r" $(clean_target); \
 		fi ; \
 	done
 
6bfac69a
 else
b8e67fd6
 # ! MOD_INSTALL_UTILS
6bfac69a
 install-utils:
b8e67fd6
 utils:
 clean-utils:
 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
6bfac69a
 
 endif # $(MOD_INSTALL_UTILS)
 
 ifneq (,$(MOD_INSTALL_SCRIPTS))
 install-scripts: $(bin_prefix)/$(bin_dir)
 	@for r in $(MOD_INSTALL_SCRIPTS) ; do \
 		if [ -n "$$r" ]; then \
 			if [ -f "$$r" ]; then \
 				$(call try_err, $(INSTALL_TOUCH) \
 					$(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
 				$(call try_err,\
 					$(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
 			else \
 				echo "ERROR: $$r not found" ; \
 				if [ ${err_fail} = 1 ] ; then \
 					exit 1; \
 				fi ; \
 			fi ; \
 		fi ; \
 	done; true
 
 else
 install-scripts:
 
 endif # $(MOD_INSTALL_SCRIPTS)
 
 ifneq (,$(MOD_INSTALL_CFGS))
 install-cfg: $(cfg_prefix)/$(cfg_dir)
 	@for r in $(MOD_INSTALL_CFGS) ; do \
 		if [ -n "$$r" ]; then \
 			if [ -f "$$r" ]; then \
6c0de646
 				n=`basename "$$r"` ; \
6bfac69a
 				$(call try_err, $(INSTALL_TOUCH) \
6c0de646
 					"$(cfg_prefix)/$(cfg_dir)/$$n.sample" ); \
6bfac69a
 				$(call try_err,\
6c0de646
 					$(INSTALL_CFG)  "$$r"  \
 						"$(cfg_prefix)/$(cfg_dir)/$$n.sample"); \
 				if [ -z "${skip_cfg_install}" -a \
 						! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; then \
 					mv -f $(cfg_prefix)/$(cfg_dir)$$n.sample \
 						$(cfg_prefix)/$(cfg_dir)$$n; \
 				fi ; \
6bfac69a
 			else \
 				echo "ERROR: $$r not found" ; \
 				if [ ${err_fail} = 1 ] ; then \
 					exit 1; \
 				fi ; \
 			fi ; \
 		fi ; \
 	done; true
 
 else
 install-cfg:
 
 endif # $(MOD_INSTALL_CFGS)
 
80c36172
 ifneq (,$(MOD_INSTALL_SHARE))
 install-share: $(share_prefix)/$(share_dir)
 	@for r in $(MOD_INSTALL_SHARE) ; do \
 		if [ -n "$$r" ]; then \
 			if [ -f "$$r" ]; then \
 				$(call try_err, $(INSTALL_TOUCH) \
 					$(share_prefix)/$(share_dir)/`basename "$$r"` ); \
 				$(call try_err,\
 					$(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) ); \
 			else \
 				echo "ERROR: $$r not found" ; \
 				if [ ${err_fail} = 1 ] ; then \
 					exit 1; \
 				fi ; \
 			fi ; \
 		fi ; \
 	done; true
 
 else
 install-share:
 
 endif # $(MOD_INSTALL_SHARE)
 
6bfac69a
 
 $(bin_prefix)/$(bin_dir):
 	mkdir -p $@
 
 $(cfg_prefix)/$(cfg_dir):
 	mkdir -p $@
a51f9e36
 
80c36172
 $(share_prefix)/$(share_dir):
 	mkdir -p $@
 
617ced39
 # README build rules
 ifneq (,$(wildcard doc/Makefile))
 #doc/Makefile present => we can generate README
 
d9bb387b
 README: doc/*.xml ../../docbook/entities.xml
617ced39
 	$(MAKE) -C doc $(MOD_NAME).txt
8c6e0b05
 	mv doc/$(MOD_NAME).txt $@
617ced39
 
 else
 # do nothing
 
 README:
 endif
 
 #man page build rules
 ifneq (,$(wildcard $(MOD_NAME).xml))
 
 $(MOD_NAME).7: $(MOD_NAME).xml
c9088190
 	$(DOCBOOK) -s ../../doc/stylesheets/serdoc2man.xsl $<
617ced39
 
 man: $(MOD_NAME).7
 
 else
 
 man:
 
 endif
7742b1d2
 
6fb2e27d
 
 printmiface:
c7566f66
 	@echo -n $(MODIFACE)
6fb2e27d
 
7742b1d2
 endif # ifeq($(makefile_defs),1)
 
 include $(COREPATH)/Makefile.cfg