Browse code

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 authored on 27/03/2009 19:44:36
Showing 7 changed files
... ...
@@ -56,6 +56,7 @@
56 56
 #              added cfg-defs, new target that only rebuilds config.mak
57 57
 #  2009-03-10  replaced DEFS with C_DEFS (DEFS are now used only for
58 58
 #              "temporary" defines inside modules or libs) (andrei)
59
+#  2009-03-27  multiple modules directory support, see modules_dirs (andrei)
59 60
 #  2009-04-02  workaround for export not supported in gnu make 3.80
60 61
 #               target specific variables: use mk_params for each
61 62
 #               $(MAKE) invocation (andrei)
... ...
@@ -89,6 +90,9 @@ skip_cfg_install?=
89 90
 #extra modules to exclude
90 91
 skip_modules?=
91 92
 
93
+# see Makefile.dirs for the directories used for the modules
94
+include Makefile.dirs
95
+
92 96
 # Set document format
93 97
 # Alternatives are txt, html, xhtml, and pdf (see Makefile.doc)
94 98
 doc_format?=html
... ...
@@ -212,7 +216,7 @@ endif
212 216
 #
213 217
 static_modules:=
214 218
 
215
-ALLDEP=config.mak Makefile Makefile.sources Makefile.rules
219
+ALLDEP=config.mak Makefile Makefile.dirs Makefile.sources Makefile.rules
216 220
 
217 221
 #include general defs (like CC, CFLAGS  a.s.o)
218 222
 # hack to force makefile.defs re-inclusion (needed when make calls itself with
... ...
@@ -260,23 +264,47 @@ export extra_defs
260 264
 # - exclude_modules
261 265
 
262 266
 ifneq ($(modules_configured),1) 
263
-modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
267
+#modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
268
+
269
+# create modules*_all vars
270
+$(foreach mods,$(modules_dirs),$(eval \
271
+	$(mods)_all=$$(filter-out $(mods)/CVS,$$(wildcard $(mods)/*))))
272
+#debugging
273
+#$(foreach mods,$(modules_dirs),$(info "$(mods)_all=$($(mods)_all)"))
274
+
264 275
 ifneq ($(group_include),)
265
-	modules=$(filter-out $(addprefix modules/, \
266
-			$(exclude_modules) $(static_modules)), \
267
-			$(addprefix modules/, $(include_modules) ))
276
+$(foreach mods,$(modules_dirs),$(eval \
277
+	$(mods)=$$(filter-out $$(addprefix $(mods)/, \
278
+			$$(exclude_modules) $$(static_modules)), \
279
+			$$(addprefix $(mods)/, $$(include_modules) )) ))
268 280
 else	
269 281
 	# Standard, old resultant set
270
-	modules_noinc=$(filter-out $(addprefix modules/, \
271
-			$(exclude_modules) $(static_modules)), $(modules_all))
272
-	modules=$(filter-out $(modules_noinc), \
273
-				$(addprefix modules/, $(include_modules) )) $(modules_noinc)
282
+$(foreach mods,$(modules_dirs),$(eval \
283
+	$(mods)_noinc=$$(filter-out $$(addprefix $(mods)/, \
284
+			$$(exclude_modules) $$(static_modules)), $$($(mods)_all)) \
285
+))
286
+$(foreach mods,$(modules_dirs),$(eval \
287
+	$(mods)=$$(filter-out $$(modules_noinc), \
288
+			$$(addprefix $(mods)/, $$(include_modules) )) $$($(mods)_noinc) \
289
+))
274 290
 endif # ifneq($(group_include),)
275 291
 endif # ifneq($(modules_configured),1)
276
-modules_names=$(shell echo $(modules)| \
277
-				sed -e 's/modules\/\([^/ ]*\)\/*/\1.so/g' )
278
-modules_basenames:=$(shell echo $(modules)| \
279
-				sed -e 's/modules\/\([^/ ]*\)\/*/\1/g' )
292
+
293
+$(foreach mods,$(modules_dirs),$(eval \
294
+	$(mods)_names=$$(shell echo $$($(mods))| \
295
+				sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1.so/g' ) \
296
+))
297
+$(foreach mods,$(modules_dirs),$(eval \
298
+	$(mods)_basenames:=$$(shell echo $$($(mods))| \
299
+				sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1/g' ) \
300
+))
301
+
302
+# all modules from all the $(modules_dirs)
303
+all_modules_lst=$(foreach mods,$(modules_dirs), $($(mods)_all))
304
+
305
+# compile modules list (all the compiled mods from  $(modules_dirs))
306
+cmodules=$(foreach mods,$(modules_dirs), $($(mods)))
307
+
280 308
 #modules_names=$(patsubst modules/%, %.so, $(modules))
281 309
 #modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
282 310
 
... ...
@@ -356,14 +384,18 @@ endif # ifeq ($(config_mak),1)
356 384
 modules.lst:
357 385
 	@echo  saving modules list...
358 386
 	@echo "# this file is autogenerated by make modules-cfg" >$@
387
+	@echo "modules_dirs:=$(modules_dirs)" >>$@
359 388
 	@echo "cfg_group_include=$(group_include)" >>$@
360 389
 	@$(call cfg_save_var2,include_modules,$@)
361 390
 	@$(call cfg_save_var2,static_modules,$@)
362 391
 	@$(call cfg_save_var2,skip_modules,$@)
363 392
 	@$(call cfg_save_var2,exclude_modules,$@)
364
-	@$(call cfg_save_var2,modules_all,$@)
365
-	@$(call cfg_save_var2,modules_noinc,$@)
366
-	@$(call cfg_save_var2,modules,$@)
393
+	@$(foreach mods,$(modules_dirs), \
394
+		$(call cfg_save_var2,$(mods)_all,$@))
395
+	@$(foreach mods,$(modules_dirs), \
396
+		$(call cfg_save_var2,$(mods)_noinc,$@))
397
+	@$(foreach mods,$(modules_dirs), \
398
+		$(call cfg_save_var2,$(mods),$@))
367 399
 	@echo "modules_configured:=1" >>$@
368 400
 
369 401
 .PHONY: cfg config cfg-defs
... ...
@@ -377,7 +409,7 @@ modules-cfg modules-list modules-lst:
377 409
 	$(MAKE) modules.lst
378 410
 
379 411
 .PHONY: all
380
-all: $(NAME) modules
412
+all: $(NAME) every-module
381 413
 
382 414
 .PHONY: print-modules
383 415
 print-modules:
... ...
@@ -386,16 +418,81 @@ print-modules:
386 418
 	echo ---------------------------------------------------------- ; \
387 419
 	echo The following modules will be excluded: $(exclude_modules) ; \
388 420
 	echo ---------------------------------------------------------- ; \
389
-	echo The following modules will be made: $(modules_basenames) ; \
421
+	echo The following modules will be made; \
422
+	$(foreach mods,$(modules_dirs), \
423
+		echo $(mods)/: $($(mods)_basenames) ; ) \
424
+	#echo DBG: The following modules will be made: $(modules_basenames) ; \
425
+
390 426
 
391
-.PHONY: modules
392
-modules: modules.lst
393
-	@for r in $(modules) "" ; do \
394
-		if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
427
+# modules templates (instantiated based on modules_dirs contents)
428
+define MODULES_RULES_template
429
+
430
+$(1)_dst=$(modules_prefix)/$(modules_dir)$(1)
431
+
432
+.PHONY: $(1)
433
+$(1): modules.lst
434
+	@for r in $($(1)) "" ; do \
435
+		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
395 436
 			echo  "" ; \
396 437
 			echo  "" ; \
397
-			if  $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
398
-			then\
438
+			if  $(MAKE) -C $$$$r $$(mk_params) || [ ${err_fail} != 1 ] ; then \
439
+				:; \
440
+			else \
441
+				exit 1; \
442
+			fi ; \
443
+		fi ; \
444
+	done; true
445
+
446
+.PHONY: $(1)-doc
447
+$(1)-doc: modules.lst
448
+	@for r in $($(1)) "" ; do \
449
+		if [ -n "$$$$r" ]; then \
450
+			echo  "" ; \
451
+			echo  "" ; \
452
+			$(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
453
+		fi ; \
454
+	done
455
+
456
+.PHONY: $(1)-readme
457
+
458
+$(1)-readme: modules.lst
459
+	-@for r in $($(1)) "" ; do \
460
+		if [ -n "$$$$r" ]; then \
461
+			echo  "" ; \
462
+			echo  "" ; \
463
+			if  $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
464
+			then \
465
+				:; \
466
+			else \
467
+				exit 1; \
468
+			fi ; \
469
+		fi ; \
470
+	done; true
471
+
472
+.PHONY: $(1)-man
473
+$(1)-man: modules.lst
474
+	-@for r in $($(1)) "" ; do \
475
+		if [ -n "$$$$r" ]; then \
476
+			echo  "" ; \
477
+			echo  "" ; \
478
+			if  $(MAKE) -C $$$$r $$(mk_params) man || [ ${err_fail} != 1 ] ;\
479
+			then \
480
+				:; \
481
+			else \
482
+				exit 1; \
483
+			fi ; \
484
+		fi ; \
485
+	done; true
486
+
487
+.PHONY: install-$(1)
488
+
489
+install-$(1): modules.lst $$($(1)_dst)
490
+	@for r in $($(1)) "" ; do \
491
+		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
492
+			echo  "" ; \
493
+			echo  "" ; \
494
+			if  $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
495
+				|| [ ${err_fail} != 1 ] ; then \
399 496
 				:; \
400 497
 			else \
401 498
 				exit 1; \
... ...
@@ -403,6 +500,58 @@ modules: modules.lst
403 500
 		fi ; \
404 501
 	done; true
405 502
 
503
+
504
+.PHONY: install-$(1)-doc
505
+
506
+install-$(1)-doc: modules.lst $(doc_prefix)/$(doc_dir)$(1)
507
+	@for r in $($(1)_basenames) "" ; do \
508
+		if [ -n "$$$$r" ]; then \
509
+			if [ -f $(1)/"$$$$r"/README ]; then \
510
+				$$(call try_err,\
511
+					$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README ); \
512
+				$$(call try_err,\
513
+					$(INSTALL_DOC)  $(1)/"$$$$r"/README  \
514
+									$(doc_prefix)/$(doc_dir)$(1)/README ); \
515
+				$$(call try_err,\
516
+					mv -f $(doc_prefix)/$(doc_dir)$(1)/README \
517
+							$(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
518
+			fi ; \
519
+		fi ; \
520
+	done; true
521
+
522
+.PHONY: install-$(1)-man
523
+
524
+install-$(1)-man: $(1)-man $(man_prefix)/$(man_dir)/man7
525
+	@for r in $($(1)_basenames) "" ; do \
526
+		if [ -n "$$$$r" ]; then \
527
+			if [ -f $(1)/"$$$$r"/"$$$$r".7 ]; then \
528
+				$$(call try_err,\
529
+				  $(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$$$r".7 );\
530
+				$$(call try_err,\
531
+					$(INSTALL_MAN)  modules/"$$$$r"/"$$$$r".7  \
532
+									$(man_prefix)/$(man_dir)/man7 ); \
533
+			fi ; \
534
+		fi ; \
535
+	done; true
536
+
537
+
538
+$(modules_prefix)/$(modules_dir)$(1):
539
+		mkdir -p $$(@)
540
+
541
+$(doc_prefix)/$(doc_dir)$(1):
542
+		mkdir -p $$(@)
543
+
544
+
545
+endef
546
+
547
+# instantiate the template
548
+$(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
549
+
550
+#$(foreach mods,$(modules_dirs),$(eval  $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
551
+
552
+# build all the modules
553
+every-module: $(modules_dirs)
554
+
406 555
 $(extra_objs):
407 556
 	@echo "Extra objs: $(extra_objs)" 
408 557
 	@for r in $(static_modules_path) "" ; do \
... ...
@@ -510,55 +659,10 @@ sunpkg:
510 659
 	rm -rf tmp/ser
511 660
 	rm -rf tmp/ser_sun_pkg
512 661
 
513
-.PHONY: modules-doc
514
-modules-doc: modules.lst
515
-	-@for r in $(modules) "" ; do \
516
-		if [ -n "$$r" ]; then \
517
-			echo  "" ; \
518
-			echo  "" ; \
519
-			$(MAKE) -C $$r/doc $(doc_format)  $(mk_params); \
520
-		fi ; \
521
-	done 
522
-
523
-.PHONY: modules-readme
524
-modules-readme: README
525
-
526
-.PHONY: README
527
-README: modules.lst
528
-	-@for r in $(modules) "" ; do \
529
-		if [ -n "$$r" ]; then \
530
-			echo  "" ; \
531
-			echo  "" ; \
532
-			if  $(MAKE) -C $$r README $(mk_params) || \
533
-				[ ${err_fail} != 1 ] ; then \
534
-				:; \
535
-			else \
536
-				exit 1; \
537
-			fi ; \
538
-		fi ; \
539
-	done; true 
540
-
541
-.PHONY: modules-man
542
-modules-man: man
543
-
544
-.PHONY: man
545
-man: modules.lst
546
-	-@for r in $(modules) "" ; do \
547
-		if [ -n "$$r" ]; then \
548
-			echo  "" ; \
549
-			echo  "" ; \
550
-			if  $(MAKE) -C $$r man $(mk_params) || [ ${err_fail} != 1 ] ; \
551
-			then \
552
-				:; \
553
-			else \
554
-				exit 1; \
555
-			fi ; \
556
-		fi ; \
557
-	done; true
558 662
 
559 663
 .PHONY: install
560 664
 install: mk_params="compile_for_install=yes"
561
-install: install-bin install-modules install-cfg \
665
+install: install-bin install-every-module install-cfg \
562 666
 	install-doc install-man install-utils install-share
563 667
 
564 668
 .PHONY: dbinstall
... ...
@@ -567,11 +671,19 @@ dbinstall:
567 671
 	scripts/mysql/ser_mysql.sh create
568 672
 	-@echo "Done"
569 673
 
674
+.PHONY: README
675
+README: $(foreach mods,$(modules_dirs),$(mods)-readme)
676
+
677
+.PHONY: man
678
+man: $(foreach mods,$(modules_dirs),$(mods)-man)
679
+
570 680
 mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
571 681
 			$(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
572 682
 			$(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
573
-            $(share_prefix)/$(share_dir)
574
-
683
+			$(share_prefix)/$(share_dir) \
684
+			$(foreach mods,$(modules_dirs),\
685
+				$(modules_prefix)/$(modules_dir)$(mods) \
686
+				$(doc_prefix)/$(doc_dir)$(mods) )
575 687
 
576 688
 $(cfg_prefix)/$(cfg_dir): 
577 689
 		mkdir -p $(cfg_prefix)/$(cfg_dir)
... ...
@@ -585,7 +697,6 @@ $(share_prefix)/$(share_dir):
585 697
 $(modules_prefix)/$(modules_dir):
586 698
 		mkdir -p $(modules_prefix)/$(modules_dir)
587 699
 
588
-
589 700
 $(doc_prefix)/$(doc_dir):
590 701
 		mkdir -p $(doc_prefix)/$(doc_dir)
591 702
 
... ...
@@ -648,19 +759,12 @@ install-share: $(share_prefix)/$(share_dir)
648 759
 		fi ; \
649 760
 	done; true
650 761
 
651
-install-modules: modules.lst $(modules_prefix)/$(modules_dir)
652
-	@for r in $(modules) "" ; do \
653
-		if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
654
-			echo  "" ; \
655
-			echo  "" ; \
656
-			if  $(MAKE) -C $$r install $(mk_params) || \
657
-				[ ${err_fail} != 1 ] ; then \
658
-				:; \
659
-			else \
660
-				exit 1; \
661
-			fi ; \
662
-		fi ; \
663
-	done; true
762
+
763
+install-every-module: $(foreach mods,$(modules_dirs),install-$(mods))
764
+
765
+install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
766
+
767
+install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
664 768
 
665 769
 install-utils: utils $(bin_prefix)/$(bin_dir)
666 770
 	@for r in $(utils_bin_install) "" ; do \
... ...
@@ -700,10 +804,10 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
700 804
 	chmod 755 $(bin_prefix)/$(bin_dir)/ser_mysql.sh
701 805
 
702 806
 
703
-install-modules-all: install-modules install-modules-doc
807
+install-modules-all: install-every-module install-every-module-doc
704 808
 
705 809
 
706
-install-doc: $(doc_prefix)/$(doc_dir) install-modules-doc
810
+install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
707 811
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL 
708 812
 	$(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
709 813
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES 
... ...
@@ -716,23 +820,6 @@ install-doc: $(doc_prefix)/$(doc_dir) install-modules-doc
716 820
 	$(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
717 821
 
718 822
 
719
-install-modules-doc: modules.lst $(doc_prefix)/$(doc_dir)
720
-	@for r in $(modules_basenames) "" ; do \
721
-		if [ -n "$$r" ]; then \
722
-			if [ -f modules/"$$r"/README ]; then \
723
-				$(call try_err,\
724
-					$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README ); \
725
-				$(call try_err,\
726
-					$(INSTALL_DOC)  modules/"$$r"/README  \
727
-									$(doc_prefix)/$(doc_dir)/README ); \
728
-				$(call try_err,\
729
-					mv -f $(doc_prefix)/$(doc_dir)/README \
730
-							$(doc_prefix)/$(doc_dir)/README."$$r" ); \
731
-			fi ; \
732
-		fi ; \
733
-	done; true
734
-
735
-
736 823
 install-ser-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
737 824
 		sed -e "s#/etc/ser/ser\.cfg#$(cfg_target)ser.cfg#g" \
738 825
 			-e "s#/usr/sbin/#$(bin_target)#g" \
... ...
@@ -747,20 +834,8 @@ install-ser-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
747 834
 			< ser.cfg.5 >  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
748 835
 		chmod 644  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
749 836
 
750
-install-man:  install-ser-man install-modules-man
837
+install-man:  install-ser-man install-every-module-man
751 838
 
752
-install-modules-man: modules-man $(man_prefix)/$(man_dir)/man7
753
-	@for r in $(modules_basenames) "" ; do \
754
-		if [ -n "$$r" ]; then \
755
-			if [ -f modules/"$$r"/"$$r".7 ]; then \
756
-				$(call try_err,\
757
-					$(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$r".7 );\
758
-				$(call try_err,\
759
-					$(INSTALL_MAN)  modules/"$$r"/"$$r".7  \
760
-									$(man_prefix)/$(man_dir)/man7 ); \
761
-			fi ; \
762
-		fi ; \
763
-	done; true
764 839
 
765 840
 
766 841
 .PHONY: clean_libs
... ...
@@ -775,7 +850,7 @@ clean:	clean_libs
775 850
 #try to clean everything (including all the modules, even ones that are not
776 851
 # configured/compiled normally
777 852
 .PHONY: clean-all
778
-clean-all: modules=$(modules_all)
853
+clean-all: cmodules=$(all_modules_lst)
779 854
 clean-all: clean
780 855
 
781 856
 # on make proper clean also the build config (w/o module list)
... ...
@@ -785,7 +860,7 @@ proper realclean distclean: clean_cfg
785 860
 maintainer-clean: clean_modules_cfg
786 861
 
787 862
 .PHONY: proper-all realclean-all distclean-all
788
-proper-all realclean-all distclean-all: modules=$(modules_all)
863
+proper-all realclean-all distclean-all: cmodules=$(all_modules_lst)
789 864
 proper-all realclean-all distclean-all: proper
790 865
 
791 866
 
... ...
@@ -168,7 +168,8 @@ CC_EXTRA_OPTS ?=
168 168
 cfg_dir = etc/ser/
169 169
 bin_dir = sbin/
170 170
 share_dir = share/ser/
171
-modules_dir = lib/ser/modules/
171
+# lib/ser/modules , lib/ser/modules-s, lib/ser/modules-k
172
+modules_dir = lib/ser/
172 173
 lib_dir = lib/ser/
173 174
 ifeq ($(OS), linux)
174 175
 	doc_dir = share/doc/ser/
175 176
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+# $Id$
2
+#
3
+# path config makefile
4
+#
5
+# History:
6
+# --------
7
+#  2009-03-27  initial version (andrei)
8
+
9
+ifneq ($(makefile_dirs_included),1)
10
+
11
+override makefile_dirs_included:=1
12
+
13
+# modules directories
14
+# WARNING: - names must not conflict with any makefile variable or 
15
+#            target name
16
+#          - they should not contain '-' in them (portability: some exported
17
+#            var names might be derived from them and some shell do not 
18
+#            support '-' in variables)
19
+# makefile module related targets will be defined based on them:
20
+# install-$(1), install-$(1)-doc, $(1) a.s.o.
21
+modules_dirs= modules modules_s modules_k
22
+
23
+endif
... ...
@@ -22,7 +22,7 @@ MOD_NAME=$(NAME:.so=)
22 22
 COREPATH ?=../..
23 23
 
24 24
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
25
- $(COREPATH)/Makefile.modules $(COREPATH)/config.mak
25
+ $(COREPATH)/Makefile.modules $(COREPATH)/Makefile.dirs $(COREPATH)/config.mak
26 26
 
27 27
 #override modules value, a module cannot have submodules
28 28
 override modules=
... ...
@@ -65,22 +65,24 @@ endif
65 65
 
66 66
 
67 67
 
68
+include $(COREPATH)/Makefile.dirs
68 69
 include $(COREPATH)/Makefile.targets
69 70
 include $(COREPATH)/Makefile.rules
70 71
 
72
+# default: if not overwritten by the main Makefile, install in modules
73
+mods_dst=$(modules_prefix)/$(modules_dir)/modules
71 74
 
72
-
73
-$(modules_prefix)/$(modules_dir):
74
-		mkdir -p $(modules_prefix)/$(modules_dir)
75
+$(mods_dst):
76
+		mkdir -p $(mods_dst)
75 77
 
76 78
 LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
77 79
 
78 80
 
79 81
 .PHONY: install
80 82
 .PHONY: install-libs
81
-install: $(NAME) $(modules_prefix)/$(modules_dir) install-libs
82
-	$(INSTALL_TOUCH) $(modules_prefix)/$(modules_dir)/$(NAME)
83
-	$(INSTALL_MODULES)  $(NAME)  $(modules_prefix)/$(modules_dir)
83
+install: $(NAME) $(mods_dst) install-libs
84
+	$(INSTALL_TOUCH) $(mods_dst)/$(NAME)
85
+	$(INSTALL_MODULES)  $(NAME)  $(mods_dst)
84 86
 
85 87
 install-libs:
86 88
 	@for lib in $(dir $(SER_LIBS)); do \
... ...
@@ -162,7 +162,7 @@ makecfg.lst:
162 162
 			$(filter-out $(NOREBUILD_INCLUDES),\
163 163
 				$(C_INCLUDES) $(INCLUDES))))) >>$@
164 164
 .PHONY: all
165
-all: $(NAME) modules
165
+all: $(NAME) every-module
166 166
 
167 167
 .PHONY: dep
168 168
 dep: $(depends)
... ...
@@ -173,14 +173,14 @@ static: $(objs)
173 173
 .PHONY: clean
174 174
 clean: 
175 175
 	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
176
-	-@for r in $(modules) $(static_modules_path) "" ; do \
176
+	-@for r in $(cmodules) $(static_modules_path) "" ; do \
177 177
 		if [ -d "$$r" ]; then \
178 178
 			echo "module $$r" ; \
179 179
 			$(MAKE) -C $$r clean ; \
180 180
 			$(MAKE) -C $$r/doc clean ; \
181 181
 		fi ; \
182 182
 	done 
183
-	@if [ -n "$(modules)" ]; then \
183
+	@if [ -n "$(cmodules)" ]; then \
184 184
 		for r in $(utils_compile) "" ; do \
185 185
 			if [ -d "$$r" ]; then \
186 186
 				 $(MAKE) -C $$r clean ; \
... ...
@@ -196,13 +196,13 @@ proper realclean distclean: mrproper
196 196
 mrproper: clean 
197 197
 	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) \
198 198
 			makecfg.lst 2>/dev/null
199
-	-@for r in $(modules) "" ; do \
199
+	-@for r in $(cmodules) "" ; do \
200 200
 		if [ -d "$$r" ]; then \
201 201
 			$(MAKE) -C $$r proper ; \
202 202
 			$(MAKE) -C $$r/doc proper ; \
203 203
 		fi ; \
204 204
 	done 
205
-	@if [ -n "$(modules)" ]; then \
205
+	@if [ -n "$(cmodules)" ]; then \
206 206
 		for r in $(utils_compile) "" ; do \
207 207
 			if [ -d "$$r" ]; then \
208 208
 				 $(MAKE) -C $$r proper ; \
... ...
@@ -213,7 +213,7 @@ mrproper: clean
213 213
 .PHONY: mantainer-cleaan
214 214
 mantainer-clean: distclean
215 215
 	-rm -f TAGS tags *.dbg .*.swp
216
-	-@for r in $(modules) "" ; do \
216
+	-@for r in $(cmodules) "" ; do \
217 217
 		if [ -d "$$r" ]; then \
218 218
 			$(MAKE) -C $$r mantainer-clean; \
219 219
 		fi ; \
... ...
@@ -23,6 +23,6 @@ endif
23 23
 objs=$(sources:.c=.o)
24 24
 extra_objs=
25 25
 depends=$(sources:.c=.d)
26
-modules=
26
+cmodules=
27 27
 static_modules=
28 28
 static_modules_path=
... ...
@@ -13,19 +13,27 @@
13 13
 #  2008-06-26  initial version (andrei) 
14 14
 #
15 15
 
16
+ifeq (,$(strip $(modules_dirs)))
17
+include $(COREPATH)/Makefile.dirs
18
+endif
19
+
16 20
 clean_targets:=	clean proper distclean realclean mantainer-clean clean_libs \
17 21
 				clean-all proper-all distclean-all realclean-all \
18 22
 				clean_cfg clean_modules_cfg clean-modules-cfg
19
-doc_targets:=	modules-doc modules-readme README modules-man man \
20
-		install-doc install-modules-doc install-man install-ser-man \
21
-		install-modules-man
23
+doc_targets:=	README man install-doc install-man install-ser-man \
24
+		install-every-module-doc install-every-module-man \
25
+		$(foreach m,$(modules_dirs),$(m)-doc $(m)-readme $(m)-man) \
26
+		$(foreach m,$(modules_dirs),install-$(m)-doc install-$(m)-man)
27
+
22 28
 # auxiliary: maintance, debugging, etc. (don't affect code/objects)
23 29
 aux_targets:=	TAGS tar dist cfg-defs cfg config config.mak print-modules \
24
-		dbg dbinstall librpath.lst makecfg.lst modules.lst
30
+		dbg dbinstall librpath.lst makecfg.lst \
31
+		modules-cfg modules-list modules-lst modules.lst mk-install_dirs
25 32
 # other targets that don't produce code in the current directory ("external")
26
-ext_targets:=	modules libs utils \
27
-		install-cfg install-modules install-utils  install-modules-all \
28
-		install-share 
33
+ext_targets:=	every-module $(modules_dirs) libs utils \
34
+		install-cfg install-utils  install-modules-all install-every-module\
35
+		$(foreach m,$(modules_dirs),install-$(m)) \
36
+		install-share
29 37
 
30 38
 # all the targets that don't require code dependecies in the current dir.
31 39
 nodep_targets:=	$(clean_targets) $(doc_targets) $(aux_targets) $(ext_targets)