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 265
 config_mak=0
266 266
 makefile_defs=0
267 267
 exported_vars=0
268
+else
269
+# config.mak not strictly needed, but try to load it if exists for $(Q)
270
+config_mak=skip
271
+-include config.mak
268 272
 endif
269 273
 endif
270 274
 
... ...
@@ -401,7 +407,7 @@ ifeq ($(config_mak),1)
401 401
 
402 402
 include Makefile.cfg
403 403
 
404
-else
404
+else ifneq ($(config_mak),skip)
405 405
 
406 406
 config.mak: Makefile.defs
407 407
 	@echo making config...
... ...
@@ -494,8 +500,8 @@ $(1)_target=$(prefix)/$(modules_dir)$(1)
494 494
 $(1): modules.lst
495 495
 	@for r in $($(1)) "" ; do \
496 496
 		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
497
-			echo  "" ; \
498
-			echo  "" ; \
497
+			$(call oecho, "" ;) \
498
+			$(call oecho, "" ;) \
499 499
 			if  $(MAKE) -C $$$$r $$(mk_params) || [ ${err_fail} != 1 ] ; then \
500 500
 				:; \
501 501
 			else \
... ...
@@ -508,8 +514,8 @@ $(1): modules.lst
508 508
 $(1)-doc: modules.lst
509 509
 	@for r in $($(1)) "" ; do \
510 510
 		if [ -n "$$$$r" ]; then \
511
-			echo  "" ; \
512
-			echo  "" ; \
511
+			$(call oecho, "" ;) \
512
+			$(call oecho, "" ;) \\
513 513
 			$(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
514 514
 		fi ; \
515 515
 	done
... ...
@@ -519,8 +525,8 @@ $(1)-doc: modules.lst
519 519
 $(1)-readme: modules.lst
520 520
 	-@for r in $($(1)) "" ; do \
521 521
 		if [ -n "$$$$r" ]; then \
522
-			echo  "" ; \
523
-			echo  "" ; \
522
+			$(call oecho, "" ;) \
523
+			$(call oecho, "" ;) \
524 524
 			if  $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
525 525
 			then \
526 526
 				:; \
... ...
@@ -534,8 +540,8 @@ $(1)-readme: modules.lst
534 534
 $(1)-man: modules.lst
535 535
 	-@for r in $($(1)) "" ; do \
536 536
 		if [ -n "$$$$r" ]; then \
537
-			echo  "" ; \
538
-			echo  "" ; \
537
+			$(call oecho, "" ;) \
538
+			$(call oecho, "" ;) \
539 539
 			if  $(MAKE) -C $$$$r $$(mk_params) man || [ ${err_fail} != 1 ] ;\
540 540
 			then \
541 541
 				:; \
... ...
@@ -550,8 +556,8 @@ $(1)-man: modules.lst
550 550
 install-$(1): modules.lst $$($(1)_dst)
551 551
 	@for r in $($(1)) "" ; do \
552 552
 		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
553
-			echo  "" ; \
554
-			echo  "" ; \
553
+			$(call oecho, "" ;) \
554
+			$(call oecho, "" ;) \
555 555
 			if  $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
556 556
 				|| [ ${err_fail} != 1 ] ; then \
557 557
 				:; \
... ...
@@ -617,8 +623,8 @@ $(extra_objs):
617 617
 	@echo "Extra objs: $(extra_objs)" 
618 618
 	@for r in $(static_modules_path) "" ; do \
619 619
 		if [ -n "$$r" -a -r "$$r/Makefile"  ]; then \
620
-			echo  "" ; \
621
-			echo  "Making static module $r" ; \
620
+			$(call oecho, "" ;) \
621
+			$(call oecho, "Making static module $r" ;) \
622 622
 			if $(MAKE) -C $$r static $(mk_params) ; then  \
623 623
 				:; \
624 624
 			else \
... ...
@@ -631,8 +637,8 @@ $(extra_objs):
631 631
 utils:
632 632
 	@for r in $(utils_compile) "" ; do \
633 633
 		if [ -n "$$r" ]; then \
634
-			echo  "" ; \
635
-			echo  "" ; \
634
+			$(call oecho, "" ;) \
635
+			$(call oecho, "" ;) \
636 636
 			if  $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
637 637
 			then \
638 638
 				:; \
... ...
@@ -774,22 +780,22 @@ $(man_prefix)/$(man_dir)/man5:
774 774
 
775 775
 # note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...) 
776 776
 install-cfg: $(cfg_prefix)/$(cfg_dir)
777
-		sed $(foreach m,$(modules_dirs),\
777
+		@sed $(foreach m,$(modules_dirs),\
778 778
 				-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
779 779
 			< etc/$(CFG_NAME)-basic.cfg > \
780 780
 			$(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 \
781
+		@chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample
782
+		@if [ -z "${skip_cfg_install}" -a \
783 783
 				! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg ]; then \
784 784
 			mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample \
785 785
 				$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg; \
786 786
 		fi
787
-		sed $(foreach m,$(modules_dirs),\
787
+		@sed $(foreach m,$(modules_dirs),\
788 788
 			-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
789 789
 			< etc/$(CFG_NAME)-oob.cfg \
790 790
 			> $(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 \
791
+		@chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample
792
+		@if [ -z "${skip_cfg_install}" -a \
793 793
 				! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg ]; \
794 794
 		then \
795 795
 			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 878
 
879 879
 
880 880
 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" \
881
+		@sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
882 882
 			-e "s#/usr/sbin/#$(bin_target)#g" \
883 883
 			$(foreach m,$(modules_dirs),\
884 884
 				-e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
885 885
 			-e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
886 886
 			< $(CFG_NAME).8 >  \
887 887
 							$(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" \
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" \
890 890
 			-e "s#/usr/sbin/#$(bin_target)#g" \
891 891
 			$(foreach m,$(modules_dirs),\
892 892
 				-e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
893 893
 			-e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
894 894
 			< $(CFG_NAME).cfg.5 >  \
895 895
 			$(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
896
-		chmod 644  $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
896
+		@chmod 644  $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
897 897
 
898 898
 install-man:  install-sr-man install-every-module-man
899 899
 
... ...
@@ -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 94
 # don't export the vars)
95 95
 COREPATH?= ../..
96 96
 include $(COREPATH)/config.mak
97
+ifeq ($(quiet),verbose)
97 98
 $(info config.mak included)
99
+endif # verbose
98 100
 # config.mak should set makefile_defs if complete
99 101
 export makefile_defs
100 102
 
... ...
@@ -103,7 +108,9 @@ override makefile_defs=1
103 103
 export makefile_defs
104 104
 
105 105
 
106
+ifeq ($(quiet),verbose)
106 107
 $(info normal Makefile.defs exec)
108
+endif # verbose
107 109
 # main binary name
108 110
 MAIN_NAME=ser
109 111
 #prefix for various configs and scripts
... ...
@@ -417,11 +424,11 @@ endif # predefined macros tests (x86_macros, ...)
417 417
 endif # gcc
418 418
 
419 419
 ifdef CC_ARCH
420
-$(info target architecture <$(CC_ARCH)>, host architecture <$(HOST_ARCH)>)
421 420
 ARCH:=$(CC_ARCH)
422 421
 else
423 422
 ARCH:=$(HOST_ARCH)
424 423
 endif
424
+$(info target architecture <$(ARCH)>, host architecture <$(HOST_ARCH)>)
425 425
 
426 426
 # compile-time options
427 427
 #
... ...
@@ -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 156
 		$(@) 1>/dev/null 2>/dev/null ; \
157 157
 	then :; \
158 158
 	else \
159
-		echo "re-building $(@D)" ; \
159
+		$(call oecho,"re-building $(@D)" ;) \
160 160
 		$(MAKE) -wC $(@D) compile_for_install=$(lib_compile_for_install) ; \
161 161
 	fi
162 162
 
163 163
 .PHONY: FORCE-BUILD-LIBS
164 164
 FORCE-BUILD-LIBS:
165 165
 	@for r in $(SER_LIBS_DIRS) ; do \
166
-		echo building lib $$r; \
166
+		$(call oecho,building lib $$r ;) \
167 167
 		$(MAKE) -wC $$r compile_for_install=$(lib_compile_for_install) ; \
168 168
 	done
169 169
 
... ...
@@ -207,7 +212,7 @@ clean: local-clean
207 207
 clean-modules:
208 208
 	-@for r in $(cmodules) $(static_modules_path) "" ; do \
209 209
 		if [ -d "$$r" ]; then \
210
-			echo "module $$r" ; \
210
+			$(call oecho,"module $$r" ;) \
211 211
 			$(MAKE) -C "$$r" clean ; \
212 212
 			[ -d "$$r"/doc/Makefile ] && $(MAKE) -C "$$r"/doc clean ; \
213 213
 		fi ; \