]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
[bg] silent: simplify by taking advantage of GNU make semantics
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 18 Jun 2012 09:33:00 +0000 (11:33 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 18 Jun 2012 13:35:31 +0000 (15:35 +0200)
In particular, taking advantage of the fact that, in GNU make, command
line override of variables is propagated to recursive make invocations.

This change offers us a small but nice size reduction bot in Automake's
code and in the generated Makefiles.  It also improves the API to define
custom silent "tags", by turning it from:

    pkg_verbose = $(pkg_verbose_$(V))
    pkg_verbose_ = $(pkg_verbose_$(AM_DEFAULT_V))
    pkg_verbose_0 = @echo PKG-GEN $@;

to the slightly clearer:

    pkg_verbose = $(pkg_verbose/$(V))
    pkg_verbose/1 =
    pkg_verbose/0 = @echo PKG-GEN $@;

* NG-NEWS: Update.
* doc/automake-ng.texi (Automake Silent Rules): Update w.r.t. the
API for user-defined silent rules.
* automake.in: Simplify, by removing the indirections involving
$(AM_DEFAULT_VERBOSITY); some other changes and simplifications.
(verbose_private_var): Delete, its calls from &define_verbose_var
deleted (and those were its only calls).
* lib/am/header-vars.am: Define '$(V)' to 0 if it's not already
defined.
* m4/silent.m4: Initialize and AC_SUBST the variable 'V' directly,
instead of of the indirect 'AM_DEFAULT_VERBOSITY'.  Do not set nor
AC_SUBST the variable 'AM_BACKSLASH', it's not used anymore (and
hasn't been since out overhauling and simplification of the compile
rules).
* GNUmakefile: Simplify a little.
* t/silent6.sh, t/silent-configsite.sh: Adjust.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
GNUmakefile
NG-NEWS
automake.in
doc/automake-ng.texi
lib/am/header-vars.am
m4/silent.m4
t/silent-configsite.sh
t/silent6.sh

index a6ba2f99c936dff8519eb2f573b694e84ab5a8f1..d814dfe41ac676ece5f7b981a0e0c74a994b02d3 100644 (file)
@@ -35,8 +35,7 @@ endif
 # To allow bootstrapping also in an unconfigured tree.
 srcdir ?= .
 am__cd ?= CDPATH=. && unset CDPATH && cd
-AM_DEFAULT_VERBOSITY ?= 0
-V ?= $(AM_DEFAULT_VERBOSITY)
+V ?= 0
 
 ifeq ($(V),0)
   AM_V_BOOTSTRAP = @echo "  BOOTSTRAP";
diff --git a/NG-NEWS b/NG-NEWS
index 16d0074882dd491ba45b3f837d4da1f973b818b0..7776ed9371c6e20852b4352ab7498d00c514face 100644 (file)
--- a/NG-NEWS
+++ b/NG-NEWS
@@ -25,18 +25,23 @@ Automatic dependency tracking support
 Silent rules
 ============
 
-* The silent-rules support unconditionally assumes that nested variables
-  expansion are supported.  Accordingly, the AC_SUBST'd variables '@AM_V@'
-  and'@AM_DEFAULT_V@' have been removed, so that instead of using
-  something like:
-
-    pkg_verbose = $(pkg_verbose_@AM_V@)
-    pkg_verbose_ = $(pkg_verbose_@AM_DEFAULT_V@)
-
-  you should simply use:
-
-    pkg_verbose = $(pkg_verbose_$(V))
-    pkg_verbose_ = $(pkg_verbose_$(AM_DEFAULT_VERBOSITY))
+* The silent rules support has been simplified to take advantage
+  of more GNU make features.  Among other things, the AC_SUBST'd
+  variables '@AM_V@' and'@AM_DEFAULT_V@' have been removed.  Now,
+  when defining uses custom silent rules, you should do something
+  like:
+
+      # Modern correct way.
+      pkg_verbose = $(pkg_verbose/$(V))
+      pkg_verbose/0 = @echo PKG-GEN $@;
+      pkg_verbose/1 =
+
+  while the old idiom would have been something like:
+
+      # Old obsolete way, won't work anymore.
+      pkg_verbose = $(pkg_verbose_@AM_V@)
+      pkg_verbose_ = $(pkg_verbose_@AM_DEFAULT_V@)
+      pkg_verbose_0 = @echo PKG-GEN $@;
 
 
 Warnings and diagnostic
index c3a9848da3948cb5715179fb1f2635aef0064d26..12224e8ba1c71ec9363810244653bc2d9d3f57e8 100644 (file)
@@ -1119,15 +1119,6 @@ sub verbose_var ($)
     return 'AM_V_' . $name;
 }
 
-# verbose_private_var (NAME)
-# --------------------------
-# The naming policy for the private variables for silent rules.
-sub verbose_private_var ($)
-{
-    my ($name) = @_;
-    return 'am__v_' . $name;
-}
-
 # define_verbose_var (NAME, VAL-IF-SILENT, [VAL-IF-VERBOSE])
 # ----------------------------------------------------------
 # For  silent rules, setup VAR and dispatcher, to expand to
@@ -1138,19 +1129,13 @@ 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';
-    define_variable ($var, INTERNAL,
-                     '$(' . $pvar . '_$(V))');
-    define_variable ($pvar . '_', INTERNAL,
-                     '$(' . $pvar . '_$(AM_DEFAULT_VERBOSITY))');
-    Automake::Variable::define ($silent_var, VAR_AUTOMAKE, '', TRUE,
+    define_variable ($var, INTERNAL, "\$($var/\$V)");
+    Automake::Variable::define ("$var/0", VAR_AUTOMAKE, '', TRUE,
                                 $silent_val, '', INTERNAL)
-      if (! vardef ($silent_var, TRUE));
-    Automake::Variable::define ($verbose_var, VAR_AUTOMAKE, '', TRUE,
+      if (! vardef ("$var/0", TRUE));
+    Automake::Variable::define ("$var/1", VAR_AUTOMAKE, '', TRUE,
                                 $verbose_val, '', INTERNAL)
-      if (! vardef ($verbose_var, TRUE));
+      if (! vardef ("$var/1", TRUE));
 }
 
 # Above should not be needed in the general automake code.
index d0132104354610f2fcc9fed08ca8bf0dddcc781c..23749b58a684fc7e12973a96f7b1457df85f26f3 100644 (file)
@@ -10783,9 +10783,9 @@ The following snippet shows how you would define your own equivalent of
 @code{AM_V_GEN}:
 
 @example
-pkg_verbose = $(pkg_verbose_$(V))
-pkg_verbose_ = $(pkg_verbose_$(AM_DEFAULT_VERBOSITY))
-pkg_verbose_0 = @@echo PKG-GEN $@@;
+pkg_verbose = $(pkg_verbose/$(V))
+pkg_verbose/1 =
+pkg_verbose/0 = @@echo PKG-GEN $@@;
 
 foo: foo.in
         $(pkg_verbose)cp $(srcdir)/foo.in $@@
index c4f14d0181e2ff35347ce93b87a749fc58c63455..636713b9b7c425a3529023f90349754ef8ae1e92 100644 (file)
@@ -60,6 +60,12 @@ ifdef SUBDIRS
   endif
 endif
 
+# Be verbose by deafault.  Yes, we really want $(V) to be overridable
+# from the environment, both for simplicity and for consistency with
+# mainline Automake.
+# FIXME: maybe normalize/sanitize $(V)?
+V ?= 0
+
 am__mkdir = test -d $1 || $(MKDIR_P) $1
 
 # In a recipe, ensure the given directory exists, creating it if
index 3929793049515b0865a60a729294cf63f036902d..7f4d4b4a47ac9cb88a22c0987a75ddfd72d2f599 100644 (file)
@@ -21,12 +21,8 @@ AS_HELP_STRING(
   [verbose build output (undo: "make V=0")])dnl
 ])
 case $enable_silent_rules in @%:@ (((
-  yes) AM_DEFAULT_VERBOSITY=0;;
-   no) AM_DEFAULT_VERBOSITY=1;;
-    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+  yes) V=0;;
+   no) V=1;;
+    *) V=m4_if([$1], [yes], [0], [1]);;
 esac
-AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
-AM_BACKSLASH='\'
-AC_SUBST([AM_BACKSLASH])dnl
-_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
-])
+AC_SUBST([V])])
index d8c2b3322a9ff2244e3eb923d45e2e4f9a19f985..a31fb2a6401c4e2ffc5cc46501d00d7cb6888f5f 100755 (executable)
@@ -28,9 +28,9 @@ EOF
 cat > Makefile.am <<'EOF'
 .PHONY: test-silent test-nosilent
 test-silent:
-       test x'$(AM_DEFAULT_VERBOSITY)' = x'0'
+       $(AM_V_P); test $$? -eq 1
 test-nosilent:
-       test x'$(AM_DEFAULT_VERBOSITY)' = x'1'
+       $(AM_V_P); test $$? -eq 0
 EOF
 
 unset enable_silent_rules || :
index 0fc36650968d8f28ea06715b0a887a31bef8df0d..8d3a3260d43cd9d503ada14bb71af4e45288003f 100755 (executable)
@@ -30,9 +30,9 @@ 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 " XGEN    $@";
+my_verbose = $(my_verbose/$(V))
+my_verbose/0 = @echo " XGEN    $@";
+my_verbose/1 =
 
 all-local: foo gen-headers