summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2013-05-04 11:50:10 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2013-05-04 11:50:10 +0200
commit2d3a2e36b595cd740894823d060e31c6c483f569 (patch)
treeba74fa042ecc41e025c2d37725b222b4db790e73 /lib
parente5e3a629e01c7642a46217817c32cfa86e9bd708 (diff)
parentf5f75eef28a32493258047eb3060478395a42120 (diff)
downloadautomake-2d3a2e36b595cd740894823d060e31c6c483f569.tar.gz
Merge branch 'branch-1.13.2' into maint
* branch-1.13.2: maint: targets and recipes to simplify testing on real-world packages build: preparatory refactoring build: tiny reduction in code duplication make flags analysis: handle more options with args make flags analysis: use simpler variable names make flags analysis: whitespace changes make flags analysis: embed in a subshell make flags analysis: be more robust make flags analysis: cater to GNU make 3.83 (still unreleased as of now) tests: expose weaknesses in make flags analysis tests: improve debugging output in checks on make flags analysis make flags analysis: refactor, to reduce code duplication tests: avoid one tricky use of "make -e" tests: avoid a spurious error with Solaris make subdirs: don't return false positives for the '-k' option's presence header-vars: recognize more make flags ('-k' in particular) header-vars: simplify how make flags are determined tests: remove dead code from t/make-dryrun.tap header-vars: new variable $(am__running_with_option) tests: expose bug#12554 (false positives for presence of '-k' make option)
Diffstat (limited to 'lib')
-rw-r--r--lib/am/header-vars.am120
-rw-r--r--lib/am/subdirs.am13
2 files changed, 83 insertions, 50 deletions
diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index d2f098425..4b9cc04cb 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -31,54 +31,88 @@ VPATH = @srcdir@
## enough for now.
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+## Shell code that determines whether the current make instance is
+## running with a given one-letter option (e.g., -k, -n) that takes
+## no argument. Actually, the only supported option at the moment
+## is '-n' (support for '-k' will be added soon).
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+## The format of $(MAKEFLAGS) is quite tricky with GNU make; the
+## variable $(MFLAGS) behaves much better in that regard. So use it.
+ sane_makeflags=$$MFLAGS; \
+ else \
+## Non-GNU make: we must rely on $(MAKEFLAGS). This is tricker and more
+## 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.
+ *\\[\ \ ]*) \
+## Extra indirection with ${bs} required by FreeBSD 8.x make.
+## Not sure why (so sorry for the cargo-cult programming here).
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+##
+## GNU make 3.83 has changed the format of $MFLAGS, and removed the space
+## between an option and its argument (e.g., from "-I dir" to "-Idir").
+## So we need to handle both formats, at least for options valid in GNU
+## make. OTOH, BSD make formats $(MAKEFLAGS) by separating all options,
+## and separating any option from its argument, so things are easier
+## there.
+##
+## For GNU make and BSD make.
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+## For GNU make >= 3.83.
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+## For GNU make (possibly overkill, this one).
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+## For BSD make.
+ -[dEDm]) skip_next=yes;; \
+## For NetBSD make.
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+
## Shell code that determines whether make is running in "dry mode"
## ("make -n") or not. Useful in rules that invoke make recursively,
## and are thus executed also with "make -n" -- either because they
## are declared as dependencies to '.MAKE' (NetBSD make), or because
## their recipes contain the "$(MAKE)" string (GNU and Solaris make).
-am__make_dryrun = \
- { \
- am__dry=no; \
- 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 unpleasant hack.
- *\\[\ \ ]*) \
- echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
- | grep '^AM OK$$' >/dev/null || am__dry=yes ;; \
- *) \
- am__skip_next=no; \
- for am__flg in $$MAKEFLAGS; do \
- if test $$am__skip_next = yes; then \
- am__skip_next=no; \
- continue; \
- fi; \
- case $$am__flg in \
- *=*|--*) ;; \
-## Quite ugly special-casing. We might need other similar, but let's
-## wait until the need arises.
- -I) am__skip_next=yes;; \
- *n*) am__dry=yes; break;; \
- esac; \
- done ;;\
- esac; \
- fi; \
- test $$am__dry = yes; \
- }
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+
+## Shell code that determines whether make is running in "keep-going mode"
+## ("make -k") or not. Useful in rules that must recursively descend into
+## subdirectories, and decide whther to stop at the first error or not.
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
## Some derived variables that have been found to be useful.
pkgdatadir = $(datadir)/@PACKAGE@
diff --git a/lib/am/subdirs.am b/lib/am/subdirs.am
index c4c3694cb..999aa7877 100644
--- a/lib/am/subdirs.am
+++ b/lib/am/subdirs.am
@@ -39,13 +39,12 @@ AM_RECURSIVE_TARGETS += $(am__recursive_targets:-recursive=)
$(am__recursive_targets):
## Using $failcom allows "-k" to keep its natural meaning when running a
## recursive rule.
- @fail= failcom='exit 1'; \
- for f in x $$MAKEFLAGS; do \
- case $$f in \
- *=* | --[!k]*);; \
- *k*) failcom='fail=yes';; \
- esac; \
- done; \
+ @fail=; \
+ if $(am__make_keepgoing); then \
+ failcom='fail=yes'; \
+ else \
+ failcom='exit 1'; \
+ fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
## For distclean and maintainer-clean we make sure to use the full