Hash :
947ce0ed
Author :
Date :
2012-02-07T11:12:59
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#! /bin/sh
# Copyright (C) 2012 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check that $(am__make_dryrun) works as expected.
. ./defs || Exit 1
set -e
mkdir sub
echo AC_OUTPUT >> configure.in
cat > Makefile.am <<'END'
all:
: Dummy, nothing to do.
foo:
$(MAKE) all
notdry:
@echo ":: $$MAKEFLAGS ::"; : For debugging.
$(am__make_dryrun) && exit 1; exit 0
dry:
+@echo ":: $$MAKEFLAGS ::"; : For debugging.
+$(am__make_dryrun) || exit 1; echo ok > from-dry-mode
END
$ACLOCAL
$AUTOCONF
$AUTOMAKE
./configure
$MAKE notdry
# Test against a known regressions. This was especially
# heinous, since make running in normal mode was sometimes
# mistaken for make running in dry mode.
$MAKE notdry TESTS="n1.test n2.test"
$MAKE notdry TESTS="n1 n2" AM_MAKEFLAGS="TESTS='n1 n2'"
$MAKE notdry TESTS="n1 n2" AM_MAKEFLAGS='TESTS="n1 n2"'
$MAKE notdry FOOFLAGS="-n -n -knf2 \\n --none -n"
$MAKE notdry BARFLAGS="-n \"n\" '-n' --none -n"
if echo 'all: ; @+printf %sbb%s aa cc' | $MAKE -n -f - | grep aabbcc; then
$MAKE -n dry
test -f from-dry-mode
rm -f from-dry-mode
fi
if using_gmake; then
$MAKE --dry-run -k dry
test -f from-dry-mode
fi
: