automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] dry-run: with GNU make, prefer $(MFLAGS) over $(MAKEFLAGS)


From: Stefano Lattarini
Subject: [PATCH 2/3] dry-run: with GNU make, prefer $(MFLAGS) over $(MAKEFLAGS)
Date: Tue, 23 Apr 2013 11:12:47 +0200

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 <address@hidden>
---
 lib/am/header-vars.am | 43 ++++++++++++++++++++++++++++---------------
 t/make-dryrun.tap     |  4 ++--
 2 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index 8295a99..23c627e 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 1459a9f..208b421 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" \
-- 
1.8.2.1.389.gcaa7d79




reply via email to

[Prev in Thread] Current Thread [Next in Thread]