automake-1.16: Tricks For Silencing Make
21.2 Standard and generic ways to silence Make
==============================================
Here we describe some common idioms/tricks to obtain a quieter make
output, with their relative advantages and drawbacks. In the next
section (⇒Automake Silent Rules) we’ll see how Automake can help
in this respect, providing more elaborate and flexible idioms.
• ‘make -s’
This simply causes ‘make’ not to print _any_ rule before executing
it.
The ‘-s’ flag is mandated by POSIX, universally supported, and its
purpose and function are easy to understand.
But it also has its serious limitations too. First of all, it
embodies an “all or nothing” strategy, i.e., either everything is
silenced, or nothing is; this lack of granularity can sometimes be
a fatal flaw. Moreover, when the ‘-s’ flag is used, the ‘make’
output might turn out to be too terse; in case of errors, the user
won’t be able to easily see what rule or command have caused them,
or even, in case of tools with poor error reporting, what the
errors were!
• ‘make >/dev/null || make’
Apparently, this perfectly obeys the “silence is golden” rule:
warnings from stderr are passed through, output reporting is done
only in case of error, and in that case it should provide a
verbose-enough report to allow an easy determination of the error
location and causes.
However, calling ‘make’ two times in a row might hide errors
(especially intermittent ones), or subtly change the expected
semantics of the ‘make’ calls — these things can clearly make
debugging and error assessment very difficult.
• ‘make --no-print-directory’
This is GNU ‘make’ specific. When called with the
‘--no-print-directory’ option, GNU ‘make’ will disable printing of
the working directory by invoked sub-‘make’s (the well-known
“Entering/Leaving directory ...” messages). This helps to decrease
the verbosity of the output, but experience has shown that it can
also often render debugging considerably harder in projects using
deeply-nested ‘make’ recursion.
As an aside, notice that the ‘--no-print-directory’ option is
automatically activated if the ‘-s’ flag is used.