Selaa lähdekoodia

build system: support for multiple modules dirs

Multiple modules directories are now supported.
The list of the modules directories is in Makefile.dirs in
 $(modules_dirs).
Name restrictions: the names must not match any makefile variable name
and they shouldn't contain any '-' char.

The modules and modules doc/READMEs will be installed in separate dirs
(e.g. for modules_dirs="modules modules_s modules_k" , the modules
 will be installed in .../lib/ser/modules , ...lib/ser/modules_s
 and ...lib/ser/modules_k).
The module man pages will all be installed in the same man dir
(but so far only some ser modules have man pages so we should be
safe).

New make targets:
every-module          -  make all the modules in all the module dirs
install-every-module  - like above, but install
install-every-module-doc
install-every-module-man

Targets dependent on $(modules_dirs) content:
$(m), $(m)-doc, $(m)-readme, $(m)-man, install-$(m),
install-$(m)-doc,  install-$(m)-man.

E.g.: for modules_dirs=modules modules_k modules_s
make modules - make all modules in the directory "modules".
make modules_k - make all the modules in the directory modules_k.
make every-module - make all the modules in the directories
                     modules, modules_k and modules_s.
make install-modules_s - install all the modules in the directory
                        modules_s.
Andrei Pelinescu-Onciul 16 vuotta sitten
vanhempi
commit
27cdfd2c39
7 muutettua tiedostoa jossa 251 lisäystä ja 142 poistoa
  1. 195 120
      Makefile
  2. 2 1
      Makefile.defs
  3. 23 0
      Makefile.dirs
  4. 9 7
      Makefile.modules
  5. 6 6
      Makefile.rules
  6. 1 1
      Makefile.sources
  7. 15 7
      Makefile.targets

+ 195 - 120
Makefile

@@ -56,6 +56,7 @@
 #              added cfg-defs, new target that only rebuilds config.mak
 #              added cfg-defs, new target that only rebuilds config.mak
 #  2009-03-10  replaced DEFS with C_DEFS (DEFS are now used only for
 #  2009-03-10  replaced DEFS with C_DEFS (DEFS are now used only for
 #              "temporary" defines inside modules or libs) (andrei)
 #              "temporary" defines inside modules or libs) (andrei)
+#  2009-03-27  multiple modules directory support, see modules_dirs (andrei)
 #  2009-04-02  workaround for export not supported in gnu make 3.80
 #  2009-04-02  workaround for export not supported in gnu make 3.80
 #               target specific variables: use mk_params for each
 #               target specific variables: use mk_params for each
 #               $(MAKE) invocation (andrei)
 #               $(MAKE) invocation (andrei)
@@ -89,6 +90,9 @@ skip_cfg_install?=
 #extra modules to exclude
 #extra modules to exclude
 skip_modules?=
 skip_modules?=
 
 
+# see Makefile.dirs for the directories used for the modules
+include Makefile.dirs
+
 # Set document format
 # Set document format
 # Alternatives are txt, html, xhtml, and pdf (see Makefile.doc)
 # Alternatives are txt, html, xhtml, and pdf (see Makefile.doc)
 doc_format?=html
 doc_format?=html
@@ -212,7 +216,7 @@ endif
 #
 #
 static_modules:=
 static_modules:=
 
 
-ALLDEP=config.mak Makefile Makefile.sources Makefile.rules
+ALLDEP=config.mak Makefile Makefile.dirs Makefile.sources Makefile.rules
 
 
 #include general defs (like CC, CFLAGS  a.s.o)
 #include general defs (like CC, CFLAGS  a.s.o)
 # hack to force makefile.defs re-inclusion (needed when make calls itself with
 # hack to force makefile.defs re-inclusion (needed when make calls itself with
@@ -260,23 +264,47 @@ export extra_defs
 # - exclude_modules
 # - exclude_modules
 
 
 ifneq ($(modules_configured),1) 
 ifneq ($(modules_configured),1) 
-modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
+#modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
+
+# create modules*_all vars
+$(foreach mods,$(modules_dirs),$(eval \
+	$(mods)_all=$$(filter-out $(mods)/CVS,$$(wildcard $(mods)/*))))
+#debugging
+#$(foreach mods,$(modules_dirs),$(info "$(mods)_all=$($(mods)_all)"))
+
 ifneq ($(group_include),)
 ifneq ($(group_include),)
-	modules=$(filter-out $(addprefix modules/, \
-			$(exclude_modules) $(static_modules)), \
-			$(addprefix modules/, $(include_modules) ))
+$(foreach mods,$(modules_dirs),$(eval \
+	$(mods)=$$(filter-out $$(addprefix $(mods)/, \
+			$$(exclude_modules) $$(static_modules)), \
+			$$(addprefix $(mods)/, $$(include_modules) )) ))
 else	
 else	
 	# Standard, old resultant set
 	# Standard, old resultant set
-	modules_noinc=$(filter-out $(addprefix modules/, \
-			$(exclude_modules) $(static_modules)), $(modules_all))
-	modules=$(filter-out $(modules_noinc), \
-				$(addprefix modules/, $(include_modules) )) $(modules_noinc)
+$(foreach mods,$(modules_dirs),$(eval \
+	$(mods)_noinc=$$(filter-out $$(addprefix $(mods)/, \
+			$$(exclude_modules) $$(static_modules)), $$($(mods)_all)) \
+))
+$(foreach mods,$(modules_dirs),$(eval \
+	$(mods)=$$(filter-out $$(modules_noinc), \
+			$$(addprefix $(mods)/, $$(include_modules) )) $$($(mods)_noinc) \
+))
 endif # ifneq($(group_include),)
 endif # ifneq($(group_include),)
 endif # ifneq($(modules_configured),1)
 endif # ifneq($(modules_configured),1)
-modules_names=$(shell echo $(modules)| \
-				sed -e 's/modules\/\([^/ ]*\)\/*/\1.so/g' )
-modules_basenames:=$(shell echo $(modules)| \
-				sed -e 's/modules\/\([^/ ]*\)\/*/\1/g' )
+
+$(foreach mods,$(modules_dirs),$(eval \
+	$(mods)_names=$$(shell echo $$($(mods))| \
+				sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1.so/g' ) \
+))
+$(foreach mods,$(modules_dirs),$(eval \
+	$(mods)_basenames:=$$(shell echo $$($(mods))| \
+				sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1/g' ) \
+))
+
+# all modules from all the $(modules_dirs)
+all_modules_lst=$(foreach mods,$(modules_dirs), $($(mods)_all))
+
+# compile modules list (all the compiled mods from  $(modules_dirs))
+cmodules=$(foreach mods,$(modules_dirs), $($(mods)))
+
 #modules_names=$(patsubst modules/%, %.so, $(modules))
 #modules_names=$(patsubst modules/%, %.so, $(modules))
 #modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
 #modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
 
 
@@ -356,14 +384,18 @@ endif # ifeq ($(config_mak),1)
 modules.lst:
 modules.lst:
 	@echo  saving modules list...
 	@echo  saving modules list...
 	@echo "# this file is autogenerated by make modules-cfg" >$@
 	@echo "# this file is autogenerated by make modules-cfg" >$@
+	@echo "modules_dirs:=$(modules_dirs)" >>$@
 	@echo "cfg_group_include=$(group_include)" >>$@
 	@echo "cfg_group_include=$(group_include)" >>$@
 	@$(call cfg_save_var2,include_modules,$@)
 	@$(call cfg_save_var2,include_modules,$@)
 	@$(call cfg_save_var2,static_modules,$@)
 	@$(call cfg_save_var2,static_modules,$@)
 	@$(call cfg_save_var2,skip_modules,$@)
 	@$(call cfg_save_var2,skip_modules,$@)
 	@$(call cfg_save_var2,exclude_modules,$@)
 	@$(call cfg_save_var2,exclude_modules,$@)
-	@$(call cfg_save_var2,modules_all,$@)
-	@$(call cfg_save_var2,modules_noinc,$@)
-	@$(call cfg_save_var2,modules,$@)
+	@$(foreach mods,$(modules_dirs), \
+		$(call cfg_save_var2,$(mods)_all,$@))
+	@$(foreach mods,$(modules_dirs), \
+		$(call cfg_save_var2,$(mods)_noinc,$@))
+	@$(foreach mods,$(modules_dirs), \
+		$(call cfg_save_var2,$(mods),$@))
 	@echo "modules_configured:=1" >>$@
 	@echo "modules_configured:=1" >>$@
 
 
 .PHONY: cfg config cfg-defs
 .PHONY: cfg config cfg-defs
@@ -377,7 +409,7 @@ modules-cfg modules-list modules-lst:
 	$(MAKE) modules.lst
 	$(MAKE) modules.lst
 
 
 .PHONY: all
 .PHONY: all
-all: $(NAME) modules
+all: $(NAME) every-module
 
 
 .PHONY: print-modules
 .PHONY: print-modules
 print-modules:
 print-modules:
@@ -386,16 +418,81 @@ print-modules:
 	echo ---------------------------------------------------------- ; \
 	echo ---------------------------------------------------------- ; \
 	echo The following modules will be excluded: $(exclude_modules) ; \
 	echo The following modules will be excluded: $(exclude_modules) ; \
 	echo ---------------------------------------------------------- ; \
 	echo ---------------------------------------------------------- ; \
-	echo The following modules will be made: $(modules_basenames) ; \
+	echo The following modules will be made; \
+	$(foreach mods,$(modules_dirs), \
+		echo $(mods)/: $($(mods)_basenames) ; ) \
+	#echo DBG: The following modules will be made: $(modules_basenames) ; \
+
 
 
-.PHONY: modules
-modules: modules.lst
-	@for r in $(modules) "" ; do \
-		if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
+# modules templates (instantiated based on modules_dirs contents)
+define MODULES_RULES_template
+
+$(1)_dst=$(modules_prefix)/$(modules_dir)$(1)
+
+.PHONY: $(1)
+$(1): modules.lst
+	@for r in $($(1)) "" ; do \
+		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
 			echo  "" ; \
 			echo  "" ; \
 			echo  "" ; \
 			echo  "" ; \
-			if  $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
-			then\
+			if  $(MAKE) -C $$$$r $$(mk_params) || [ ${err_fail} != 1 ] ; then \
+				:; \
+			else \
+				exit 1; \
+			fi ; \
+		fi ; \
+	done; true
+
+.PHONY: $(1)-doc
+$(1)-doc: modules.lst
+	@for r in $($(1)) "" ; do \
+		if [ -n "$$$$r" ]; then \
+			echo  "" ; \
+			echo  "" ; \
+			$(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
+		fi ; \
+	done
+
+.PHONY: $(1)-readme
+
+$(1)-readme: modules.lst
+	-@for r in $($(1)) "" ; do \
+		if [ -n "$$$$r" ]; then \
+			echo  "" ; \
+			echo  "" ; \
+			if  $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
+			then \
+				:; \
+			else \
+				exit 1; \
+			fi ; \
+		fi ; \
+	done; true
+
+.PHONY: $(1)-man
+$(1)-man: modules.lst
+	-@for r in $($(1)) "" ; do \
+		if [ -n "$$$$r" ]; then \
+			echo  "" ; \
+			echo  "" ; \
+			if  $(MAKE) -C $$$$r $$(mk_params) man || [ ${err_fail} != 1 ] ;\
+			then \
+				:; \
+			else \
+				exit 1; \
+			fi ; \
+		fi ; \
+	done; true
+
+.PHONY: install-$(1)
+
+install-$(1): modules.lst $$($(1)_dst)
+	@for r in $($(1)) "" ; do \
+		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
+			echo  "" ; \
+			echo  "" ; \
+			if  $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
+				|| [ ${err_fail} != 1 ] ; then \
 				:; \
 				:; \
 			else \
 			else \
 				exit 1; \
 				exit 1; \
@@ -403,6 +500,58 @@ modules: modules.lst
 		fi ; \
 		fi ; \
 	done; true
 	done; true
 
 
+
+.PHONY: install-$(1)-doc
+
+install-$(1)-doc: modules.lst $(doc_prefix)/$(doc_dir)$(1)
+	@for r in $($(1)_basenames) "" ; do \
+		if [ -n "$$$$r" ]; then \
+			if [ -f $(1)/"$$$$r"/README ]; then \
+				$$(call try_err,\
+					$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README ); \
+				$$(call try_err,\
+					$(INSTALL_DOC)  $(1)/"$$$$r"/README  \
+									$(doc_prefix)/$(doc_dir)$(1)/README ); \
+				$$(call try_err,\
+					mv -f $(doc_prefix)/$(doc_dir)$(1)/README \
+							$(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
+			fi ; \
+		fi ; \
+	done; true
+
+.PHONY: install-$(1)-man
+
+install-$(1)-man: $(1)-man $(man_prefix)/$(man_dir)/man7
+	@for r in $($(1)_basenames) "" ; do \
+		if [ -n "$$$$r" ]; then \
+			if [ -f $(1)/"$$$$r"/"$$$$r".7 ]; then \
+				$$(call try_err,\
+				  $(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$$$r".7 );\
+				$$(call try_err,\
+					$(INSTALL_MAN)  modules/"$$$$r"/"$$$$r".7  \
+									$(man_prefix)/$(man_dir)/man7 ); \
+			fi ; \
+		fi ; \
+	done; true
+
+
+$(modules_prefix)/$(modules_dir)$(1):
+		mkdir -p $$(@)
+
+$(doc_prefix)/$(doc_dir)$(1):
+		mkdir -p $$(@)
+
+
+endef
+
+# instantiate the template
+$(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
+
+#$(foreach mods,$(modules_dirs),$(eval  $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
+
+# build all the modules
+every-module: $(modules_dirs)
+
 $(extra_objs):
 $(extra_objs):
 	@echo "Extra objs: $(extra_objs)" 
 	@echo "Extra objs: $(extra_objs)" 
 	@for r in $(static_modules_path) "" ; do \
 	@for r in $(static_modules_path) "" ; do \
@@ -510,55 +659,10 @@ sunpkg:
 	rm -rf tmp/ser
 	rm -rf tmp/ser
 	rm -rf tmp/ser_sun_pkg
 	rm -rf tmp/ser_sun_pkg
 
 
-.PHONY: modules-doc
-modules-doc: modules.lst
-	-@for r in $(modules) "" ; do \
-		if [ -n "$$r" ]; then \
-			echo  "" ; \
-			echo  "" ; \
-			$(MAKE) -C $$r/doc $(doc_format)  $(mk_params); \
-		fi ; \
-	done 
-
-.PHONY: modules-readme
-modules-readme: README
-
-.PHONY: README
-README: modules.lst
-	-@for r in $(modules) "" ; do \
-		if [ -n "$$r" ]; then \
-			echo  "" ; \
-			echo  "" ; \
-			if  $(MAKE) -C $$r README $(mk_params) || \
-				[ ${err_fail} != 1 ] ; then \
-				:; \
-			else \
-				exit 1; \
-			fi ; \
-		fi ; \
-	done; true 
-
-.PHONY: modules-man
-modules-man: man
-
-.PHONY: man
-man: modules.lst
-	-@for r in $(modules) "" ; do \
-		if [ -n "$$r" ]; then \
-			echo  "" ; \
-			echo  "" ; \
-			if  $(MAKE) -C $$r man $(mk_params) || [ ${err_fail} != 1 ] ; \
-			then \
-				:; \
-			else \
-				exit 1; \
-			fi ; \
-		fi ; \
-	done; true
 
 
 .PHONY: install
 .PHONY: install
 install: mk_params="compile_for_install=yes"
 install: mk_params="compile_for_install=yes"
-install: install-bin install-modules install-cfg \
+install: install-bin install-every-module install-cfg \
 	install-doc install-man install-utils install-share
 	install-doc install-man install-utils install-share
 
 
 .PHONY: dbinstall
 .PHONY: dbinstall
@@ -567,11 +671,19 @@ dbinstall:
 	scripts/mysql/ser_mysql.sh create
 	scripts/mysql/ser_mysql.sh create
 	-@echo "Done"
 	-@echo "Done"
 
 
+.PHONY: README
+README: $(foreach mods,$(modules_dirs),$(mods)-readme)
+
+.PHONY: man
+man: $(foreach mods,$(modules_dirs),$(mods)-man)
+
 mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
 mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
 			$(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
 			$(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
 			$(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
 			$(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
-            $(share_prefix)/$(share_dir)
-
+			$(share_prefix)/$(share_dir) \
+			$(foreach mods,$(modules_dirs),\
+				$(modules_prefix)/$(modules_dir)$(mods) \
+				$(doc_prefix)/$(doc_dir)$(mods) )
 
 
 $(cfg_prefix)/$(cfg_dir): 
 $(cfg_prefix)/$(cfg_dir): 
 		mkdir -p $(cfg_prefix)/$(cfg_dir)
 		mkdir -p $(cfg_prefix)/$(cfg_dir)
@@ -585,7 +697,6 @@ $(share_prefix)/$(share_dir):
 $(modules_prefix)/$(modules_dir):
 $(modules_prefix)/$(modules_dir):
 		mkdir -p $(modules_prefix)/$(modules_dir)
 		mkdir -p $(modules_prefix)/$(modules_dir)
 
 
-
 $(doc_prefix)/$(doc_dir):
 $(doc_prefix)/$(doc_dir):
 		mkdir -p $(doc_prefix)/$(doc_dir)
 		mkdir -p $(doc_prefix)/$(doc_dir)
 
 
@@ -648,19 +759,12 @@ install-share: $(share_prefix)/$(share_dir)
 		fi ; \
 		fi ; \
 	done; true
 	done; true
 
 
-install-modules: modules.lst $(modules_prefix)/$(modules_dir)
-	@for r in $(modules) "" ; do \
-		if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
-			echo  "" ; \
-			echo  "" ; \
-			if  $(MAKE) -C $$r install $(mk_params) || \
-				[ ${err_fail} != 1 ] ; then \
-				:; \
-			else \
-				exit 1; \
-			fi ; \
-		fi ; \
-	done; true
+
+install-every-module: $(foreach mods,$(modules_dirs),install-$(mods))
+
+install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
+
+install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
 
 
 install-utils: utils $(bin_prefix)/$(bin_dir)
 install-utils: utils $(bin_prefix)/$(bin_dir)
 	@for r in $(utils_bin_install) "" ; do \
 	@for r in $(utils_bin_install) "" ; do \
@@ -700,10 +804,10 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
 	chmod 755 $(bin_prefix)/$(bin_dir)/ser_mysql.sh
 	chmod 755 $(bin_prefix)/$(bin_dir)/ser_mysql.sh
 
 
 
 
-install-modules-all: install-modules install-modules-doc
+install-modules-all: install-every-module install-every-module-doc
 
 
 
 
-install-doc: $(doc_prefix)/$(doc_dir) install-modules-doc
+install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL 
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL 
 	$(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
 	$(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES 
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES 
@@ -716,23 +820,6 @@ install-doc: $(doc_prefix)/$(doc_dir) install-modules-doc
 	$(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
 	$(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
 
 
 
 
-install-modules-doc: modules.lst $(doc_prefix)/$(doc_dir)
-	@for r in $(modules_basenames) "" ; do \
-		if [ -n "$$r" ]; then \
-			if [ -f modules/"$$r"/README ]; then \
-				$(call try_err,\
-					$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README ); \
-				$(call try_err,\
-					$(INSTALL_DOC)  modules/"$$r"/README  \
-									$(doc_prefix)/$(doc_dir)/README ); \
-				$(call try_err,\
-					mv -f $(doc_prefix)/$(doc_dir)/README \
-							$(doc_prefix)/$(doc_dir)/README."$$r" ); \
-			fi ; \
-		fi ; \
-	done; true
-
-
 install-ser-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
 install-ser-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
 		sed -e "s#/etc/ser/ser\.cfg#$(cfg_target)ser.cfg#g" \
 		sed -e "s#/etc/ser/ser\.cfg#$(cfg_target)ser.cfg#g" \
 			-e "s#/usr/sbin/#$(bin_target)#g" \
 			-e "s#/usr/sbin/#$(bin_target)#g" \
@@ -747,20 +834,8 @@ install-ser-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
 			< ser.cfg.5 >  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
 			< ser.cfg.5 >  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
 		chmod 644  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
 		chmod 644  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
 
 
-install-man:  install-ser-man install-modules-man
+install-man:  install-ser-man install-every-module-man
 
 
-install-modules-man: modules-man $(man_prefix)/$(man_dir)/man7
-	@for r in $(modules_basenames) "" ; do \
-		if [ -n "$$r" ]; then \
-			if [ -f modules/"$$r"/"$$r".7 ]; then \
-				$(call try_err,\
-					$(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$r".7 );\
-				$(call try_err,\
-					$(INSTALL_MAN)  modules/"$$r"/"$$r".7  \
-									$(man_prefix)/$(man_dir)/man7 ); \
-			fi ; \
-		fi ; \
-	done; true
 
 
 
 
 .PHONY: clean_libs
 .PHONY: clean_libs
@@ -775,7 +850,7 @@ clean:	clean_libs
 #try to clean everything (including all the modules, even ones that are not
 #try to clean everything (including all the modules, even ones that are not
 # configured/compiled normally
 # configured/compiled normally
 .PHONY: clean-all
 .PHONY: clean-all
-clean-all: modules=$(modules_all)
+clean-all: cmodules=$(all_modules_lst)
 clean-all: clean
 clean-all: clean
 
 
 # on make proper clean also the build config (w/o module list)
 # on make proper clean also the build config (w/o module list)
@@ -785,7 +860,7 @@ proper realclean distclean: clean_cfg
 maintainer-clean: clean_modules_cfg
 maintainer-clean: clean_modules_cfg
 
 
 .PHONY: proper-all realclean-all distclean-all
 .PHONY: proper-all realclean-all distclean-all
-proper-all realclean-all distclean-all: modules=$(modules_all)
+proper-all realclean-all distclean-all: cmodules=$(all_modules_lst)
 proper-all realclean-all distclean-all: proper
 proper-all realclean-all distclean-all: proper
 
 
 
 

+ 2 - 1
Makefile.defs

@@ -168,7 +168,8 @@ CC_EXTRA_OPTS ?=
 cfg_dir = etc/ser/
 cfg_dir = etc/ser/
 bin_dir = sbin/
 bin_dir = sbin/
 share_dir = share/ser/
 share_dir = share/ser/
-modules_dir = lib/ser/modules/
+# lib/ser/modules , lib/ser/modules-s, lib/ser/modules-k
+modules_dir = lib/ser/
 lib_dir = lib/ser/
 lib_dir = lib/ser/
 ifeq ($(OS), linux)
 ifeq ($(OS), linux)
 	doc_dir = share/doc/ser/
 	doc_dir = share/doc/ser/

+ 23 - 0
Makefile.dirs

@@ -0,0 +1,23 @@
+# $Id$
+#
+# path config makefile
+#
+# History:
+# --------
+#  2009-03-27  initial version (andrei)
+
+ifneq ($(makefile_dirs_included),1)
+
+override makefile_dirs_included:=1
+
+# modules directories
+# WARNING: - names must not conflict with any makefile variable or 
+#            target name
+#          - they should not contain '-' in them (portability: some exported
+#            var names might be derived from them and some shell do not 
+#            support '-' in variables)
+# makefile module related targets will be defined based on them:
+# install-$(1), install-$(1)-doc, $(1) a.s.o.
+modules_dirs= modules modules_s modules_k
+
+endif

+ 9 - 7
Makefile.modules

@@ -22,7 +22,7 @@ MOD_NAME=$(NAME:.so=)
 COREPATH ?=../..
 COREPATH ?=../..
 
 
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
- $(COREPATH)/Makefile.modules $(COREPATH)/config.mak
+ $(COREPATH)/Makefile.modules $(COREPATH)/Makefile.dirs $(COREPATH)/config.mak
 
 
 #override modules value, a module cannot have submodules
 #override modules value, a module cannot have submodules
 override modules=
 override modules=
@@ -65,22 +65,24 @@ endif
 
 
 
 
 
 
+include $(COREPATH)/Makefile.dirs
 include $(COREPATH)/Makefile.targets
 include $(COREPATH)/Makefile.targets
 include $(COREPATH)/Makefile.rules
 include $(COREPATH)/Makefile.rules
 
 
+# default: if not overwritten by the main Makefile, install in modules
+mods_dst=$(modules_prefix)/$(modules_dir)/modules
 
 
-
-$(modules_prefix)/$(modules_dir):
-		mkdir -p $(modules_prefix)/$(modules_dir)
+$(mods_dst):
+		mkdir -p $(mods_dst)
 
 
 LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
 LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
 
 
 
 
 .PHONY: install
 .PHONY: install
 .PHONY: install-libs
 .PHONY: install-libs
-install: $(NAME) $(modules_prefix)/$(modules_dir) install-libs
-	$(INSTALL_TOUCH) $(modules_prefix)/$(modules_dir)/$(NAME)
-	$(INSTALL_MODULES)  $(NAME)  $(modules_prefix)/$(modules_dir)
+install: $(NAME) $(mods_dst) install-libs
+	$(INSTALL_TOUCH) $(mods_dst)/$(NAME)
+	$(INSTALL_MODULES)  $(NAME)  $(mods_dst)
 
 
 install-libs:
 install-libs:
 	@for lib in $(dir $(SER_LIBS)); do \
 	@for lib in $(dir $(SER_LIBS)); do \

+ 6 - 6
Makefile.rules

@@ -162,7 +162,7 @@ makecfg.lst:
 			$(filter-out $(NOREBUILD_INCLUDES),\
 			$(filter-out $(NOREBUILD_INCLUDES),\
 				$(C_INCLUDES) $(INCLUDES))))) >>$@
 				$(C_INCLUDES) $(INCLUDES))))) >>$@
 .PHONY: all
 .PHONY: all
-all: $(NAME) modules
+all: $(NAME) every-module
 
 
 .PHONY: dep
 .PHONY: dep
 dep: $(depends)
 dep: $(depends)
@@ -173,14 +173,14 @@ static: $(objs)
 .PHONY: clean
 .PHONY: clean
 clean: 
 clean: 
 	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
 	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
-	-@for r in $(modules) $(static_modules_path) "" ; do \
+	-@for r in $(cmodules) $(static_modules_path) "" ; do \
 		if [ -d "$$r" ]; then \
 		if [ -d "$$r" ]; then \
 			echo "module $$r" ; \
 			echo "module $$r" ; \
 			$(MAKE) -C $$r clean ; \
 			$(MAKE) -C $$r clean ; \
 			$(MAKE) -C $$r/doc clean ; \
 			$(MAKE) -C $$r/doc clean ; \
 		fi ; \
 		fi ; \
 	done 
 	done 
-	@if [ -n "$(modules)" ]; then \
+	@if [ -n "$(cmodules)" ]; then \
 		for r in $(utils_compile) "" ; do \
 		for r in $(utils_compile) "" ; do \
 			if [ -d "$$r" ]; then \
 			if [ -d "$$r" ]; then \
 				 $(MAKE) -C $$r clean ; \
 				 $(MAKE) -C $$r clean ; \
@@ -196,13 +196,13 @@ proper realclean distclean: mrproper
 mrproper: clean 
 mrproper: clean 
 	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) \
 	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) \
 			makecfg.lst 2>/dev/null
 			makecfg.lst 2>/dev/null
-	-@for r in $(modules) "" ; do \
+	-@for r in $(cmodules) "" ; do \
 		if [ -d "$$r" ]; then \
 		if [ -d "$$r" ]; then \
 			$(MAKE) -C $$r proper ; \
 			$(MAKE) -C $$r proper ; \
 			$(MAKE) -C $$r/doc proper ; \
 			$(MAKE) -C $$r/doc proper ; \
 		fi ; \
 		fi ; \
 	done 
 	done 
-	@if [ -n "$(modules)" ]; then \
+	@if [ -n "$(cmodules)" ]; then \
 		for r in $(utils_compile) "" ; do \
 		for r in $(utils_compile) "" ; do \
 			if [ -d "$$r" ]; then \
 			if [ -d "$$r" ]; then \
 				 $(MAKE) -C $$r proper ; \
 				 $(MAKE) -C $$r proper ; \
@@ -213,7 +213,7 @@ mrproper: clean
 .PHONY: mantainer-cleaan
 .PHONY: mantainer-cleaan
 mantainer-clean: distclean
 mantainer-clean: distclean
 	-rm -f TAGS tags *.dbg .*.swp
 	-rm -f TAGS tags *.dbg .*.swp
-	-@for r in $(modules) "" ; do \
+	-@for r in $(cmodules) "" ; do \
 		if [ -d "$$r" ]; then \
 		if [ -d "$$r" ]; then \
 			$(MAKE) -C $$r mantainer-clean; \
 			$(MAKE) -C $$r mantainer-clean; \
 		fi ; \
 		fi ; \

+ 1 - 1
Makefile.sources

@@ -23,6 +23,6 @@ endif
 objs=$(sources:.c=.o)
 objs=$(sources:.c=.o)
 extra_objs=
 extra_objs=
 depends=$(sources:.c=.d)
 depends=$(sources:.c=.d)
-modules=
+cmodules=
 static_modules=
 static_modules=
 static_modules_path=
 static_modules_path=

+ 15 - 7
Makefile.targets

@@ -13,19 +13,27 @@
 #  2008-06-26  initial version (andrei) 
 #  2008-06-26  initial version (andrei) 
 #
 #
 
 
+ifeq (,$(strip $(modules_dirs)))
+include $(COREPATH)/Makefile.dirs
+endif
+
 clean_targets:=	clean proper distclean realclean mantainer-clean clean_libs \
 clean_targets:=	clean proper distclean realclean mantainer-clean clean_libs \
 				clean-all proper-all distclean-all realclean-all \
 				clean-all proper-all distclean-all realclean-all \
 				clean_cfg clean_modules_cfg clean-modules-cfg
 				clean_cfg clean_modules_cfg clean-modules-cfg
-doc_targets:=	modules-doc modules-readme README modules-man man \
-		install-doc install-modules-doc install-man install-ser-man \
-		install-modules-man
+doc_targets:=	README man install-doc install-man install-ser-man \
+		install-every-module-doc install-every-module-man \
+		$(foreach m,$(modules_dirs),$(m)-doc $(m)-readme $(m)-man) \
+		$(foreach m,$(modules_dirs),install-$(m)-doc install-$(m)-man)
+
 # auxiliary: maintance, debugging, etc. (don't affect code/objects)
 # auxiliary: maintance, debugging, etc. (don't affect code/objects)
 aux_targets:=	TAGS tar dist cfg-defs cfg config config.mak print-modules \
 aux_targets:=	TAGS tar dist cfg-defs cfg config config.mak print-modules \
-		dbg dbinstall librpath.lst makecfg.lst modules.lst
+		dbg dbinstall librpath.lst makecfg.lst \
+		modules-cfg modules-list modules-lst modules.lst mk-install_dirs
 # other targets that don't produce code in the current directory ("external")
 # other targets that don't produce code in the current directory ("external")
-ext_targets:=	modules libs utils \
-		install-cfg install-modules install-utils  install-modules-all \
-		install-share 
+ext_targets:=	every-module $(modules_dirs) libs utils \
+		install-cfg install-utils  install-modules-all install-every-module\
+		$(foreach m,$(modules_dirs),install-$(m)) \
+		install-share
 
 
 # all the targets that don't require code dependecies in the current dir.
 # all the targets that don't require code dependecies in the current dir.
 nodep_targets:=	$(clean_targets) $(doc_targets) $(aux_targets) $(ext_targets)
 nodep_targets:=	$(clean_targets) $(doc_targets) $(aux_targets) $(ext_targets)