Subject: bug#8665: automake should offer APIs to honour silent-rules verbosity from shell code in Makefiles

From: Stefano Lattarini <[email-masked]>
Date: Thu, 12 May 2011 22:27:42 +0200

severity: wishlist
thanks

Hello automakers.

We all know that's not usual, for long and complex makefile rules, to
be, at least in part, unconditionally silenced (with a leading `@'), as
otherwise the noise/information ratio in the output would be too high.
Such rules usually use echo (or similar commands) to print "by hand"
relevant information that might be useful, e.g., in debugging.

In fact, some rules generated by Automake itself are written this way;
for example, various installation rules, or the rules to automatically
rebuild 'Makefile.in's from 'Makefile.am's -- let's see this last one,
to have a real-word example:

  $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
  @for dep in $?; do \
    case '$(am__configure_deps)' in \
      *$$dep*) \
        echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
        $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu && exit 0; \
        exit 1;; \
    esac; \
  done; \
  echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
  $(am__cd) $(top_srcdir) && $(AUTOMAKE) --gnu Makefile

The problem with such rules is that, when the 'silent-rules' option is
used, they do not respect the default or enforced verbosity; worse of all,
they have no proper way to do so, because automake does not presently
offer any API in this respect.

I thus propose we add an API of this kind.  At first, this might be as
simple as just defining two proper `AM_V_ECHO' and `AM_Q_ECHO' variables;
`AM_V_ECHO' should be `echo' when silent rules are in effect, and `:'
when they are not; viceversa for `AM_Q_ECHO'.

To give a simplified example of what I'm proposing:

  $ cat > Makefile.am <<'END'
  headers:
    @... [commands defining a shell variable `$headers']; \
     $(AM_V_ECHO) "cd somedir && generate-header --flag $$headers"; \
     $(AM_Q_ECHO) "GEN headers"; \
     cd somedir && generate-header --flag $$headers
 END
 $ autoreconf ...
 $ ./configure --disable-silent-rules
 ...
 $ make headers
 cd somedir && generate-header --flag foo.h bar.h baz.h
 $ make headers V=0
 GEN headers
 $ ./configure --enable-silent-rules
 ...
 $ make headers
 GEN headers
 $ make headers V=1
 cd somedir && generate-header --flag foo.h bar.h baz.h

Or maybe we could start being more general from the beginning, and define
a variable `AM_IS_SILENT' (say) that is defined to "yes" when silent rules
are in effect, and to "no" otherwise.

WDYT?

Regards,
  Stefano

P.S. JFTR, this report has been motivated by this other one:
     "check_JAVA does not support silent rules"
     <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8662>