Makefile: quiet shell commands when "make --silent"
PATCH 1/1 Makefile: quiet shell commands when "make --silent"
Option "--silent", "--quiet" or "-s" to make prevents echoing of commands as they are executed. However, there are some explicit "echo" commands in the Makefile and in the two GIT-VERSION-GEN scripts that always echo.
Quiet the explicit "echo"s in Makefile when MAKEFLAG "s" is set. Pass this information into both GIT-VERSION-GEN helpers so that they can run silently too.
Before:
$ echo >>git.c
$ make -s
GIT_VERSION = 1.7.12.378.gaeb1945.dirty
* new script parameters
GITGUI_VERSION = 0.16.GITGUI-dirty
$After:
$ echo >>git.c
$ make -s
$---
Make should be silent when given "--silent".
This may help tools that post-process make output, like the "check-docs" command. Peff noticed in 5fafce0 (check-docs: get documented command list from Makefile, 2012-08-08) that:
Quoted 2 lines
... make will print extra cruft like
"GIT-VERSION-FILE is up to date" to stdout.
They now can use "make -s" to avoid filtering out the cruft.
-- Pete
GIT-VERSION-GEN | 11 ++++++++++- Makefile | 13 ++++++++----- git-gui/GIT-VERSION-GEN | 11 ++++++++++- 3 files changed, 28 insertions(+), 7 deletions(-)
GIT-VERSION-GEN +10 -1
@@ -6,6 +6,12 @@ DEF_VER=v1.7.12.GIT LF=' ' +silent= +if test "${1:-}" = "#" +then + silent=1 +fi + # First see if there is a version file (included in release tarballs), # then try git-describe, then default. if test -f version
@@ -35,7 +41,10 @@ else VC=unset fi test "$VN" = "$VC" || { - echo >&2 "GIT_VERSION = $VN" + if test -z "$silent" + then + echo >&2 "GIT_VERSION = $VN" + fi echo "GIT_VERSION = $VN" >$GVF }
Makefile +8 -5
@@ -305,7 +305,7 @@ all:: # "git help" is called without a parameter specifying the format. GIT-VERSION-FILE: FORCE - @$(SHELL_PATH) ./GIT-VERSION-GEN + @$(SHELL_PATH) ./GIT-VERSION-GEN "$(SILENT_SH_ECHO)" -include GIT-VERSION-FILE uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
@@ -1850,6 +1850,9 @@ ifndef V export QUIET_GEN export QUIET_BUILT_IN endif +else +# in --silent mode, suppress echo command in shell commands +SILENT_SH_ECHO = \# endif ifdef NO_INSTALL_HARDLINKS
@@ -2074,7 +2077,7 @@ endef GIT-SCRIPT-DEFINES: FORCE @FLAGS='$(SCRIPT_DEFINES)'; \ if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \ - echo 1>&2 " * new script parameters"; \ + $(SILENT_SH_ECHO)echo 1>&2 " * new script parameters"; \ echo "$$FLAGS" >$@; \ fi
@@ -2451,7 +2454,7 @@ TRACK_PREFIX = $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\ GIT-PREFIX: FORCE @FLAGS='$(TRACK_PREFIX)'; \ if test x"$$FLAGS" != x"`cat GIT-PREFIX 2>/dev/null`" ; then \ - echo 1>&2 " * new prefix flags"; \ + $(SILENT_SH_ECHO)echo 1>&2 " * new prefix flags"; \ echo "$$FLAGS" >GIT-PREFIX; \ fi
@@ -2460,7 +2463,7 @@ TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME) GIT-CFLAGS: FORCE @FLAGS='$(TRACK_CFLAGS)'; \ if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \ - echo 1>&2 " * new build flags"; \ + $(SILENT_SH_ECHO)echo 1>&2 " * new build flags"; \ echo "$$FLAGS" >GIT-CFLAGS; \ fi
@@ -2469,7 +2472,7 @@ TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS)) GIT-LDFLAGS: FORCE @FLAGS='$(TRACK_LDFLAGS)'; \ if test x"$$FLAGS" != x"`cat GIT-LDFLAGS 2>/dev/null`" ; then \ - echo 1>&2 " * new link flags"; \ + $(SILENT_SH_ECHO)echo 1>&2 " * new link flags"; \ echo "$$FLAGS" >GIT-LDFLAGS; \ fi
git-gui/GIT-VERSION-GEN +10 -1
@@ -6,6 +6,12 @@ DEF_VER=0.16.GITGUI LF=' ' +silent= +if test "${1:-}" = "#" +then + silent=1 +fi + tree_search () { head=$1
@@ -75,6 +81,9 @@ else VC=unset fi test "$VN" = "$VC" || { - echo >&2 "GITGUI_VERSION = $VN" + if test -z "$silent" + then + echo >&2 "GITGUI_VERSION = $VN" + fi echo "GITGUI_VERSION = $VN" >$GVF }
Signature · 1 line
1.7.12.378.gaeb1945.dirty
Quoted 4 lines · Pete Wyckoff
Option "--silent", "--quiet" or "-s" to make prevents echoing of commands as they are executed. However, there are some explicit "echo" commands in the
Makefileand in the two GIT-VERSION-GEN scripts that always echo.
"make -s clean"?
I am not very enthused, especially if the primary motivation is about "check-docs". Such a script must be prepared to filter out cruft from the output of $(MAKE) and to pick out the bits that interests it and that has been the way of life with $(MAKE) way before Git started as a project ;-).
In order to make it more robust, targets like "print-man1" can (and should) arrange their output in such a way that interesting parts are easily findable.
[email protected] wrote on Sun, 09 Sep 2012 17:35 -0700:
Quoted 8 lines
Quoted 4 lines · Pete Wyckoff
Option "--silent", "--quiet" or "-s" to make prevents echoing of commands as they are executed. However, there are some explicit "echo" commands in the
Makefileand in the two GIT-VERSION-GEN scripts that always echo."make -s clean"?
Fixed here.
Quoted 5 lines
I am not very enthused, especially if the primary motivation is about "check-docs". Such a script must be prepared to filter out cruft from the output of $(MAKE) and to pick out the bits that interests it and that has been the way of life with $(MAKE) way before Git started as a project ;-).
My motivation was to quiet output from a script I use to test bisectability. I sent it out because I noticed someone else found the verbosity annoying too.
Agreed that "fixing" check-docs is not important; that's why I didn't bother in this patch.
-- Pete