summaryrefslogtreecommitdiff
path: root/lib/am
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-02-07 11:12:59 +0100
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-02-07 11:12:59 +0100
commit947ce0ed641ca226c632a3c05adfc068b802c518 (patch)
treefc9912f65adf40319c44d1473ada566edf9e0ca0 /lib/am
parentea4f1a91ac1c11a91a21169125b7ed931a4ab7fe (diff)
downloadautomake-947ce0ed641ca226c632a3c05adfc068b802c518.tar.gz
dryrun: fix regression with '$(am__make_dryrun)'
In commit v1.11-683-gda0964e of 05-02-2012, we introduced a new variable '$(am__make_dryrun)' that could be used in recipes to determine whether make is running in dry mode (e.g., as with "make -n"). Unfortunately, the idiom we used fails to take into account the case in which $(MAKEFLAGS) contains one or more variable definitions whose value is a whitespace-separated list; for example, if we invoke make as: make check TESTS="n1.test n2.test" then the better make implementations out there (at least modern GNU make and BSD make) will export MAKEFLAGS to the following value: TESTS=n1.test\ n2.test So a shell loop like the one we used in $(am__make_dryrun): for flag in $$MAKEFLAGS; do ... won't behave as expected: the shell word-splitting rules will break up the entry for TESTS into the two distinct entries "TESTS=n1.test\" and "n2.test", and this second entry will goad our $(am__make_dryrun) code into thinking that make is performing a dry run! So now we simply loop over the expanded value of $(MAKEFLAGS). This solves the regression, but alas, is more brittle in case the users passes on the command line a macro value containing unbalanced " or ' quotes, or shell metacharacters like, say, '`' or '('. This should almost never happen though, so we don't worry about it now; we will revisit the issue only when and if we receive bug reports in this area. * lib/am/header-vars.am (am__make_dryrun): Fix. * tests/make-dryrun.test: New test. * tests/list-of-tests.mk: Add it.
Diffstat (limited to 'lib/am')
-rw-r--r--lib/am/header-vars.am3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index 0f05731ae..1078a3d5d 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -35,8 +35,9 @@ VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
- for am__flg in $$MAKEFLAGS; do \
+ for am__flg in : $(MAKEFLAGS); do \
case $$am__flg in \
+ :) ;; \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \