From: Stefano Lattarini Date: Sun, 15 Apr 2012 20:45:47 +0000 (+0200) Subject: [ng] dry run: only use GNU make builtins to determine whether running dry X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2c35939ef284c2dbb78134f7bc8713b5b171850a;p=thirdparty%2Fautomake.git [ng] dry run: only use GNU make builtins to determine whether running dry * 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 --- diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am index f6ae4609e..40aa13f64 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 5dcad1ce9..1002c5436 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