Makefile.defs: version set 3.4.0-dev2
[sip-router] / Makefile.modules
index fab1bf9..cd391e6 100644 (file)
@@ -16,6 +16,8 @@
 #              inside modules or libs) (andrei)
 #  2009-10-01  added support for automatically installing extra utils,
 #               scripts and cfg files (andrei)
+#  2010-03-04  don't overwrite already installed .cfgs, save the .cfg as
+#              .sample in this case (andrei)
 #
 
 #
 #
 # MOD_INSTALL_CFGS - list of extra config files that should be installed in
 #                    the main config directory, along the module (OPTIONAL).
+#
+# MOD_INSTALL_SHARE - list of files to install into the arch-independent
+#                     shared directory (by default
+#                     /usr/local/share/$(MAIN_NAME))
+#
 
 MOD_NAME=$(NAME:.so=)
 
@@ -68,6 +75,14 @@ override static_modules_path=
 # temporary def (visible only in the module, not exported)
 DEFS += -DMOD_NAME='"$(MOD_NAME)"'
 
+
+ifeq (,$(findstring -DSER_MOD_INTERFACE, $(DEFS)))
+       MODIFACE=-DOPENSER_MOD_INTERFACE
+else
+       MODIFACE=-DSER_MOD_INTERFACE
+endif
+
+
 ifneq ($(makefile_defs_included),1)
 $(error "the local makefile does not include Makefile.defs!")
 endif
@@ -119,7 +134,7 @@ LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
 .PHONY: install-scripts
 .PHONY: install-cfgs
 install: $(NAME) $(mods_dst) install-libs install-utils install-scripts \
-               install-cfg
+               install-cfg install-share
        $(INSTALL_TOUCH) $(mods_dst)/$(NAME)
        $(INSTALL_MODULES)  $(NAME)  $(mods_dst)
 
@@ -134,14 +149,45 @@ install-libs:
 
 endif # $(SER_LIBS)
 
+.PHONY: utils
+.PHONY: clean-utils
+.PHONY: proper-utils
+.PHONY: distclean-utils
+.PHONY: realclean-utils
+.PHONY: maintainer-clean-utils
 ifneq (,$(MOD_INSTALL_UTILS))
 install-utils:
        @for ut in $(MOD_INSTALL_UTILS) ; do \
                $(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
        done; true
 
+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
+
 else
+# ! MOD_INSTALL_UTILS
 install-utils:
+utils:
+clean-utils:
+proper-utils realclean-utils distclean-utils maintainer-clean-utils:
 
 endif # $(MOD_INSTALL_UTILS)
 
@@ -173,10 +219,17 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
        @for r in $(MOD_INSTALL_CFGS) ; do \
                if [ -n "$$r" ]; then \
                        if [ -f "$$r" ]; then \
+                               n=`basename "$$r"` ; \
                                $(call try_err, $(INSTALL_TOUCH) \
-                                       $(cfg_prefix)/$(cfg_dir)/`basename "$$r"` ); \
+                                       "$(cfg_prefix)/$(cfg_dir)/$$n.sample" ); \
                                $(call try_err,\
-                                       $(INSTALL_CFG)  "$$r"  $(cfg_prefix)/$(cfg_dir) ); \
+                                       $(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 ; \
                        else \
                                echo "ERROR: $$r not found" ; \
                                if [ ${err_fail} = 1 ] ; then \
@@ -191,6 +244,29 @@ install-cfg:
 
 endif # $(MOD_INSTALL_CFGS)
 
+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)
+
 
 $(bin_prefix)/$(bin_dir):
        mkdir -p $@
@@ -198,11 +274,14 @@ $(bin_prefix)/$(bin_dir):
 $(cfg_prefix)/$(cfg_dir):
        mkdir -p $@
 
+$(share_prefix)/$(share_dir):
+       mkdir -p $@
+
 # README build rules
 ifneq (,$(wildcard doc/Makefile))
 #doc/Makefile present => we can generate README
 
-README: doc/*.xml
+README: doc/*.xml ../../docbook/entities.xml
        $(MAKE) -C doc $(MOD_NAME).txt
        mv doc/$(MOD_NAME).txt $@
 
@@ -226,6 +305,10 @@ man:
 
 endif
 
+
+printmiface:
+       @echo -n $(MODIFACE)
+
 endif # ifeq($(makefile_defs),1)
 
 include $(COREPATH)/Makefile.cfg