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 89
 #extra modules to exclude
90 90
 skip_modules?=
91 91
 
92
+# see Makefile.dirs for the directories used for the modules
93
+include Makefile.dirs
94
+
92 95
 # Set document format
93 96
 # Alternatives are txt, html, xhtml, and pdf (see Makefile.doc)
94 97
 doc_format?=html
... ...
@@ -212,7 +216,7 @@ endif
212 212
 #
213 213
 static_modules:=
214 214
 
215
-ALLDEP=config.mak Makefile Makefile.sources Makefile.rules
215
+ALLDEP=config.mak Makefile Makefile.dirs Makefile.sources Makefile.rules
216 216
 
217 217
 #include general defs (like CC, CFLAGS  a.s.o)
218 218
 # hack to force makefile.defs re-inclusion (needed when make calls itself with
... ...
@@ -260,23 +264,47 @@ export extra_defs
260 260
 # - exclude_modules
261 261
 
262 262
 ifneq ($(modules_configured),1) 
263
-modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
263
+#modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
264
+
265
+# create modules*_all vars
266
+$(foreach mods,$(modules_dirs),$(eval \
267
+	$(mods)_all=$$(filter-out $(mods)/CVS,$$(wildcard $(mods)/*))))
268
+#debugging
269
+#$(foreach mods,$(modules_dirs),$(info "$(mods)_all=$($(mods)_all)"))
270
+
264 271
 ifneq ($(group_include),)
265
-	modules=$(filter-out $(addprefix modules/, \
266
-			$(exclude_modules) $(static_modules)), \
267
-			$(addprefix modules/, $(include_modules) ))
272
+$(foreach mods,$(modules_dirs),$(eval \
273
+	$(mods)=$$(filter-out $$(addprefix $(mods)/, \
274
+			$$(exclude_modules) $$(static_modules)), \
275
+			$$(addprefix $(mods)/, $$(include_modules) )) ))
268 276
 else	
269 277
 	# 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)
278
+$(foreach mods,$(modules_dirs),$(eval \
279
+	$(mods)_noinc=$$(filter-out $$(addprefix $(mods)/, \
280
+			$$(exclude_modules) $$(static_modules)), $$($(mods)_all)) \
281
+))
282
+$(foreach mods,$(modules_dirs),$(eval \
283
+	$(mods)=$$(filter-out $$(modules_noinc), \
284
+			$$(addprefix $(mods)/, $$(include_modules) )) $$($(mods)_noinc) \
285
+))
274 286
 endif # ifneq($(group_include),)
275 287
 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' )
288
+
289
+$(foreach mods,$(modules_dirs),$(eval \
290
+	$(mods)_names=$$(shell echo $$($(mods))| \
291
+				sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1.so/g' ) \
292
+))
293
+$(foreach mods,$(modules_dirs),$(eval \
294
+	$(mods)_basenames:=$$(shell echo $$($(mods))| \
295
+				sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1/g' ) \
296
+))
297
+
298
+# all modules from all the $(modules_dirs)
299
+all_modules_lst=$(foreach mods,$(modules_dirs), $($(mods)_all))
300
+
301
+# compile modules list (all the compiled mods from  $(modules_dirs))
302
+cmodules=$(foreach mods,$(modules_dirs), $($(mods)))
303
+
280 304
 #modules_names=$(patsubst modules/%, %.so, $(modules))
281 305
 #modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
282 306
 
... ...
@@ -356,14 +384,18 @@ endif # ifeq ($(config_mak),1)
356 356
 modules.lst:
357 357
 	@echo  saving modules list...
358 358
 	@echo "# this file is autogenerated by make modules-cfg" >$@
359
+	@echo "modules_dirs:=$(modules_dirs)" >>$@
359 360
 	@echo "cfg_group_include=$(group_include)" >>$@
360 361
 	@$(call cfg_save_var2,include_modules,$@)
361 362
 	@$(call cfg_save_var2,static_modules,$@)
362 363
 	@$(call cfg_save_var2,skip_modules,$@)
363 364
 	@$(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,$@)
365
+	@$(foreach mods,$(modules_dirs), \
366
+		$(call cfg_save_var2,$(mods)_all,$@))
367
+	@$(foreach mods,$(modules_dirs), \
368
+		$(call cfg_save_var2,$(mods)_noinc,$@))
369
+	@$(foreach mods,$(modules_dirs), \
370
+		$(call cfg_save_var2,$(mods),$@))
367 371
 	@echo "modules_configured:=1" >>$@
368 372
 
369 373
 .PHONY: cfg config cfg-defs
... ...
@@ -377,7 +409,7 @@ modules-cfg modules-list modules-lst:
377 377
 	$(MAKE) modules.lst
378 378
 
379 379
 .PHONY: all
380
-all: $(NAME) modules
380
+all: $(NAME) every-module
381 381
 
382 382
 .PHONY: print-modules
383 383
 print-modules:
... ...
@@ -386,16 +418,81 @@ print-modules:
386 386
 	echo ---------------------------------------------------------- ; \
387 387
 	echo The following modules will be excluded: $(exclude_modules) ; \
388 388
 	echo ---------------------------------------------------------- ; \
389
-	echo The following modules will be made: $(modules_basenames) ; \
389
+	echo The following modules will be made; \
390
+	$(foreach mods,$(modules_dirs), \
391
+		echo $(mods)/: $($(mods)_basenames) ; ) \
392
+	#echo DBG: The following modules will be made: $(modules_basenames) ; \
393
+
390 394
 
391
-.PHONY: modules
392
-modules: modules.lst
393
-	@for r in $(modules) "" ; do \
394
-		if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
395
+# modules templates (instantiated based on modules_dirs contents)
396
+define MODULES_RULES_template
397
+
398
+$(1)_dst=$(modules_prefix)/$(modules_dir)$(1)
399
+
400
+.PHONY: $(1)
401
+$(1): modules.lst
402
+	@for r in $($(1)) "" ; do \
403
+		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
395 404
 			echo  "" ; \
396 405
 			echo  "" ; \
397
-			if  $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
398
-			then\
406
+			if  $(MAKE) -C $$$$r $$(mk_params) || [ ${err_fail} != 1 ] ; then \
407
+				:; \
408
+			else \
409
+				exit 1; \
410
+			fi ; \
411
+		fi ; \
412
+	done; true
413
+
414
+.PHONY: $(1)-doc
415
+$(1)-doc: modules.lst
416
+	@for r in $($(1)) "" ; do \
417
+		if [ -n "$$$$r" ]; then \
418
+			echo  "" ; \
419
+			echo  "" ; \
420
+			$(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
421
+		fi ; \
422
+	done
423
+
424
+.PHONY: $(1)-readme
425
+
426
+$(1)-readme: modules.lst
427
+	-@for r in $($(1)) "" ; do \
428
+		if [ -n "$$$$r" ]; then \
429
+			echo  "" ; \
430
+			echo  "" ; \
431
+			if  $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
432
+			then \
433
+				:; \
434
+			else \
435
+				exit 1; \
436
+			fi ; \
437
+		fi ; \
438
+	done; true
439
+
440
+.PHONY: $(1)-man
441
+$(1)-man: modules.lst
442
+	-@for r in $($(1)) "" ; do \
443
+		if [ -n "$$$$r" ]; then \
444
+			echo  "" ; \
445
+			echo  "" ; \
446
+			if  $(MAKE) -C $$$$r $$(mk_params) man || [ ${err_fail} != 1 ] ;\
447
+			then \
448
+				:; \
449
+			else \
450
+				exit 1; \
451
+			fi ; \
452
+		fi ; \
453
+	done; true
454
+
455
+.PHONY: install-$(1)
456
+
457
+install-$(1): modules.lst $$($(1)_dst)
458
+	@for r in $($(1)) "" ; do \
459
+		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
460
+			echo  "" ; \
461
+			echo  "" ; \
462
+			if  $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
463
+				|| [ ${err_fail} != 1 ] ; then \
399 464
 				:; \
400 465
 			else \
401 466
 				exit 1; \
... ...
@@ -403,6 +500,58 @@ modules: modules.lst
403 403
 		fi ; \
404 404
 	done; true
405 405
 
406
+
407
+.PHONY: install-$(1)-doc
408
+
409
+install-$(1)-doc: modules.lst $(doc_prefix)/$(doc_dir)$(1)
410
+	@for r in $($(1)_basenames) "" ; do \
411
+		if [ -n "$$$$r" ]; then \
412
+			if [ -f $(1)/"$$$$r"/README ]; then \
413
+				$$(call try_err,\
414
+					$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README ); \
415
+				$$(call try_err,\
416
+					$(INSTALL_DOC)  $(1)/"$$$$r"/README  \
417
+									$(doc_prefix)/$(doc_dir)$(1)/README ); \
418
+				$$(call try_err,\
419
+					mv -f $(doc_prefix)/$(doc_dir)$(1)/README \
420
+							$(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
421
+			fi ; \
422
+		fi ; \
423
+	done; true
424
+
425
+.PHONY: install-$(1)-man
426
+
427
+install-$(1)-man: $(1)-man $(man_prefix)/$(man_dir)/man7
428
+	@for r in $($(1)_basenames) "" ; do \
429
+		if [ -n "$$$$r" ]; then \
430
+			if [ -f $(1)/"$$$$r"/"$$$$r".7 ]; then \
431
+				$$(call try_err,\
432
+				  $(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$$$r".7 );\
433
+				$$(call try_err,\
434
+					$(INSTALL_MAN)  modules/"$$$$r"/"$$$$r".7  \
435
+									$(man_prefix)/$(man_dir)/man7 ); \
436
+			fi ; \
437
+		fi ; \
438
+	done; true
439
+
440
+
441
+$(modules_prefix)/$(modules_dir)$(1):
442
+		mkdir -p $$(@)
443
+
444
+$(doc_prefix)/$(doc_dir)$(1):
445
+		mkdir -p $$(@)
446
+
447
+
448
+endef
449
+
450
+# instantiate the template
451
+$(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
452
+
453
+#$(foreach mods,$(modules_dirs),$(eval  $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
454
+
455
+# build all the modules
456
+every-module: $(modules_dirs)
457
+
406 458
 $(extra_objs):
407 459
 	@echo "Extra objs: $(extra_objs)" 
408 460
 	@for r in $(static_modules_path) "" ; do \
... ...
@@ -510,55 +659,10 @@ sunpkg:
510 510
 	rm -rf tmp/ser
511 511
 	rm -rf tmp/ser_sun_pkg
512 512
 
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 513
 
559 514
 .PHONY: install
560 515
 install: mk_params="compile_for_install=yes"
561
-install: install-bin install-modules install-cfg \
516
+install: install-bin install-every-module install-cfg \
562 517
 	install-doc install-man install-utils install-share
563 518
 
564 519
 .PHONY: dbinstall
... ...
@@ -567,11 +671,19 @@ dbinstall:
567 567
 	scripts/mysql/ser_mysql.sh create
568 568
 	-@echo "Done"
569 569
 
570
+.PHONY: README
571
+README: $(foreach mods,$(modules_dirs),$(mods)-readme)
572
+
573
+.PHONY: man
574
+man: $(foreach mods,$(modules_dirs),$(mods)-man)
575
+
570 576
 mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
571 577
 			$(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
572 578
 			$(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
573
-            $(share_prefix)/$(share_dir)
574
-
579
+			$(share_prefix)/$(share_dir) \
580
+			$(foreach mods,$(modules_dirs),\
581
+				$(modules_prefix)/$(modules_dir)$(mods) \
582
+				$(doc_prefix)/$(doc_dir)$(mods) )
575 583
 
576 584
 $(cfg_prefix)/$(cfg_dir): 
577 585
 		mkdir -p $(cfg_prefix)/$(cfg_dir)
... ...
@@ -585,7 +697,6 @@ $(share_prefix)/$(share_dir):
585 585
 $(modules_prefix)/$(modules_dir):
586 586
 		mkdir -p $(modules_prefix)/$(modules_dir)
587 587
 
588
-
589 588
 $(doc_prefix)/$(doc_dir):
590 589
 		mkdir -p $(doc_prefix)/$(doc_dir)
591 590
 
... ...
@@ -648,19 +759,12 @@ install-share: $(share_prefix)/$(share_dir)
648 648
 		fi ; \
649 649
 	done; true
650 650
 
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
651
+
652
+install-every-module: $(foreach mods,$(modules_dirs),install-$(mods))
653
+
654
+install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
655
+
656
+install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
664 657
 
665 658
 install-utils: utils $(bin_prefix)/$(bin_dir)
666 659
 	@for r in $(utils_bin_install) "" ; do \
... ...
@@ -700,10 +804,10 @@ install-utils: utils $(bin_prefix)/$(bin_dir)
700 700
 	chmod 755 $(bin_prefix)/$(bin_dir)/ser_mysql.sh
701 701
 
702 702
 
703
-install-modules-all: install-modules install-modules-doc
703
+install-modules-all: install-every-module install-every-module-doc
704 704
 
705 705
 
706
-install-doc: $(doc_prefix)/$(doc_dir) install-modules-doc
706
+install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
707 707
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL 
708 708
 	$(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
709 709
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES 
... ...
@@ -716,23 +820,6 @@ install-doc: $(doc_prefix)/$(doc_dir) install-modules-doc
716 716
 	$(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
717 717
 
718 718
 
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 719
 install-ser-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
737 720
 		sed -e "s#/etc/ser/ser\.cfg#$(cfg_target)ser.cfg#g" \
738 721
 			-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 747
 			< ser.cfg.5 >  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
748 748
 		chmod 644  $(man_prefix)/$(man_dir)/man5/ser.cfg.5
749 749
 
750
-install-man:  install-ser-man install-modules-man
750
+install-man:  install-ser-man install-every-module-man
751 751
 
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 752
 
765 753
 
766 754
 .PHONY: clean_libs
... ...
@@ -775,7 +850,7 @@ clean:	clean_libs
775 775
 #try to clean everything (including all the modules, even ones that are not
776 776
 # configured/compiled normally
777 777
 .PHONY: clean-all
778
-clean-all: modules=$(modules_all)
778
+clean-all: cmodules=$(all_modules_lst)
779 779
 clean-all: clean
780 780
 
781 781
 # on make proper clean also the build config (w/o module list)
... ...
@@ -785,7 +860,7 @@ proper realclean distclean: clean_cfg
785 785
 maintainer-clean: clean_modules_cfg
786 786
 
787 787
 .PHONY: proper-all realclean-all distclean-all
788
-proper-all realclean-all distclean-all: modules=$(modules_all)
788
+proper-all realclean-all distclean-all: cmodules=$(all_modules_lst)
789 789
 proper-all realclean-all distclean-all: proper
790 790
 
791 791
 
... ...
@@ -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 @@
0
+# $Id$
1
+#
2
+# path config makefile
3
+#
4
+# History:
5
+# --------
6
+#  2009-03-27  initial version (andrei)
7
+
8
+ifneq ($(makefile_dirs_included),1)
9
+
10
+override makefile_dirs_included:=1
11
+
12
+# modules directories
13
+# WARNING: - names must not conflict with any makefile variable or 
14
+#            target name
15
+#          - they should not contain '-' in them (portability: some exported
16
+#            var names might be derived from them and some shell do not 
17
+#            support '-' in variables)
18
+# makefile module related targets will be defined based on them:
19
+# install-$(1), install-$(1)-doc, $(1) a.s.o.
20
+modules_dirs= modules modules_s modules_k
21
+
22
+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)