[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-ng] [PATCH] [ng] dry run: only use GNU make builtins to determ
From: |
Stefano Lattarini |
Subject: |
[Automake-ng] [PATCH] [ng] dry run: only use GNU make builtins to determine whether running dry |
Date: |
Mon, 16 Apr 2012 13:22:20 +0200 |
* lib/am/header-vars.am (am__make_dryrun): only use GNU make builtins to
determine whether make is being running in "dry mode".
* t/nodep.sh: Adjust grepping checks to avoid spurious failures.
Signed-off-by: Stefano Lattarini <address@hidden>
---
I will push by this evening if there is no objection.
Regards,
Stefano
lib/am/header-vars.am | 41 +++++++++++++++--------------------------
t/nodep.sh | 2 +-
2 files changed, 16 insertions(+), 27 deletions(-)
diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index f6ae460..40aa13f 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -29,32 +29,21 @@ am__vpath_rewrite = \
## a vendor make.
## DESTDIR =
-## Shell code that determines whether make is running in "dry mode"
-## ("make -n") or not. Useful in rules that invoke make recursively, and
-## are thus executed also with "make -n" -- because, say, their recipes
-## contain the "$(MAKE)" string or starts with the '+' modifier.
-am__make_dryrun = \
- { \
- am__dry=no; \
- case $$MAKEFLAGS in \
-## If we run "make TESTS='snooze nap'", GNU make will export MAKEFLAGS
-## to "TESTS=foo\ nap", so that the simpler loop below (on word-splitted
-## $$MAKEFLAGS) would see a "make flag" equal to "nap", and would wrongly
-## misinterpret that as and indication that make is running in dry mode.
-## This has already happened in practice. So we need this hack.
- *\\[\ \ ]*) \
- echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
- | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
- *) \
- for am__flg in $$MAKEFLAGS; do \
- case $$am__flg in \
- *=*|--*) ;; \
- *n*) am__dry=yes; break;; \
- esac; \
- done;; \
- esac; \
- test $$am__dry = yes; \
- }
+## Tell whether make is running in "dry mode". It is either 'true' or
+## 'false', so that it can be easily used in shell code as well as in
+## GNU make conditionals.
+## If we run "make TESTS='snooze nap'", GNU make will export MAKEFLAGS to
+## "TESTS=foo\ nap", so that the builtins operating on word-split lists
+## would see a "make flag" equal to "nap" when analyzing $(MAKEFLAGS), and
+## would wrongly misinterpret that as and indication that make is running
+## in dry mode. This has already happened in practice. So we need the
+## hack with $(subst \, ...).
+am__make_dryrun := \
+ $(strip $(if $(strip \
+ $(foreach am__v, $(subst \ ,,$(strip $(MAKEFLAGS))), \
+ $(if $(or $(findstring =,$(am__v)),$(filter --%,$(am__v))),, \
+ $(findstring n,$(am__v))))), \
+ true, false))
## Some derived variables that have been found to be useful.
pkgdatadir = $(datadir)/@PACKAGE@
diff --git a/t/nodep.sh b/t/nodep.sh
index 5dcad1c..1002c54 100755
--- a/t/nodep.sh
+++ b/t/nodep.sh
@@ -36,5 +36,5 @@ mkdir x
$ACLOCAL
$AUTOMAKE
-grep '%' Makefile.in && Exit 1
+$FGREP -v '$(filter --%,' Makefile.in | grep '%' && Exit 1
Exit 0
--
1.7.9.5
- [Automake-ng] [PATCH] [ng] dry run: only use GNU make builtins to determine whether running dry,
Stefano Lattarini <=