automake-ng
[Top][All Lists]
Advanced

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

[Automake-NG] [FYI] [ng] vars: names of iterating vars in $(foreach) loo


From: Stefano Lattarini
Subject: [Automake-NG] [FYI] [ng] vars: names of iterating vars in $(foreach) loops shorter & simpler
Date: Tue, 24 Jul 2012 15:45:41 +0200

In GNU make, after a "$(foreach x,...)" loop, the make variable $(x):

  - is restored to its original variable it had before the 'foreach'
    loop, if it was already set;

  - re-unset otherwise.

This behaviour is checked by the recent spy test 't/spy-foreach.sh'.

This means that, in most situations, there's no actual need to use
a "namespace safe" variable name for the iterating variable in a
"$(foreach ...)" loop, because that variable won't linger in the
environment after the loop anyway.

* lib/am/compile.am, lib/am/header-vars.am, lib/am/parallel-tests.am,
lib/am/serial-tests.am: Adjust to use simpler variables names in their
foreach loops; for example, simply 'v' instead of 'am__v', etc.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 lib/am/compile.am        | 4 ++--
 lib/am/header-vars.am    | 6 +++---
 lib/am/parallel-tests.am | 8 ++++----
 lib/am/serial-tests.am   | 2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/am/compile.am b/lib/am/compile.am
index f874550..af96a3c 100644
--- a/lib/am/compile.am
+++ b/lib/am/compile.am
@@ -21,8 +21,8 @@ AM_DEFAULT_INCLUDES = \
 ## unaesthetic in non-VPATH builds, so get rid of it if it is not
 ## actually needed.
     $(call am.util.uniq, -I. -I$(srcdir) \
-      $(foreach am__h, $(AM_CONFIG_HEADERS), \
-        $(patsubst %/,%,-I$(dir $(am__h)))))))
+      $(foreach h, $(AM_CONFIG_HEADERS), \
+        $(patsubst %/,%,-I$(dir $h))))))
 else !%?STDINC%
 AM_DEFAULT_INCLUDES =
 endif !%?STDINC%
diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index 69a6f92..11ad708 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -138,9 +138,9 @@ am.vpath.rewrite = \
 ## hack with $(subst \ , ...).
 am.make.dry-run := \
   $(strip $(if $(strip \
-    $(foreach am__v, $(subst \ ,,$(strip $(MAKEFLAGS))), \
-      $(if $(or $(findstring =,$(am__v)),$(filter --%,$(am__v))),, \
-        $(findstring n,$(am__v))))), \
+    $(foreach v, $(subst \ ,,$(strip $(MAKEFLAGS))), \
+      $(if $(or $(findstring =,$v),$(filter --%,$v)),, \
+        $(findstring n,$v)))), \
     true, false))
 
 # An empty string.  It can be very useful to "fool" the make parser w.r.t.
diff --git a/lib/am/parallel-tests.am b/lib/am/parallel-tests.am
index 22e1f10..a318281 100644
--- a/lib/am/parallel-tests.am
+++ b/lib/am/parallel-tests.am
@@ -87,10 +87,10 @@ am__tpfx = \
 ## FIXME: this will pick up the default from the environment; are we sure
 ## FIXME: we want that?
 !TEST_EXTENSIONS ?= .test
-!$(foreach am__e,$(filter-out .%,$(TEST_EXTENSIONS)),\
-!     $(call am.error,invalid test extension: '$(am__e)'))
-!$(foreach am__e,$(TEST_EXTENSIONS), \
-!  $(eval $(call am__handle_per_suffix_test,$(am__e))))
+!$(foreach e,$(filter-out .%,$(TEST_EXTENSIONS)),\
+!     $(call am.error,invalid test extension: '$e'))
+!$(foreach e,$(TEST_EXTENSIONS), \
+!  $(eval $(call am__handle_per_suffix_test,$e)))
 ## It is *imperative* that the "empty" suffix goes last.  Otherwise, a
 ## declaration like "TESTS = all.test" would cause GNU make to mistakenly
 ## try to build the 'all.log' and 'all.trs' files from a non-existent
diff --git a/lib/am/serial-tests.am b/lib/am/serial-tests.am
index 7a8f071..8850dbb 100644
--- a/lib/am/serial-tests.am
+++ b/lib/am/serial-tests.am
@@ -23,7 +23,7 @@ if %?HANDLE-EXEEXT%
 am__check_cook_with_exeext_1 = \
     $(if $(filter $(am.all-progs), $1), $1$(EXEEXT), $1)
 am__check_cook_with_exeext = $(strip \
-  $(if $(EXEEXT), $(foreach am__t, $1, $(call $(0)_1, $(am__t))), $1))
+  $(if $(EXEEXT), $(foreach t, $1, $(call $(0)_1, $t)), $1))
 else !%?HANDLE-EXEEXT%
 am__check_cook_with_exeext = $(strip $1)
 endif !%?HANDLE-EXEEXT%
-- 
1.7.12.rc0




reply via email to

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