Browse code

makefile: even more quiet

Andrei Pelinescu-Onciul authored on 09/10/2009 19:03:03
Showing 4 changed files
... ...
@@ -247,7 +247,9 @@ ifeq (,$(strip \
247 247
 	$(filter config.mak config cfg cfg-defs $(clean_targets),$(MAKECMDGOALS))))
248 248
 include config.mak
249 249
 ifeq ($(makefile_defs),1)
250
+ifeq ($(quiet),verbose)
250 251
 $(info config.mak loaded)
252
+endif # verbose
251 253
 # config_make valid & used
252 254
 config_mak=1
253 255
 ifeq ($(MAIN_NAME),)
... ...
@@ -265,6 +267,10 @@ $(shell rm -rf config.mak)
265 267
 config_mak=0
266 268
 makefile_defs=0
267 269
 exported_vars=0
270
+else
271
+# config.mak not strictly needed, but try to load it if exists for $(Q)
272
+config_mak=skip
273
+-include config.mak
268 274
 endif
269 275
 endif
270 276
 
... ...
@@ -401,7 +407,7 @@ ifeq ($(config_mak),1)
401 407
 
402 408
 include Makefile.cfg
403 409
 
404
-else
410
+else ifneq ($(config_mak),skip)
405 411
 
406 412
 config.mak: Makefile.defs
407 413
 	@echo making config...
... ...
@@ -494,8 +500,8 @@ $(1)_target=$(prefix)/$(modules_dir)$(1)
494 500
 $(1): modules.lst
495 501
 	@for r in $($(1)) "" ; do \
496 502
 		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
497
-			echo  "" ; \
498
-			echo  "" ; \
503
+			$(call oecho, "" ;) \
504
+			$(call oecho, "" ;) \
499 505
 			if  $(MAKE) -C $$$$r $$(mk_params) || [ ${err_fail} != 1 ] ; then \
500 506
 				:; \
501 507
 			else \
... ...
@@ -508,8 +514,8 @@ $(1): modules.lst
508 514
 $(1)-doc: modules.lst
509 515
 	@for r in $($(1)) "" ; do \
510 516
 		if [ -n "$$$$r" ]; then \
511
-			echo  "" ; \
512
-			echo  "" ; \
517
+			$(call oecho, "" ;) \
518
+			$(call oecho, "" ;) \\
513 519
 			$(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
514 520
 		fi ; \
515 521
 	done
... ...
@@ -519,8 +525,8 @@ $(1)-doc: modules.lst
519 525
 $(1)-readme: modules.lst
520 526
 	-@for r in $($(1)) "" ; do \
521 527
 		if [ -n "$$$$r" ]; then \
522
-			echo  "" ; \
523
-			echo  "" ; \
528
+			$(call oecho, "" ;) \
529
+			$(call oecho, "" ;) \
524 530
 			if  $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
525 531
 			then \
526 532
 				:; \
... ...
@@ -534,8 +540,8 @@ $(1)-readme: modules.lst
534 540
 $(1)-man: modules.lst
535 541
 	-@for r in $($(1)) "" ; do \
536 542
 		if [ -n "$$$$r" ]; then \
537
-			echo  "" ; \
538
-			echo  "" ; \
543
+			$(call oecho, "" ;) \
544
+			$(call oecho, "" ;) \
539 545
 			if  $(MAKE) -C $$$$r $$(mk_params) man || [ ${err_fail} != 1 ] ;\
540 546
 			then \
541 547
 				:; \
... ...
@@ -550,8 +556,8 @@ $(1)-man: modules.lst
550 556
 install-$(1): modules.lst $$($(1)_dst)
551 557
 	@for r in $($(1)) "" ; do \
552 558
 		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
553
-			echo  "" ; \
554
-			echo  "" ; \
559
+			$(call oecho, "" ;) \
560
+			$(call oecho, "" ;) \
555 561
 			if  $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
556 562
 				|| [ ${err_fail} != 1 ] ; then \
557 563
 				:; \
... ...
@@ -617,8 +623,8 @@ $(extra_objs):
617 623
 	@echo "Extra objs: $(extra_objs)" 
618 624
 	@for r in $(static_modules_path) "" ; do \
619 625
 		if [ -n "$$r" -a -r "$$r/Makefile"  ]; then \
620
-			echo  "" ; \
621
-			echo  "Making static module $r" ; \
626
+			$(call oecho, "" ;) \
627
+			$(call oecho, "Making static module $r" ;) \
622 628
 			if $(MAKE) -C $$r static $(mk_params) ; then  \
623 629
 				:; \
624 630
 			else \
... ...
@@ -631,8 +637,8 @@ $(extra_objs):
631 637
 utils:
632 638
 	@for r in $(utils_compile) "" ; do \
633 639
 		if [ -n "$$r" ]; then \
634
-			echo  "" ; \
635
-			echo  "" ; \
640
+			$(call oecho, "" ;) \
641
+			$(call oecho, "" ;) \
636 642
 			if  $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
637 643
 			then \
638 644
 				:; \
... ...
@@ -774,22 +780,22 @@ $(man_prefix)/$(man_dir)/man5:
774 780
 
775 781
 # note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...) 
776 782
 install-cfg: $(cfg_prefix)/$(cfg_dir)
777
-		sed $(foreach m,$(modules_dirs),\
783
+		@sed $(foreach m,$(modules_dirs),\
778 784
 				-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
779 785
 			< etc/$(CFG_NAME)-basic.cfg > \
780 786
 			$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample
781
-		chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample
782
-		if [ -z "${skip_cfg_install}" -a \
787
+		@chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample
788
+		@if [ -z "${skip_cfg_install}" -a \
783 789
 				! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg ]; then \
784 790
 			mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample \
785 791
 				$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg; \
786 792
 		fi
787
-		sed $(foreach m,$(modules_dirs),\
793
+		@sed $(foreach m,$(modules_dirs),\
788 794
 			-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
789 795
 			< etc/$(CFG_NAME)-oob.cfg \
790 796
 			> $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample
791
-		chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample
792
-		if [ -z "${skip_cfg_install}" -a \
797
+		@chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample
798
+		@if [ -z "${skip_cfg_install}" -a \
793 799
 				! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg ]; \
794 800
 		then \
795 801
 			mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample \
... ...
@@ -878,22 +884,22 @@ install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
878 884
 
879 885
 
880 886
 install-sr-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
881
-		sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
887
+		@sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
882 888
 			-e "s#/usr/sbin/#$(bin_target)#g" \
883 889
 			$(foreach m,$(modules_dirs),\
884 890
 				-e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
885 891
 			-e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
886 892
 			< $(CFG_NAME).8 >  \
887 893
 							$(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
888
-		chmod 644  $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
889
-		sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
894
+		@chmod 644  $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
895
+		@sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
890 896
 			-e "s#/usr/sbin/#$(bin_target)#g" \
891 897
 			$(foreach m,$(modules_dirs),\
892 898
 				-e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
893 899
 			-e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
894 900
 			< $(CFG_NAME).cfg.5 >  \
895 901
 			$(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
896
-		chmod 644  $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
902
+		@chmod 644  $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
897 903
 
898 904
 install-man:  install-sr-man install-every-module-man
899 905
 
... ...
@@ -75,15 +75,18 @@
75 75
 #  2009-10-01  use -fsigned-char for gcc on ppc, ppc64, arm and arm6
76 76
 #              (on those archs char is unsigned by default) (andrei)
77 77
 
78
+quiet?=$(if $(filter 1 yes on,$(Q)),silent,verbose)
78 79
 
79 80
 # check if already included/exported
80 81
 
81
-
82 82
 # used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
83 83
 # specifies if we have a set of valid defs)
84 84
 override makefile_defs_included:=1
85 85
 ifeq ($(makefile_defs),1)
86
+ifeq ($(quiet),verbose)
86 87
 $(info Makefile.defs defs skipped)
88
+endif # verbose
89
+
87 90
 else
88 91
 
89 92
 ifeq (,$(main_makefile))
... ...
@@ -94,7 +97,9 @@ ifeq (,$(main_makefile))
94 97
 # don't export the vars)
95 98
 COREPATH?= ../..
96 99
 include $(COREPATH)/config.mak
100
+ifeq ($(quiet),verbose)
97 101
 $(info config.mak included)
102
+endif # verbose
98 103
 # config.mak should set makefile_defs if complete
99 104
 export makefile_defs
100 105
 
... ...
@@ -103,7 +108,9 @@ override makefile_defs=1
103 108
 export makefile_defs
104 109
 
105 110
 
111
+ifeq ($(quiet),verbose)
106 112
 $(info normal Makefile.defs exec)
113
+endif # verbose
107 114
 # main binary name
108 115
 MAIN_NAME=ser
109 116
 #prefix for various configs and scripts
... ...
@@ -417,11 +424,11 @@ endif # predefined macros tests (x86_macros, ...)
417 424
 endif # gcc
418 425
 
419 426
 ifdef CC_ARCH
420
-$(info target architecture <$(CC_ARCH)>, host architecture <$(HOST_ARCH)>)
421 427
 ARCH:=$(CC_ARCH)
422 428
 else
423 429
 ARCH:=$(HOST_ARCH)
424 430
 endif
431
+$(info target architecture <$(ARCH)>, host architecture <$(HOST_ARCH)>)
425 432
 
426 433
 # compile-time options
427 434
 #
... ...
@@ -20,7 +20,9 @@ endif
20 20
 
21 21
 ifneq	(,$(filter install% %install install, $(MAKECMDGOALS)))
22 22
 compile_for_install:=yes
23
+ifeq ($(quiet),verbose)
23 24
 $(info install mode)
25
+endif # verbose
24 26
 endif
25 27
 
26 28
 ifeq ($(NAME),)
... ...
@@ -66,9 +66,14 @@ silent_cmd_LD=LD ($(LD)) [$(strip $(crt_type) $(NAME))]		$@
66 66
 ifneq (,$(filter 1 yes on, $(Q) $(QUIET)))
67 67
 quiet=silent
68 68
 Q=1
69
+MAKE+= --no-print-directory
70
+#shell optional print
71
+oecho=
69 72
 else
70
-Q=0
73
+override Q:=
71 74
 quiet=verbose
75
+#shell optional print
76
+oecho=echo $(1)
72 77
 endif
73 78
 
74 79
 quote:= "
... ...
@@ -156,14 +161,14 @@ $(SER_IPATH_LST): FORCE
156 161
 		$(@) 1>/dev/null 2>/dev/null ; \
157 162
 	then :; \
158 163
 	else \
159
-		echo "re-building $(@D)" ; \
164
+		$(call oecho,"re-building $(@D)" ;) \
160 165
 		$(MAKE) -wC $(@D) compile_for_install=$(lib_compile_for_install) ; \
161 166
 	fi
162 167
 
163 168
 .PHONY: FORCE-BUILD-LIBS
164 169
 FORCE-BUILD-LIBS:
165 170
 	@for r in $(SER_LIBS_DIRS) ; do \
166
-		echo building lib $$r; \
171
+		$(call oecho,building lib $$r ;) \
167 172
 		$(MAKE) -wC $$r compile_for_install=$(lib_compile_for_install) ; \
168 173
 	done
169 174
 
... ...
@@ -207,7 +212,7 @@ clean: local-clean
207 212
 clean-modules:
208 213
 	-@for r in $(cmodules) $(static_modules_path) "" ; do \
209 214
 		if [ -d "$$r" ]; then \
210
-			echo "module $$r" ; \
215
+			$(call oecho,"module $$r" ;) \
211 216
 			$(MAKE) -C "$$r" clean ; \
212 217
 			[ -d "$$r"/doc/Makefile ] && $(MAKE) -C "$$r"/doc clean ; \
213 218
 		fi ; \