Makefile: suppress command echoing in silent mode (make -s)
PATCH 1/1 Makefile: suppress command echoing in silent mode (make -s)
--- rules.mak | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
rules.mak +12 -1
@@ -125,7 +125,18 @@ modules: %.a: $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@") -quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) +# Suppress command echoing in silent mode (make -s) +ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 +ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) +SILENT := 1 +endif +else # make-3.8x +ifneq ($(findstring s, $(MAKEFLAGS)),) +SILENT := 1 +endif +endif + +quiet-command = $(if $(V),$1,$(if $(2),$(if $(SILENT),@$1,@echo $2 && $1),@$1)) # cc-option # Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
Signature · 1 line
2.1.4
Quoted 1 line · Jerome Forissier
Signed-off-by Jerome Forissier <[email protected]>
Please Cc qemu-devel on patches.
Quoted 14 lines
rules.mak | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)rules.mak +2
-1@@ -125,7 +125,18 @@ modules: %.a: $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@") -quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) +# Suppress command echoing in silent mode (make -s) +ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
rules.mak modules: · line 139
Quoted 10 lines
rules.mak +10
-0+ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) +SILENT := 1 +endif +else # make-3.8x +ifneq ($(findstring s, $(MAKEFLAGS)),) +SILENT := 1 +endif +endif + +quiet-command = $(if $(V),$1,$(if $(2),$(if $(SILENT),@$1,@echo $2 && $1),@$1))
I'm not sure this is needed. We have V=1/V=0 way of controlling silent mode already, why add another way, which is also twisted (depends on make version and complicates already complex makefiles)?
Thanks,
/mjt
Quoted 4 lines · Michael Tokarev
Quoted 1 line · Jerome Forissier
Signed-off-by Jerome Forissier <[email protected]>Please Cc qemu-devel on patches.
OK, sorry. I wrongly assumed that trivial patches were to be sent to qemu-trivial only to avoid "polluting" qemu-devel. Obviously I read
http://wiki.qemu.org/Contribute/TrivialPatches too quickly.
Quoted 11 lines
Quoted 11 lines
rules.mak | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)rules.mak +0
-0@@ -125,7 +125,18 @@ modules: %.a: $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@")
Quoted 16 lines
rules.mak modules: · line 139
Quoted 13 lines
rules.mak +12
-1-quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) +# Suppress command echoing in silent mode (make -s) +ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 +ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) +SILENT := 1 +endif +else # make-3.8x +ifneq ($(findstring s, $(MAKEFLAGS)),) +SILENT := 1 +endif +endif + +quiet-command = $(if $(V),$1,$(if $(2),$(if $(SILENT),@$1,@echo $2 && $1),@$1))I'm not sure this is needed. We have V=1/V=0 way of controlling silent mode already,
Unless I'm mistaken, V does not allow silent mode. The current behavior is:
- "make" prints short commands only. For instance: " CC file.o".
- "make V=1" prints the full commands instead (and BTW "make V=0" does the same, which is a bit unexpected). For instance: "cc <flags> -c -o file.o file.c".
But, AFAICT, there is no way to suppress all output altogether. With the proposed patch, you can use "make -s" and get *no* output unless there is an error.
Silent mode is useful in continuous integration scenarios, where nobody is sitting in front of the terminal to watch the progress of the build, and it's better not to fill up the build logs with stuff unless we have an error.
Quoted 2 lines
why add another way, which is also twisted (depends on make version and complicates already complex makefiles)?
Yeah it's a bit unfortunate that make changed its behavior :(
Thanks,
Signature · 1 line
Jerome