# 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 \ , ...).
+# GNU make conditionals. Use $(MFLAGS), not $(MAKEFLAGS), since the
+# former doesn't containing the command line variable definitions, and
+# it always begins with a hyphen unless it is empty, assumptions that
+# allow a simpler implementation.
am.make.dry-run := \
- $(strip $(if $(strip \
- $(foreach v, $(subst \ ,,$(strip $(MAKEFLAGS))), \
- $(if $(or $(findstring =,$v),$(filter --%,$v)),, \
- $(findstring n,$v)))), \
- true, false))
+ $(if $(findstring n,$(filter-out --%,$(MFLAGS))),true,false)
am.util.strip-first-word = $(wordlist 2,$(words $(1)),$(1))
am.util.strip-last-word = $(wordlist 2,$(words $(1)),dummy $(1))
. ./defs || exit 1
-plan_ 32
+plan_ 14
echo AC_OUTPUT >> configure.ac
all:
@echo "Target '$@' should never run" >&2; exit 1;
notdry-plain:
- @echo ":: $$MAKEFLAGS ::" # For debugging.
- @$(warning << $(MAKEFLAGS) >>) # Likewise.
$(am.make.dry-run) && exit 1; exit 0
notdry-recursive:
$(MAKE) notdry-plain
dry-plain:
- +@echo ":: $$MAKEFLAGS ::" # For debugging.
- +@$(warning << $(MAKEFLAGS) >>) # Likewise.
+$(am.make.dry-run) || exit 1; echo ok > from-dry-mode
dry-recursive:
$(MAKE) dry-plain
-foo = $(error foo should not be expanded)
END
$ACLOCAL || fatal_ "aclocal failed"
cnt=1
check_no_dryrun
+check_no_dryrun -k
# Test against a known regression. This was especially heinous, since
# make running in normal mode was sometimes mistaken for make running
# in dry mode.
-check_no_dryrun TESTS="n1.test n2.test"
-check_no_dryrun TESTS="n1 n2"
-check_no_dryrun TESTS="n1 n2"
-check_no_dryrun FOOFLAGS="-n -n -knf2 n --none -n"
-check_no_dryrun MYFLAGS="-n --dryrun -n --dry-run -n"
mkdir n ./--dry-run
check_no_dryrun -I n
check_no_dryrun -I --dry-run
# ----------------------------------------------------------------------
-# Test for when shell metacharacters or backslashes are in $(MAKEFLAGS).
-
-check_metachars ()
-{
- for kind in plain recursive; do
- command_ok_ "wet-run, $kind, with shell metachars ($cnt)" \
- $MAKE notdry-$kind ${1+"$@"}
- done
- cnt=$(($cnt + 1))
-}
-cnt=1
-
-check_metachars MYFLAGS="-n \"n\" '-n' --none -n"
-check_metachars MYFLAGS='-knf2\ n\ \\n'
-check_metachars MYFLAGS="(&) | ; \" \` '"
-check_metachars MYFLAGS=" ' # ' "
-check_metachars MYFLAGS='$(foo)'
-
-# ----------------------------------------------------------------------
-
: