automake-ng
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-NG] [PATCH] [ng] silent: simplify by taking advantage of GNU m


From: Stefano Lattarini
Subject: [Automake-NG] [PATCH] [ng] silent: simplify by taking advantage of GNU make semantics
Date: Mon, 18 Jun 2012 11:54:32 +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 <address@hidden>
---

 I will push this by this evening if there is no objection.

 Regards,
   Stefano

 GNUmakefile            |    3 +--
 NG-NEWS                |   29 +++++++++++++++++------------
 automake.in            |   25 +++++--------------------
 doc/automake-ng.texi   |    6 +++---
 lib/am/header-vars.am  |    6 ++++++
 m4/silent.m4           |   12 ++++--------
 t/silent-configsite.sh |    4 ++--
 t/silent6.sh           |    6 +++---
 8 files changed, 41 insertions(+), 50 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index a6ba2f9..d814dfe 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -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 16d0074..f921c2e 100644
--- 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 = $(address@hidden@)
-    pkg_verbose_ = $(address@hidden@)
-
-  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_0 = @echo PKG-GEN $@;
+      pkg_verbose_1 =
+      pkg_verbose = $(pkg_verbose_$(V))
+
+  while the old idiom would have been something like:
+
+      # Old obsolete way, won't work anymore.
+      pkg_verbose = $(address@hidden@)
+      pkg_verbose_ = $(address@hidden@)
+      pkg_verbose_0 = @echo PKG-GEN $@;
 
 
 Warnings and diagnostic
diff --git a/automake.in b/automake.in
index c3a9848..12224e8 100644
--- a/automake.in
+++ b/automake.in
@@ -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.
diff --git a/doc/automake-ng.texi b/doc/automake-ng.texi
index d013210..23749b5 100644
--- a/doc/automake-ng.texi
+++ b/doc/automake-ng.texi
@@ -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 $@@
diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index c4f14d0..636713b 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -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
diff --git a/m4/silent.m4 b/m4/silent.m4
index 3929793..7f4d4b4 100644
--- a/m4/silent.m4
+++ b/m4/silent.m4
@@ -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])])
diff --git a/t/silent-configsite.sh b/t/silent-configsite.sh
index d8c2b33..a31fb2a 100755
--- a/t/silent-configsite.sh
+++ b/t/silent-configsite.sh
@@ -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 || :
diff --git a/t/silent6.sh b/t/silent6.sh
index 0fc3665..8d3a326 100755
--- a/t/silent6.sh
+++ b/t/silent6.sh
@@ -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
 
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]