Package: automake;
Reported by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Date: Thu, 12 May 2011 20:29:02 UTC
Severity: wishlist
To reply to this bug, email your comments to 8665 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Thu, 12 May 2011 20:29:02 GMT) Full text and rfc822 format available.Stefano Lattarini <stefano.lattarini <at> gmail.com>
:bug-automake <at> gnu.org
.
(Thu, 12 May 2011 20:29:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Stefano Lattarini <stefano.lattarini <at> gmail.com> To: bug-automake <at> gnu.org Subject: automake should offer APIs to honour silent-rules verbosity from shell code in Makefiles 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>
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Thu, 12 May 2011 23:00:03 GMT) Full text and rfc822 format available.Message #8 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Jack Kelly <jack <at> jackkelly.name> To: 8665 <at> debbugs.gnu.org Subject: Re: bug#8665: automake should offer APIs to honour silent-rules verbosity from shell code in Makefiles Date: Fri, 13 May 2011 08:59:35 +1000
Comments inline, after some snipping. On Fri, May 13, 2011 at 6:27 AM, Stefano Lattarini <stefano.lattarini <at> gmail.com> wrote: > -snip intro- > > 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 If you're just echoing "GEN headers", is there any reason you can't use $(AM_V_GEN) here? Maybe we should have a more general method of declaring silencing variables (like the $(AM_V_GEN), but also the others that echo 'CC' and friends. Then users who have unconventional setups can silence things without echoing 'GEN' everywhere. > 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. If you are going to do this, is it sufficient for it to be a variable, or does it need to be an AM_CONDITIONAL? I'm thinking a variable is fine. -- Jack
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Fri, 13 May 2011 09:32:02 GMT) Full text and rfc822 format available.Message #11 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Stefano Lattarini <stefano.lattarini <at> gmail.com> To: Jack Kelly <jack <at> jackkelly.name> Cc: 8665 <at> debbugs.gnu.org Subject: Re: bug#8665: automake should offer APIs to honour silent-rules verbosity from shell code in Makefiles Date: Fri, 13 May 2011 11:30:55 +0200
Hello Jack, thanks for the feedback. On Friday 13 May 2011, Jack Kelly wrote: > Comments inline, after some snipping. > > On Fri, May 13, 2011 at 6:27 AM, Stefano Lattarini > <stefano.lattarini <at> gmail.com> wrote: > > -snip intro- > > > > 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 > > If you're just echoing "GEN headers", is there any reason you can't > use $(AM_V_GEN) here? > Well, first of all, assuming that $(AM_V_ECHO) and $(AM_Q_ECHO) aren't available, using just $(AM_V_GEN) wouldn't be enough to silence the "cd somedir && generate-header --flag $$headers" message echoed by the rule above, and this clearly defies the purpose of having silent rules in the first place. Also in case the generation of headers uses a timestamp file, say ".headers_timestamp" (which would probably be the case in a real-world example), the use of $(AM_V_GEN) woul cause the displaying of a leass appealing and IMHO slightly less clear message "GEN .headers_timpestamp". Also, thinking about more general situations, we might want to display some trimmed-down versions of $headers instead of the constant string `headers'; for example, we might want to display the number of headers that are being generated (an information that is available only to the shell running the rule, and not to the make process): $ cat > Makefile.am <<'END' headers: @... $(AM_V_ECHO) "cd somedir && generate-header --flag $$headers"; \ set x $$headers && shift && $(AM_Q_ECHO) "GEN $# headers"; \ cd somedir && generate-header --flag $$headers The use of $(AM_V_GEN) won't allow us to do something like this in a easy and natural way. > Maybe we should have a more general method of > declaring silencing variables (like the $(AM_V_GEN), but also the > others that echo 'CC' and friends. Then users who have unconventional > setups can silence things without echoing 'GEN' everywhere. > If I understand correctly what you're suggesting, then I think the current implementation already offers what you want; see the documentation for the 'silent-rules' option at: <http://www.gnu.org/software/automake/manual/html_node/Options.html> (I know, that is, er, "suboptimally" placed; a patch to fix this is still pending). A relevant excerpt: You can add your own variables, so strings of your own choice are shown. The following snippet shows how you would define your own equivalent of AM_V_GEN: pkg_verbose = $(pkg_verbose_$(V)) pkg_verbose_ = $(pkg_verbose_$(AM_DEFAULT_VERBOSITY)) pkg_verbose_0 = @echo PKG-GEN $@; foo: foo.in (pkg_verbose)cp $(srcdir)/foo.in $@ > > 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. > > If you are going to do this, is it sufficient for it to be a variable, > or does it need to be an AM_CONDITIONAL? I'm thinking a variable is > fine. > Me too. Also because verbosity of rules is expected to be overridable at make runtime anyway (with the use of `make V=1' and `make V=0'), and automake conditionals wouldn't play well with this. Thanks, Stefano
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Fri, 13 May 2011 10:21:02 GMT) Full text and rfc822 format available.Message #14 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Jack Kelly <jack <at> jackkelly.name> To: 8665 <at> debbugs.gnu.org Subject: Re: bug#8665: automake should offer APIs to honour silent-rules verbosity from shell code in Makefiles Date: Fri, 13 May 2011 20:20:19 +1000
On Fri, May 13, 2011 at 7:30 PM, Stefano Lattarini <stefano.lattarini <at> gmail.com> wrote: > Hello Jack, thanks for the feedback. > > On Friday 13 May 2011, Jack Kelly wrote: >> Comments inline, after some snipping. >> >> On Fri, May 13, 2011 at 6:27 AM, Stefano Lattarini >> <stefano.lattarini <at> gmail.com> wrote: >> > -snip intro- >> > >> > 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 >> >> If you're just echoing "GEN headers", is there any reason you can't >> use $(AM_V_GEN) here? >> > Well, first of all, assuming that $(AM_V_ECHO) and $(AM_Q_ECHO) aren't > available, using just $(AM_V_GEN) wouldn't be enough to silence the > "cd somedir && generate-header --flag $$headers" message echoed by the > rule above, and this clearly defies the purpose of having silent rules > in the first place. Also in case the generation of headers uses a > timestamp file, say ".headers_timestamp" (which would probably be the > case in a real-world example), the use of $(AM_V_GEN) woul cause the > displaying of a leass appealing and IMHO slightly less clear message > "GEN .headers_timpestamp". You do have $(AM_V_at), though. I am persuaded by your arguments for the general case. > Also, thinking about more general situations, we might want to display > some trimmed-down versions of $headers instead of the constant string > `headers'; for example, we might want to display the number of headers > that are being generated (an information that is available only to the > shell running the rule, and not to the make process): > > -snip example- Agreed. >> Maybe we should have a more general method of >> declaring silencing variables (like the $(AM_V_GEN), but also the >> others that echo 'CC' and friends. Then users who have unconventional >> setups can silence things without echoing 'GEN' everywhere. >> > If I understand correctly what you're suggesting, then I think the current > implementation already offers what you want; see the documentation for the > 'silent-rules' option at: > > <http://www.gnu.org/software/automake/manual/html_node/Options.html> > > (I know, that is, er, "suboptimally" placed; a patch to fix this is still > pending). > > A relevant excerpt: > > You can add your own variables, so strings of your own choice are shown. > The following snippet shows how you would define your own equivalent of > AM_V_GEN: > pkg_verbose = $(pkg_verbose_$(V)) > pkg_verbose_ = $(pkg_verbose_$(AM_DEFAULT_VERBOSITY)) > pkg_verbose_0 = @echo PKG-GEN $@; > > foo: foo.in > (pkg_verbose)cp $(srcdir)/foo.in $@ Yes. I think it would be nice to make a Makefile.am declaration or m4 macro to generate this, the above was what I was looking for. -- Jack
owner <at> debbugs.gnu.org, bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Fri, 13 May 2011 11:13:01 GMT) Full text and rfc822 format available.Message #17 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Stefano Lattarini <stefano.lattarini <at> gmail.com> To: Jack Kelly <jack <at> jackkelly.name> Cc: 8665 <at> debbugs.gnu.org Subject: Re: bug#8665: automake should offer APIs to honour silent-rules verbosity from shell code in Makefiles Date: Fri, 13 May 2011 13:12:03 +0200
On Friday 13 May 2011, Jack Kelly wrote: > [snip] > > >> Maybe we should have a more general method of > >> declaring silencing variables (like the $(AM_V_GEN), but also the > >> others that echo 'CC' and friends. Then users who have unconventional > >> setups can silence things without echoing 'GEN' everywhere. > >> > > If I understand correctly what you're suggesting, then I think the current > > implementation already offers what you want; see the documentation for the > > 'silent-rules' option at: > > > > <http://www.gnu.org/software/automake/manual/html_node/Options.html> > > > > (I know, that is, er, "suboptimally" placed; a patch to fix this is still > > pending). > > > > A relevant excerpt: > > > > You can add your own variables, so strings of your own choice are shown. > > The following snippet shows how you would define your own equivalent of > > AM_V_GEN: > > pkg_verbose = $(pkg_verbose_$(V)) > > pkg_verbose_ = $(pkg_verbose_$(AM_DEFAULT_VERBOSITY)) > > pkg_verbose_0 = @echo PKG-GEN $@; > > > > foo: foo.in > > (pkg_verbose)cp $(srcdir)/foo.in $@ > > Yes. I think it would be nice to make a Makefile.am declaration or m4 > macro to generate this, > I agree. The above idiom seems easy enough to automatize. I'm not sure what the best syntax for this new feature would be, tough. > the above was what I was looking for. > > -- Jack > Regards, Stefano
bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Sun, 22 Apr 2012 15:07:02 GMT) Full text and rfc822 format available.Message #20 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Stefano Lattarini <stefano.lattarini <at> gmail.com> To: 8665 <at> debbugs.gnu.org Cc: Jack Kelly <jack <at> jackkelly.name>, Automake List <automake <at> gnu.org> Subject: Re: bug#8665: automake should offer APIs to honour silent-rules verbosity from shell code in Makefiles Date: Sun, 22 Apr 2012 17:05:20 +0200
Reviving and oldish bug report (and CC:ing the Automake list now). Reference: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8665> I wrote: > > A relevant excerpt [from the manual]: > > You can add your own variables, so strings of your own choice are shown. > The following snippet shows how you would define your own equivalent of > AM_V_GEN: > pkg_verbose = $(pkg_verbose_$(V)) > pkg_verbose_ = $(pkg_verbose_$(AM_DEFAULT_VERBOSITY)) > pkg_verbose_0 = @echo PKG-GEN $@; > foo: foo.in > (pkg_verbose)cp $(srcdir)/foo.in $@ Jack Kelly replied: > > Yes. I think it would be nice to make a Makefile.am declaration or m4 > macro to generate this, To which I replied: > > I agree. The above idiom seems easy enough to automatize. I'm not sure > what the best syntax for this new feature would be, tough. It could be something as simple as this maybe: AM_QUIET_PKG = PKG-GEN which would output in the generated Makefile.in: AM_V_PKG = $(pkg_verbose_ <at> AM_V@) am__V_PKG_ = $(pkg_verbose_ <at> AM_DEFAULT_V@) am__V_PKG_0 = @echo $(AM_QUIET_PKG) $@; so that an usage like: foo: foo.in $(AM_V_PKG)cp $(srcdir)/foo.in $@ in Makefile.am will produce at runtime: $ make foo V=0 PKG-GEN foo $ make foo V=1 cp ./foo.in foo WDYT? Regards, Stefano
bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Mon, 11 Jun 2012 14:56:01 GMT) Full text and rfc822 format available.Message #23 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Stefano Lattarini <stefano.lattarini <at> gmail.com> To: automake-patches <at> gnu.org Cc: Jack Kelly <jack <at> jackkelly.name>, 8665 <at> debbugs.gnu.org Subject: [PATCH 0/3] Determine whether silent rules are active from inside a make recipe Date: Mon, 11 Jun 2012 16:52:38 +0200
[Resurrecting an old thread] Reference: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8665> Hi Jack, automakers, sorry for the shameful delay. This patch series (for maint) should take care of the "easy" part of the bug, i.e., define a make variable that can be used from within the make recipes to determine whether make is being run in verbose mode (as with "make V=1") or quiet mode (as with "make V=0"). I will push by tomorrow if there is no objection. Regards, Stefano Stefano Lattarini (3): refactor: &define_verbose_var: accept a third optional argument refactor: silent rules handling (a little) silent: new $(AM_V_P) variable, tell if we're running in silent mode NEWS | 6 +++ automake.in | 46 ++++++++++++----- doc/automake.texi | 18 ++++++- t/list-of-tests.mk | 1 + t/silent-obsolescent-warns.sh | 71 ++++++++++++++++++++++++++ t/silent6.sh | 110 +++++++++++++++++++---------------------- 6 files changed, 180 insertions(+), 72 deletions(-) create mode 100755 t/silent-obsolescent-warns.sh -- 1.7.9.5
bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Mon, 11 Jun 2012 14:56:02 GMT) Full text and rfc822 format available.Message #26 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Stefano Lattarini <stefano.lattarini <at> gmail.com> To: automake-patches <at> gnu.org Cc: Jack Kelly <jack <at> jackkelly.name>, 8665 <at> debbugs.gnu.org Subject: [PATCH 1/3] refactor: &define_verbose_var: accept a third optional argument Date: Mon, 11 Jun 2012 16:52:39 +0200
This is only required by future changes. * automake.in (define_verbose_var): Accept a third optional argument, specifying the value to assign to the given make variable when silent rules are disabled. Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com> --- automake.in | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/automake.in b/automake.in index 5cf5a2c..5d777c1 100644 --- a/automake.in +++ b/automake.in @@ -1138,15 +1138,19 @@ sub verbose_private_var ($) return 'am__v_' . $name; } -# define_verbose_var (NAME, VAL) -# ------------------------------ -# For 'silent-rules' mode, setup VAR and dispatcher, to expand to VAL if silent. -sub define_verbose_var ($$) -{ - my ($name, $val) = @_; +# define_verbose_var (NAME, VAL-IF-SILENT, [VAL-IF-VERBOSE]) +# ---------------------------------------------------------- +# For 'silent-rules' mode, setup VAR and dispatcher, to expand to +# VAL-IF-SILENT if silent, to VAL-IF-VERBOSE (defaulting to empty) +# if not. +sub define_verbose_var ($$;$) +{ + my ($name, $silent_val, $verbose_val) = @_; + $verbose_val = '' unless defined $verbose_val; my $var = verbose_var ($name); my $pvar = verbose_private_var ($name); my $silent_var = $pvar . '_0'; + my $verbose_var = $pvar . '_1'; if (option 'silent-rules') { # For typical 'make's, 'configure' replaces AM_V (inside @@) with $(V) @@ -1155,10 +1159,13 @@ sub define_verbose_var ($$) # See AM_SILENT_RULES in m4/silent.m4. define_variable ($var, '$(' . $pvar . '_@'.'AM_V'.'@)', INTERNAL); define_variable ($pvar . '_', '$(' . $pvar . '_@'.'AM_DEFAULT_V'.'@)', INTERNAL); - Automake::Variable::define ($silent_var, VAR_AUTOMAKE, '', TRUE, $val, - '', INTERNAL, VAR_ASIS) + Automake::Variable::define ($silent_var, VAR_AUTOMAKE, '', TRUE, + $silent_val, '', INTERNAL, VAR_ASIS) if (! vardef ($silent_var, TRUE)); - } + Automake::Variable::define ($verbose_var, VAR_AUTOMAKE, '', TRUE, + $verbose_val, '', INTERNAL, VAR_ASIS) + if (! vardef ($verbose_var, TRUE)); +} } # Above should not be needed in the general automake code. -- 1.7.9.5
bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Mon, 11 Jun 2012 14:56:02 GMT) Full text and rfc822 format available.Message #29 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Stefano Lattarini <stefano.lattarini <at> gmail.com> To: automake-patches <at> gnu.org Cc: Jack Kelly <jack <at> jackkelly.name>, 8665 <at> debbugs.gnu.org Subject: [PATCH 2/3] refactor: silent rules handling (a little) Date: Mon, 11 Jun 2012 16:52:40 +0200
* automake.in (handle_languages): Move definition of $(AM_V_GEN) variable ... (define_verbose_tagvar): ... and of '$(AM_V_at)' variable ... (handle_silent): ... in this new subroutine. (generate_makefile): Call it. Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com> --- automake.in | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/automake.in b/automake.in index 5d777c1..722a202 100644 --- a/automake.in +++ b/automake.in @@ -1206,7 +1206,6 @@ sub define_verbose_tagvar ($) if (option 'silent-rules') { define_verbose_var ($name, '@echo " '. $name . ' ' x (8 - length ($name)) . '" $@;'); - define_verbose_var ('at', '@'); } } @@ -1233,6 +1232,14 @@ sub define_verbose_libtool () return verbose_flag ('lt'); } +sub handle_silent () +{ + return unless option 'silent-rules'; + # *Always* provide the user with 'AM_V_GEN' for 'silent-rules' mode. + define_verbose_tagvar ('GEN'); + define_verbose_var ('at', '@'); +} + ################################################################ @@ -1590,9 +1597,6 @@ sub handle_languages unless defined $done{$languages{'c'}}; define_linker_variable ($languages{'c'}); } - - # Always provide the user with 'AM_V_GEN' for 'silent-rules' mode. - define_verbose_tagvar ('GEN'); } @@ -8153,6 +8157,8 @@ sub generate_makefile ($$) handle_programs; handle_scripts; + handle_silent; + # These must be run after all the sources are scanned. They # use variables defined by &handle_libraries, &handle_ltlibraries, # or &handle_programs. -- 1.7.9.5
bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Mon, 11 Jun 2012 14:56:02 GMT) Full text and rfc822 format available.Message #32 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Stefano Lattarini <stefano.lattarini <at> gmail.com> To: automake-patches <at> gnu.org Cc: Jack Kelly <jack <at> jackkelly.name>, 8665 <at> debbugs.gnu.org Subject: [PATCH 3/3] silent: new $(AM_V_P) variable, tell if we're running in silent mode Date: Mon, 11 Jun 2012 16:52:41 +0200
Addresses part of automake bug#8665. * automake.in (handle_silent): Define a new make variable '$(AM_V_P)', that expands to a shell conditional that can be used in make recipes to determine whether they are being run in silent mode or not. The choice of the name derives from the LISP convention of appending the letter 'P' to denote a predicate (see also "the '-P' convention" in the Jargon File); we do so for lack of a better convention. * t/automake.texi, NEWS: Document the new variable. * t/silent6.sh: Adjust and extend. Move out the checks that didn't actually deal with user extension of silent rules ... * t/silent-obsolescent-warns.sh: ... into this test (bound to be removed once 'maint' is merged into the 'master' branch). * t/list-of-tests.mk: Add the new test. Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com> --- NEWS | 6 +++ automake.in | 7 +++ doc/automake.texi | 18 ++++++- t/list-of-tests.mk | 1 + t/silent-obsolescent-warns.sh | 71 ++++++++++++++++++++++++++ t/silent6.sh | 110 +++++++++++++++++++---------------------- 6 files changed, 154 insertions(+), 59 deletions(-) create mode 100755 t/silent-obsolescent-warns.sh diff --git a/NEWS b/NEWS index cf45836..bced15f 100644 --- a/NEWS +++ b/NEWS @@ -60,6 +60,12 @@ New in 1.12.2: input file. Such a warning will also be present in the next Autoconf version (2.70). +* Silent rules support: + + - A new predefined $(AM_V_P) make variable is provided; it expands + to a shell conditional that can be used in recipes to know whether + make is being run in silent or verbose mode. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New in 1.12.1: diff --git a/automake.in b/automake.in index 722a202..53bed2f 100644 --- a/automake.in +++ b/automake.in @@ -1235,6 +1235,13 @@ sub define_verbose_libtool () sub handle_silent () { return unless option 'silent-rules'; + # Define "$(AM_V_P)", expanding to a shell conditional that can be + # used in make recipes to determine whether we are being run in + # silent mode or not. The choice of the name derives from the LISP + # convention of appending the letter 'P' to denote a predicate (see + # also "the '-P' convention" in the Jargon File); we do so for lack + # of a better convention. + define_verbose_var ('P', 'false', ':'); # *Always* provide the user with 'AM_V_GEN' for 'silent-rules' mode. define_verbose_tagvar ('GEN'); define_verbose_var ('at', '@'); diff --git a/doc/automake.texi b/doc/automake.texi index 939fe44..1b57cd8 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -10966,15 +10966,31 @@ limitation should go away with time. @vindex @code{AM_DEFAULT_VERBOSITY} @vindex @code{AM_V} @vindex @code{AM_DEFAULT_V} -To extend the silent mode to your own rules, you have two choices: +To extend the silent mode to your own rules, you have few choices: @itemize @bullet + @item You can use the predefined variable @code{AM_V_GEN} as a prefix to commands that should output a status line in silent mode, and @code{AM_V_at} as a prefix to commands that should not output anything in silent mode. When output is to be verbose, both of these variables will expand to the empty string. + +@item +You can silence a recipe unconditionally with @code{@@}, and then use +the predefined variable @code{AM_V_P} to know whether make is being run +in silent or verbose mode, adjust the verbose information your recipe +displays accordingly: + +@example +generate-headers: + @set -e; \ + ... [commands defining a shell variable '$headers'] ...; \ + if $(AM_V_P); then set -x; else echo " GEN [headers]"; fi; \ + rm -f $$headers && generate-header --flags $$headers +@end example + @item You can add your own variables, so strings of your own choice are shown. The following snippet shows how you would define your own equivalent of diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk index 446157c..7d7e88e 100644 --- a/t/list-of-tests.mk +++ b/t/list-of-tests.mk @@ -976,6 +976,7 @@ t/silent6.sh \ t/silent7.sh \ t/silent8.sh \ t/silent9.sh \ +t/silent-obsolescent-warns.sh \ t/silentcxx.sh \ t/silentcxx-gcc.sh \ t/silentf77.sh \ diff --git a/t/silent-obsolescent-warns.sh b/t/silent-obsolescent-warns.sh new file mode 100755 index 0000000..a95f118 --- /dev/null +++ b/t/silent-obsolescent-warns.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# Copyright (C) 2009-2012 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Some checks about silent-rules mode and warnings. + +. ./defs || Exit 1 + +cat >>configure.ac <<'EOF' +AM_SILENT_RULES +AC_OUTPUT +EOF + +cat > Makefile.am <<'EOF' +my_verbose = $(my_verbose_$(V)) +my_verbose_ = $(my_verbose_$(AM_DEFAULT_VERBOSITY)) +my_verbose_0 = @echo " PKG-GEN $@"; +foo: foo.in + $(my_verbose)cp $(srcdir)/foo.in $@ +EOF + +$ACLOCAL +$AUTOMAKE --add-missing + +cat > configure.ac <<'END' +AC_INIT([silent6], [1.0]) +AM_INIT_AUTOMAKE([-Wall]) +AC_CONFIG_FILES([Makefile]) +END + +rm -rf autom4te*.cache +$ACLOCAL +AUTOMAKE_fails +grep 'my_verbose_\$(V.*non-POSIX ' stderr +$AUTOMAKE -Wno-error + +# AM_SILENT_RULES should turn off the warning. +echo 'AM_SILENT_RULES' >> configure.ac +rm -rf autom4te*.cache +$ACLOCAL +$AUTOMAKE +grep 'AM_V_GEN' Makefile.in +$AUTOMAKE --force -Wno-all -Wportability +grep 'AM_V_GEN' Makefile.in + +# The 'silent-rules' option to AM_INIT_AUTOMAKE should work likewise. +cat > configure.ac <<'END' +AC_INIT([silent6], [1.0]) +AM_INIT_AUTOMAKE([silent-rules]) +AC_CONFIG_FILES([Makefile]) +END +rm -rf autom4te*.cache +$ACLOCAL +$AUTOMAKE +grep 'AM_V_GEN' Makefile.in +$AUTOMAKE --force -Wno-all -Wportability +grep 'AM_V_GEN' Makefile.in + +: diff --git a/t/silent6.sh b/t/silent6.sh index 280d25a..1d67a0c 100755 --- a/t/silent6.sh +++ b/t/silent6.sh @@ -20,15 +20,33 @@ cat >>configure.ac <<'EOF' AM_SILENT_RULES +AC_CONFIG_FILES([sub/Makefile]) AC_OUTPUT EOF -cat > Makefile.am <<'EOF' +# We delegate all the work to the subdir makefile. This is done +# to ensure any command-line setting of $(V) gets correctly passed +# down to recursive make invocations. +echo SUBDIRS = sub > Makefile.am + +mkdir sub +cat > sub/Makefile.am <<'EOF' my_verbose = $(my_verbose_$(V)) my_verbose_ = $(my_verbose_$(AM_DEFAULT_VERBOSITY)) -my_verbose_0 = @echo GEN $@; +my_verbose_0 = @echo " XGEN $@"; + +all-local: foo gen-headers -all-local: foo +list = 0 1 2 +.PHONY: gen-headers +gen-headers: + @headers=`for i in $(list); do echo sub/$$i.h; done`; \ + if $(AM_V_P); then set -x; else \ + echo " GEN [headers]"; \ + fi; \ + rm -f $$headers || exit 1; \ +## Only fake header generation. + : generate-header --flags $$headers foo: foo.in $(my_verbose)cp $(srcdir)/foo.in $@ @@ -36,72 +54,48 @@ EXTRA_DIST = foo.in CLEANFILES = foo EOF -: >foo.in +: > sub/foo.in $ACLOCAL $AUTOMAKE --add-missing $AUTOCONF -./configure --enable-silent-rules -$MAKE >stdout || { cat stdout; Exit 1; } -cat stdout -grep '^ *GEN foo *$' stdout -grep 'cp ' stdout && Exit 1 +do_check () +{ + case ${1-} in + --silent) silent=:;; + --verbose) silent=false;; + *) fatal_ "do_check(): incorrect usage";; + esac + shift + $MAKE clean + $MAKE ${1+"$@"} >output 2>&1 || { cat output; Exit 1; } + sed 's/^/ /' output + if $silent; then + $FGREP 'cp ' output && Exit 1 + $FGREP 'generate-header' output && Exit 1 + $FGREP 'rm -f' output && Exit 1 + grep '[012]\.h' output && Exit 1 + grep '^ XGEN foo$' output + grep '^ GEN \[headers\]$' output + else + $FGREP 'GEN ' output && Exit 1 + $FGREP 'cp ./foo.in foo' output + $FGREP "rm -f sub/0.h sub/1.h sub/2.h" output + $FGREP "generate-header --flags sub/0.h sub/1.h sub/2.h" output + fi +} -$MAKE clean -$MAKE V=1 >stdout || { cat stdout; Exit 1; } -cat stdout -grep 'GEN ' stdout && Exit 1 -grep 'cp \.*/foo\.in foo' stdout +./configure --enable-silent-rules +do_check --silent +do_check --verbose V=1 $MAKE distclean ./configure --disable-silent-rules -$MAKE >stdout || { cat stdout; Exit 1; } -cat stdout -grep 'GEN ' stdout && Exit 1 -grep 'cp \.*/foo\.in foo' stdout - -$MAKE clean -$MAKE V=0 >stdout || { cat stdout; Exit 1; } -cat stdout -grep '^ *GEN foo *$' stdout -grep 'cp ' stdout && Exit 1 +do_check --verbose +do_check --silent V=0 $MAKE distclean -$sleep -# Things should also work with -Wall in AM_INIT_AUTOMAKE. -cat > configure.ac <<'END' -AC_INIT([silent6], [1.0]) -AM_INIT_AUTOMAKE([-Wall]) -AC_CONFIG_FILES([Makefile]) -END - -$ACLOCAL -AUTOMAKE_fails -$AUTOMAKE -Wno-error - -# AM_SILENT_RULES should turn off the warning. -$sleep -echo 'AM_SILENT_RULES' >> configure.ac -$ACLOCAL -$AUTOMAKE -grep 'AM_V_GEN' Makefile.in -$AUTOMAKE --force -Wno-all -Wportability -grep 'AM_V_GEN' Makefile.in - -# The 'silent-rules' option to AM_INIT_AUTOMAKE should work likewise. -$sleep -cat > configure.ac <<'END' -AC_INIT([silent6], [1.0]) -AM_INIT_AUTOMAKE([silent-rules]) -AC_CONFIG_FILES([Makefile]) -END -$ACLOCAL -$AUTOMAKE -grep 'AM_V_GEN' Makefile.in -$AUTOMAKE --force -Wno-all -Wportability -grep 'AM_V_GEN' Makefile.in - : -- 1.7.9.5
bug-automake <at> gnu.org
:bug#8665
; Package automake
.
(Fri, 15 Jun 2012 08:22:02 GMT) Full text and rfc822 format available.Message #35 received at 8665 <at> debbugs.gnu.org (full text, mbox):
From: Stefano Lattarini <stefano.lattarini <at> gmail.com> To: automake-patches <at> gnu.org Cc: Jack Kelly <jack <at> jackkelly.name>, 8665 <at> debbugs.gnu.org Subject: Re: [PATCH 0/3] Determine whether silent rules are active from inside a make recipe Date: Fri, 15 Jun 2012 10:18:28 +0200
On 06/11/2012 04:52 PM, Stefano Lattarini wrote: > [Resurrecting an old thread] > > Reference: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8665> > > Hi Jack, automakers, sorry for the shameful delay. > > This patch series (for maint) should take care of the "easy" part of > the bug, i.e., define a make variable that can be used from within the > make recipes to determine whether make is being run in verbose mode > (as with "make V=1") or quiet mode (as with "make V=0"). > > I will push by tomorrow if there is no objection. > > Regards, > Stefano > > Stefano Lattarini (3): > refactor: &define_verbose_var: accept a third optional argument > refactor: silent rules handling (a little) > silent: new $(AM_V_P) variable, tell if we're running in silent mode > > NEWS | 6 +++ > automake.in | 46 ++++++++++++----- > doc/automake.texi | 18 ++++++- > t/list-of-tests.mk | 1 + > t/silent-obsolescent-warns.sh | 71 ++++++++++++++++++++++++++ > t/silent6.sh | 110 +++++++++++++++++++---------------------- > 6 files changed, 180 insertions(+), 72 deletions(-) > create mode 100755 t/silent-obsolescent-warns.sh > Pushed. Regards, Stefano
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.