dryrun: fix regression with '$(am__make_dryrun)'
commit947ce0ed641ca226c632a3c05adfc068b802c518
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 7 Feb 2012 10:12:59 +0000 (7 11:12 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 7 Feb 2012 10:12:59 +0000 (7 11:12 +0100)
treefc9912f65adf40319c44d1473ada566edf9e0ca0
parentea4f1a91ac1c11a91a21169125b7ed931a4ab7fe
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.
lib/am/header-vars.am
tests/list-of-tests.mk
tests/make-dryrun.test [new file with mode: 0755]