diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-04-27 16:09:43 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-04-29 16:16:39 +0200 |
commit | e432b0d3f7deffd3468e7b32ab6760bc7f3148f2 (patch) | |
tree | 0bbe22ceb134e2354d47e786949cd9eb6bcee552 /lib/am/header-vars.am | |
parent | c97218a54271bdcc59a0a7b67704feb5344b89d9 (diff) | |
download | automake-e432b0d3f7deffd3468e7b32ab6760bc7f3148f2.tar.gz |
header-vars: simplify how make flags are determined
Actually, son far only the '-n' option ("dry mode") was detected,
but this change will allow us to soon detect more options.
* lib/am/header-vars.am (am__running_with_option): Even when $MAKEFLAGS
appears to contain definition of variables with embedded whitespace,
use simple textual pre-processing over $MAKEFLAGS rather than tricky
recursive invocations of make to determine whether the '-n' option was
given. This is enough to correctly handle all the tricky usages covered
in the testsuite.
* t/nodep.sh: Adjust to avoid a spurious failure.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 'lib/am/header-vars.am')
-rw-r--r-- | lib/am/header-vars.am | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am index 8426dcb1e..c0a5f0c8b 100644 --- a/lib/am/header-vars.am +++ b/lib/am/header-vars.am @@ -40,7 +40,7 @@ am__make_running_with_option = \ case $${am__target_option-} in \ n) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${am__target_option-}' specified" >&2; \ + "target option '$${am__target_option-}' specified" >&2; \ exit 1;; \ esac; \ am__has_opt=no; \ @@ -54,8 +54,8 @@ am__make_running_with_option = \ esac; \ done; \ else \ -## Non-GNU make: we must rely on $(MAKEFLAGS). This is tricky and brittle, -## but is the best we can do. +## 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 @@ -63,25 +63,30 @@ am__make_running_with_option = \ ## 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__has_opt=yes ;; \ +## Extra indirection with ${am__bs} required by FreeBSD 8.x make. +## Not sure why (so sorry for the cargo-cult programming here). + am__bs=\\; \ + am__flags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$am__bs$$am__bs[$$am__bs $$am__bs ]*//g"`;; \ *) \ - 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;; \ - *$$am__target_option*) am__has_opt=yes; break;; \ - esac; \ - done ;;\ - esac; \ + am__flags=$$MAKEFLAGS;; \ + esac; \ + am__skip_next=no; \ + for am__flg in $$am__flags; 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 ones actually, +## but let's wait until the need arises. + -I) am__skip_next=yes;; \ + *$$am__target_option*) am__has_opt=yes; break;; \ + esac; \ + done;\ fi; \ + unset am__skip_next am__flg am__flags am__target_option; \ test $$am__has_opt = yes; \ } |