summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2013-04-22 15:07:43 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2013-04-22 18:01:48 +0200
commit334a2e0b46c3d17ffb24f415cbec2e13e48b6c94 (patch)
treeb6b05062e1f3a39ed5b53c840e9da5050680f20f
parent3de27839c88bda6c755f00c7142620080b725be0 (diff)
downloadautomake-334a2e0b46c3d17ffb24f415cbec2e13e48b6c94.tar.gz
dry-run: with GNU make, prefer $(MFLAGS) over $(MAKEFLAGS)
Fixes automake bug#13760 for GNU make. * lib/am/header-vars.am (am__make_dryrun): If GNU make is being used, rely on the contents of the $(MFLAGS) variable rather than of the $(MAKEFLAGS) to decide whther make is being executed in "dry run" mode. Not only this makes the code possibly faster and less brittle, but also fixes automake bug#13760 (at least when GNU make is in use). * t/make-dryrun.tap: Adjust: some tests that were xfailing now pass. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
-rw-r--r--lib/am/header-vars.am43
-rwxr-xr-xt/make-dryrun.tap4
2 files changed, 30 insertions, 17 deletions
diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index 8295a9994..23c627ed2 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -39,23 +39,36 @@ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
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
+ if $(am__is_gnu_make); then \
+## GNU make: $(MAKEFLAGS) is quite tricky there, and the older
+## $(MFLAGS) variable behaves much better.
+ for am__flg in $$MFLAGS; do \
+ case $$am__flg in \
+ *=*|--*) ;; \
+ -*n*) am__dry=yes; break;; \
+ esac; \
+ done; \
+ else \
+## Non-GNU make: we must rely on $(MAKEFLAGS). This is tricky and brittle,
+## but is the best we can do.
+ case $$MAKEFLAGS in \
+## If we run "make TESTS='snooze nap'", FreeBSD 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; \
+## This has already happened in practice. So we need this unpleasant 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; \
+ fi; \
test $$am__dry = yes; \
}
diff --git a/t/make-dryrun.tap b/t/make-dryrun.tap
index 1459a9f37..208b4210b 100755
--- a/t/make-dryrun.tap
+++ b/t/make-dryrun.tap
@@ -112,10 +112,10 @@ check_make --dry -C using_gmake "\$MAKE is not GNU make" --dry-run -k
pr='bug#13760'
-check_make --run -X -C make_supports_option_I "-I make option unsupported" \
+check_make --run -C make_supports_option_I "-I make option unsupported" \
-M "$pr" -I none
-check_make --run -X -C using_gmake "\$MAKE is not GNU make" \
+check_make --run -C using_gmake "\$MAKE is not GNU make" \
-M "$pr" -I none --include dry-run
check_make --dry -C make_supports_option_I "-I make option unsupported" \