* Ralf Wildenhues wrote on Sun, Mar 08, 2009 at 10:07:06AM CET: > * Jan Engelhardt wrote on Sat, Mar 07, 2009 at 07:17:03PM CET: > > > > I am missing the definition of am__v_GEN in the generated Makefile > > that is designed for use with manual rules. Like, > > > > # -*- Makefile -*- > > > > man8_MANS = foo.8 > > > > foo.8: foo.8.in > > ${am__v_GEN}man -l foo.8.in >$@ > > Good point; thanks. The user extensibility should be documented, too. > So far, the only extensibility I've put in was in tests/silent6.test, > but it's a good idea to have automake add a documented variable. > > And those variables should not be in the am__ namespace. Hmm, I think > that means those variables appearing directly in %VERBOSE% should not be > in that space either.
Fixed with this couple of patches, pushed to the branch. Cheers, Ralf Redo variable naming for `silent' machinery. The public variables are named `AM_V_' plus the compiler short-hand now, e.g.: AM_V_CC, AM_V_CXXLD, AM_V_GEN. The dispatch variables are internal details and begin with `am__v_'. * automake.in (verbose_var): Update comment. (verbose_private_var): New function. Order functions so that ones not needed outside this section are listed first. (verbose_dispatch): Remove, no need to factor this. (define_verbose_var, define_verbose_libtool): Use verbose_private_var. (define_verbose_tagvar): Likewise; and simplify. Report by Jan Engelhardt. diff --git a/automake.in b/automake.in index 675a1fe..9757ed7 100755 --- a/automake.in +++ b/automake.in @@ -1115,13 +1115,41 @@ sub backname ($) # verbose_var (NAME) # ------------------ -# The naming policy for the variables used to implement `silent'. +# The public variable stem used to implement `silent'. sub verbose_var ($) { my ($name) = @_; + return 'AM_V_' . $name; +} + +# verbose_private_var (NAME) +# -------------------------- +# The naming policy for the private variables used to implement `silent'. +sub verbose_private_var ($) +{ + my ($name) = @_; return 'am__v_' . $name; } +# define_verbose_var (NAME, VAL) +# ------------------------------ +# For `silent' mode, setup VAR and dispatcher, to expand to VAL if silent. +sub define_verbose_var ($$) +{ + my ($name, $val) = @_; + my $var = verbose_var ($name); + my $pvar = verbose_private_var ($name); + if (option 'silent') + { + # Using `$V' instead of `$(V)' breaks IRIX make. + define_variable ($var, '$(' . $pvar . '_$(V))', INTERNAL); + define_variable ($pvar . '_', $val, INTERNAL); + define_variable ($pvar . '_0', $val, INTERNAL); + } +} + +# Above should not be needed in the general automake code. + # verbose_flag (NAME) # ------------------- # Contents of %VERBOSE%: variable to expand before rule command. @@ -1133,16 +1161,6 @@ sub verbose_flag ($) return ''; } -# verbose_dispatch (VAR) -# ---------------------- -# Recursive variable dispatch string. -sub verbose_dispatch ($) -{ - my ($var) = @_; - # Using `$V' instead of `$(V)' breaks IRIX make. - return '$(' . $var . '_$(V))'; -} - # silent_flag # ----------- # Contents of %SILENT%: variable to expand to `@' when silent. @@ -1151,40 +1169,16 @@ sub silent_flag () return verbose_flag ('at'); } -# define_verbose_var (VAR, VAL) -# ----------------------------- -# For `silent' mode, setup VAR and dispatcher, to expand to VAL if silent. -sub define_verbose_var ($$) -{ - my ($var, $val) = @_; - if (option 'silent') - { - define_variable ($var, verbose_dispatch ($var), INTERNAL); - define_variable ($var . '_', $val, INTERNAL); - define_variable ($var . '_0', $val, INTERNAL); - } -} - # define_verbose_tagvar (NAME) # ---------------------------- # Engage the needed `silent' machinery for tag NAME. sub define_verbose_tagvar ($) { my ($name) = @_; - my $var = verbose_var ($name); - if (option 'silent' && !vardef ($var, TRUE)) + if (option 'silent') { - Automake::Variable::define ($var, VAR_AUTOMAKE, '', TRUE, - verbose_dispatch ($var), - '', INTERNAL, VAR_ASIS); - Automake::Variable::define ($var . '_' , VAR_AUTOMAKE, '', TRUE, - '$(' . $var . '_0)', - '', INTERNAL, VAR_ASIS); - Automake::Variable::define ($var . '_0', VAR_AUTOMAKE, '', TRUE, - '@echo " '. $name . ' ' x (6 - length ($name)) . '" $@;', - '', INTERNAL, VAR_ASIS); - my $silent = verbose_var ('at'); - define_verbose_var ($silent, '@'); + define_verbose_var ($name, '@echo " '. $name . ' ' x (6 - length ($name)) . '" $@;'); + define_verbose_var ('at', '@'); } } @@ -1193,10 +1187,8 @@ sub define_verbose_tagvar ($) # Engage the needed `silent' machinery for `libtool --silent'. sub define_verbose_libtool () { - my $var = verbose_var ('lt'); - my $flag = verbose_flag ('lt'); - define_verbose_var ($var, '--silent'); - return $flag; + define_verbose_var ('lt', '--silent'); + return verbose_flag ('lt'); } Provide variables for silencing of user rules. * automake.in (handle_languages): Always define `AM_V_GEN' and `AM_V_at'. * doc/automake.texi (Options): Document these flags. * tests/silent7.test: New test. * tests/Makefile.am: Update. diff --git a/automake.in b/automake.in index 9757ed7..7286a44 100755 --- a/automake.in +++ b/automake.in @@ -1649,6 +1649,9 @@ sub handle_languages unless defined $done{$languages{'c'}}; define_linker_variable ($languages{'c'}); } + + # Always provide the user with `AM_V_GEN' for `silent' mode. + define_verbose_tagvar ('GEN'); } diff --git a/doc/automake.texi b/doc/automake.texi index da6e779..2a22ca4 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -8733,6 +8733,14 @@ variable expansion @samp{$(@var{var1}$(V))}. Do not use the expansion, which are in turn enabled by @option{-Wportability} (@pxref{Invoking Automake}). +...@vindex @code{AM_V_GEN} +...@vindex @code{AM_V_at} +To extend the silent mode to your own rules, 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. With @code{V=1}, these +variables will expand to empty strings. + @item @option{std-options} @cindex Options, @option{std-options} @cindex @samp{make installcheck}, testing @option{--help} and @option{--version} diff --git a/tests/Makefile.am b/tests/Makefile.am index a1af65d..2197a11 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -542,6 +542,7 @@ silent3.test \ silent4.test \ silent5.test \ silent6.test \ +silent7.test \ sinclude.test \ srcsub.test \ srcsub2.test \ diff --git a/tests/silent7.test b/tests/silent7.test new file mode 100755 index 0000000..4fd52f3 --- /dev/null +++ b/tests/silent7.test @@ -0,0 +1,71 @@ +#!/bin/sh +# Copyright (C) 2009 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 3, 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/>. + +# Check user extensibility of silent mode. + +. ./defs + +set -e + +cat >>configure.in <<'EOF' +AC_OUTPUT +EOF + +cat > Makefile.am <<'EOF' +all-local: foo + +## And here's how you should do it in your own code: +foo: foo.in + $(AM_V_GEN)cp $(srcdir)/foo.in $@ + $(AM_V_at)echo more >> $@ + +EXTRA_DIST = foo.in +CLEANFILES = foo +EOF + +: >foo.in + +$ACLOCAL +$AUTOMAKE --add-missing +$AUTOCONF + +./configure +$MAKE >stdout || { cat stdout; Exit 1; } +cat stdout +grep 'GEN.*foo' stdout && Exit 1 +grep 'cp ' stdout +grep 'echo ' stdout + +$MAKE distclean + +echo 'AUTOMAKE_OPTIONS = silent' >> Makefile.am +$AUTOMAKE + +./configure +$MAKE >stdout || { cat stdout; Exit 1; } +cat stdout +grep 'GEN.*foo' stdout +grep 'cp ' stdout && Exit 1 +grep 'echo ' stdout && Exit 1 + +$MAKE clean +$MAKE V=1 >stdout || { cat stdout; Exit 1; } +cat stdout +grep 'GEN.*foo' stdout && Exit 1 +grep 'cp ' stdout +grep 'echo ' stdout + +: