GNU bug report logs - #13760
am__make_dryrun fails to handle GNU make -I option

Previous Next

Package: automake;

Reported by: Boris Kolpackov <boris <at> codesynthesis.com>

Date: Tue, 19 Feb 2013 16:54:01 UTC

Severity: normal

Tags: patch

Done: Stefano Lattarini <stefano.lattarini <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13760 in the body.
You can then email your comments to 13760 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Tue, 19 Feb 2013 16:54:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Boris Kolpackov <boris <at> codesynthesis.com>:
New bug report received and forwarded. Copy sent to bug-automake <at> gnu.org. (Tue, 19 Feb 2013 16:54:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Boris Kolpackov <boris <at> codesynthesis.com>
To: bug-automake <at> gnu.org
Subject: am__make_dryrun fails to handle GNU make -I option
Date: Tue, 19 Feb 2013 12:34:26 +0200
Hi,

After upgrading from 1.11.1 to 1.11.6 or 1.12.6, or 1.13.1 my
project's dist target stopped working. After some debugging,
the culprit turned out to be am__make_dryrun function that
mis-detects make dry-run mode (make -n) if make flags contain
a -I option with a path containing character 'n'. In my case,
flags come from the MAKEFLAGS environment variable which has
the following value:

-I ~/work/build -I/opt/qnx632/target/qnx6/usr/include

The MAKEFLAGS value as passed to the shell by make then becomes
(note the missing '-' in the first option -- that's documented
GNU make behavior):

"I /home/boris/work/build -I /opt/qnx632/target/qnx6/usr/include"

am__make_dryrun then goes ahead and check each word in this list
for the presence of 'n' and finds it in the path.

I've had some dealings with GNU make's MAKEFLAGS and the semantics
is quite convoluted. GNU make doesn't just store flags the way they
appeared on the command line. Instead, it translates, combines, and
rearranges them in a certain way. For example, GNU make will combine
certain one-letter options (including -n) and place them at the front
of MAKEFLAGS without the preceding '-'. For example:

make -n -k -j 2 foo=bar => "nk --jobserver-fds=3,4 -j -- foo=bar"

Generally, in GNU make, the -n option (or its aliases) will always
be translated and come in the first word of MAKEFLAGS. And the first
word in MAKEFLAGS is always one of the following:

1. Empty. If no "old" options (those that are combined in the
   first word) were specified but a new option was, then GNU make
   will add a leading space to the MAKEFLAGS, for example:

   make -j 2 => " --jobserver-fds=3,4 -j"

2. The "old" options combination (including -n), one letter per
   option, for example:

   make -n -k -j 2 => "nk --jobserver-fds=3,4 -j"

3. Command line variable assignment. If no options were specified
   ("old" or "new") but a variable assignment was specified, then
   the first word will be the variable assignment, for example
   (note that there is no leading space as in (2)):

   make foo=bar => "foo=bar"

So, based on this knowledge, for GNU make, all we need to do is
examine the first word in MAKEFLAGS. If it contains '=', then it
is a variable assignment, otherwise, we search for the 'n' character.

The complication is that we have to also support other makes (BSD,
Solaris). I have no idea about their MAKEFLAGS behavior.

Boris




Information forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Wed, 20 Feb 2013 13:10:01 GMT) Full text and rfc822 format available.

Message #8 received at 13760 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: 13760 <at> debbugs.gnu.org
Cc: boris <at> codesynthesis.com, automake-patches <at> gnu.org
Subject: [PATCH 0/2] am__make_dryrun fails to handle GNU make -I option
Date: Wed, 20 Feb 2013 14:07:51 +0100
Reference: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13760>

On 02/19/2013 11:34 AM, Boris Kolpackov wrote:
> Hi,
>
Hi Boris, thanks for the clear and detailed report.

> After upgrading from 1.11.1 to 1.11.6 or 1.12.6, or 1.13.1 my
> project's dist target stopped working. After some debugging,
> the culprit turned out to be am__make_dryrun function that
> mis-detects make dry-run mode (make -n) if make flags contain
> a -I option with a path containing character 'n'.
>
For the moment, I have exposed the bug you have reported in the
testsuite (see the two upcoming patches).  This issue shouldn't
be too difficult too fix; I hope I'll be able to cook something
in the next days, in time for the next beta for 1.13.2.

> So, based on this knowledge, for GNU make, all we need to do is
> examine the first word in MAKEFLAGS. If it contains '=', then it
> is a variable assignment, otherwise, we search for the 'n' character.
>
This might be OK for GNU make:

  $ gmake -ki -I none -k -f- <<<'all:;@echo "$$MAKEFLAGS"'
  kI none -i

but not, e.g., for the FreeBSD and NetBSD make:

  $ bsd-make -ki -I none -k -f- <<<'all:;@echo "$$MAKEFLAGS"'
    -k -i -I none -k

nor for Solaris CCS make (note that this doesn't even support thr
-I option, though):

  $ /usr/ccs/bin/make -ki -k -f - <<<'all:;@echo "$$MAKEFLAGS"' 
  -ik

> The complication is that we have to also support other makes (BSD,
> Solaris). I have no idea about their MAKEFLAGS behavior.
> 
I have only a patchy knowledge too, but combining that with some
experimenting might be enough to find a fix

> Boris
> 

Thanks,
  Stefano

-*-*-*-

Stefano Lattarini (2):
  tests: refactor/enhance tests about make dry-run mode
  coverage: expose automake bug#13760

 t/make-dryrun.tap | 123 ++++++++++++++++++++++++++++++++----------------------
 1 file changed, 72 insertions(+), 51 deletions(-)

-- 
1.8.1.1.754.gb3600c3





Information forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Wed, 20 Feb 2013 13:10:02 GMT) Full text and rfc822 format available.

Message #11 received at 13760 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: 13760 <at> debbugs.gnu.org
Cc: boris <at> codesynthesis.com, automake-patches <at> gnu.org
Subject: [PATCH 2/2] coverage: expose automake bug#13760
Date: Wed, 20 Feb 2013 14:07:53 +0100
* t/make-dryrun.tap: Here.
* THANKS: Update with the name of the bug reporter.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 t/make-dryrun.tap | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/t/make-dryrun.tap b/t/make-dryrun.tap
index 4aa7146..1459a9f 100755
--- a/t/make-dryrun.tap
+++ b/t/make-dryrun.tap
@@ -18,7 +18,7 @@
 
 . test-init.sh
 
-plan_ 14
+plan_ 18
 
 if echo "all: ; +@printf %sbb%s aa cc" | $MAKE -n -f - | grep aabbcc; then
   make_plus_silence () { return 0; }
@@ -26,6 +26,13 @@ else
   make_plus_silence () { return 1; }
 fi
 
+mkdir none
+if echo nil: | $MAKE -I none -f -; then
+  make_supports_option_I () { return 0; }
+else
+  make_supports_option_I () { return 1; }
+fi
+
 echo AC_OUTPUT >> configure.ac
 
 cat > Makefile.am <<'END'
@@ -100,6 +107,25 @@ check_make --dry -C using_gmake "\$MAKE is not GNU make" --dry-run -k
 
 # ----------------------------------------------------------------------
 
+# Automake bug#13760: the "n" in "none" used to confound am__make_dryrun
+# into thinking the '-n' option had been passed.
+
+pr='bug#13760'
+
+check_make --run -X -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" \
+                 -M "$pr" -I none --include dry-run 
+
+check_make --dry -C make_supports_option_I "-I make option unsupported" \
+                 -M "$pr" -I none -n
+
+check_make --dry -C using_gmake "\$MAKE is not GNU make" \
+                 -M "$pr" --dry-run -I none --include dry-run
+
+# ----------------------------------------------------------------------
+
 # Test for when shell metacharacters or backslashes are in $(MAKEFLAGS).
 
 check_metachars ()
-- 
1.8.1.1.754.gb3600c3





Information forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Wed, 20 Feb 2013 13:10:03 GMT) Full text and rfc822 format available.

Message #14 received at 13760 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: 13760 <at> debbugs.gnu.org
Cc: boris <at> codesynthesis.com, automake-patches <at> gnu.org
Subject: [PATCH 1/2] tests: refactor/enhance tests about make dry-run mode
Date: Wed, 20 Feb 2013 14:07:52 +0100
* t/make-dryrun.tap: Here.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 t/make-dryrun.tap | 99 ++++++++++++++++++++++++++-----------------------------
 1 file changed, 47 insertions(+), 52 deletions(-)

diff --git a/t/make-dryrun.tap b/t/make-dryrun.tap
index 14d379a..4aa7146 100755
--- a/t/make-dryrun.tap
+++ b/t/make-dryrun.tap
@@ -20,14 +20,12 @@
 
 plan_ 14
 
-if echo "all: ; @+printf %sbb%s aa cc" | $MAKE -n -f - | grep aabbcc; then
+if echo "all: ; +@printf %sbb%s aa cc" | $MAKE -n -f - | grep aabbcc; then
   make_plus_silence () { return 0; }
 else
   make_plus_silence () { return 1; }
 fi
 
-mkdir sub
-
 echo AC_OUTPUT >> configure.ac
 
 cat > Makefile.am <<'END'
@@ -35,14 +33,48 @@ all:
 	: Dummy, nothing to do.
 foo:
 	$(MAKE) all
-notdry:
+run:
 	@echo ":: $$MAKEFLAGS ::"; : For debugging.
-	$(am__make_dryrun) && exit 1; exit 0
+	$(am__make_dryrun) && exit 1; echo ok > from-run
 dry:
 	+@echo ":: $$MAKEFLAGS ::"; : For debugging.
-	+$(am__make_dryrun) || exit 1; echo ok > from-dry-mode
+	+$(am__make_dryrun) || exit 1; echo ok > from-dry
 END
 
+check_make ()
+{
+  r=ok msg= mode= condition=: directive= reason= skip_reason=
+  case $1 in
+    --dry) mode=dry;;
+    --run) mode=run;;
+    *) fatal_ "check_run: invalid usage";;
+  esac
+  shift
+  while test $# -gt 0; do
+    case $1 in
+      -C) condition=$2 skip_reason=$3; shift; shift;;
+      -M) msg=$2; shift;;
+      -X) directive=TODO;;
+      --) shift; break;;
+       *) break;;
+    esac
+    shift
+  done
+  msg=${mode}${msg:+" [$msg]"}
+  if $condition; then
+    $MAKE "$mode" ${1+"$@"} || r='not ok'
+    test -f from-$mode      || r='not ok'
+    test ! -e bad           || r='not ok'
+    rm -f bad from-*        || fatal_ "cleaning up"
+  else
+    directive=SKIP reason=$skip_reason
+  fi
+  result_ "$r" -D "$directive" -r "$reason" "$msg"
+  unset r msg mode condition directive reason skip_reason
+}
+
+# ----------------------------------------------------------------------
+
 $ACLOCAL    || fatal_ "aclocal failed"
 $AUTOCONF   || fatal_ "autoconf failed"
 $AUTOMAKE   || fatal_ "automake failed"
@@ -50,48 +82,21 @@ $AUTOMAKE   || fatal_ "automake failed"
 
 # ----------------------------------------------------------------------
 
-check_no_dryrun ()
-{
-  command_ok_ "dry-run ($cnt)" $MAKE notdry ${1+"$@"}
-  cnt=$(($cnt + 1))
-}
-cnt=1
-
-check_no_dryrun
+check_make --run
 
 # 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" AM_MAKEFLAGS="TESTS='n1 n2'"
-check_no_dryrun TESTS="n1 n2" AM_MAKEFLAGS='TESTS="n1 n2"'
-check_no_dryrun FOOFLAGS="-n -n -knf2 n --none -n"
-check_no_dryrun MYFLAGS="-n --dryrun -n --dry-run -n"
+check_make --run TESTS="n1.test n2.test"
+check_make --run TESTS="n1 n2" AM_MAKEFLAGS="TESTS='n1 n2'"
+check_make --run TESTS="n1 n2" AM_MAKEFLAGS='TESTS="n1 n2"'
+check_make --run FOOFLAGS="-n -n -knf2 n --none -n"
+check_make --run MYFLAGS="-n --dryrun -n --dry-run -n"
 
 # ----------------------------------------------------------------------
 
-check_dryrun ()
-{
-  r=ok directive=
-  case $1 in
-    -C) condition=$2 reason=$3; shift; shift; shift;;
-     *) condition=: reason=;;
-  esac
-  if $condition; then
-    $MAKE dry ${1+"$@"}   || r='not ok'
-    test -f from-dry-mode || r='not ok'
-    rm -f from-dry-mode   || fatal_ "cleaning up"
-  else
-    directive=SKIP
-  fi
-  result_ "$r" -D "$directive" -r "$reason" "not dry-run ($cnt)"
-  unset r directive reason
-  cnt=$(($cnt + 1))
-}
-cnt=1
-
-check_dryrun -C make_plus_silence 'recipe prefix "+" unsupported' -n
-check_dryrun -C using_gmake "\$MAKE is not GNU make" --dry-run -k
+check_make --dry -C make_plus_silence 'recipe prefix "+" unsupported' -n
+check_make --dry -C using_gmake "\$MAKE is not GNU make" --dry-run -k
 
 # ----------------------------------------------------------------------
 
@@ -99,18 +104,8 @@ check_dryrun -C using_gmake "\$MAKE is not GNU make" --dry-run -k
 
 check_metachars ()
 {
-  r=ok
-  $MAKE notdry ${1+"$@"} || r='not ok'
-  if test -f bad; then
-    r='not ok'
-  else
-    rm -f bad || fatal_ "cleaning up"
-  fi
-  result_ "$r" "dry-run, with shell metachars ($cnt)"
-  unset r
-  cnt=$(($cnt + 1))
+  check_make --run -M "metachars" "$@"
 }
-cnt=1
 
 check_metachars MYFLAGS="-n \"n\" '-n' --none -n"
 check_metachars MYFLAGS='-knf2\ n\ \\n'
-- 
1.8.1.1.754.gb3600c3





Information forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Wed, 20 Feb 2013 13:18:01 GMT) Full text and rfc822 format available.

Message #17 received at 13760 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: 13760 <at> debbugs.gnu.org
Cc: boris <at> codesynthesis.com, automake-patches <at> gnu.org
Subject: Re: [PATCH 0/2] am__make_dryrun fails to handle GNU make -I option
Date: Wed, 20 Feb 2013 14:16:13 +0100
On 02/20/2013 02:07 PM, Stefano Lattarini wrote:
> Reference: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13760>
>
> [SNIP]
>
> I have only a patchy knowledge too, but combining that with some
> experimenting might be enough to find a fix
>
ESENTTOOEARLY, sorry.   Here is the complete paragraph I intended to
send:

    I too have only a patchy knowledge of them, but combining that with some
    experimenting might be enough to find a fix for this bug.  And of course,
    if you want to attempt a fix yourself in the meantime, be my guest ;-)

Sorry for the noise,
  Stefano




Information forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Wed, 20 Feb 2013 13:47:02 GMT) Full text and rfc822 format available.

Message #20 received at 13760 <at> debbugs.gnu.org (full text, mbox):

From: Boris Kolpackov <boris <at> codesynthesis.com>
To: 13760 <at> debbugs.gnu.org
Cc: Stefano Lattarini <stefano.lattarini <at> gmail.com>, automake-patches <at> gnu.org
Subject: Re: [PATCH 0/2] am__make_dryrun fails to handle GNU make -I option
Date: Wed, 20 Feb 2013 15:44:52 +0200
Stefano Lattarini <stefano.lattarini <at> gmail.com> writes:

> And of course, if you want to attempt a fix yourself in the meantime,
> be my guest ;-)

I was thinking of coming up with a fix. My problem is I can only do
it for GNU make; I don't know anything (and, to be honest, don't care)
about other flavors of make which the code has to support. I think
the clean way to fix this would be to detect somehow if we are using
GNU make and then have different tests for GNU make and other makes.
I looked around for any GNU make indication but didn't see anything
obvious (maybe the fact that in GNU make the first word can never have
'-'). I think if we try to support all make flavors in a combined test,
things will get messy (my other idea was to resort to executing make if
MAKEFLAGS contains more than one word). Seeing that the majority is
probably using GNU make and we can do a really fast test for it, it
would be bad to resort to some pessimistic tests (like running make)
just so that we can support other makes.

Just my thoughts.

Boris




Information forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Tue, 23 Apr 2013 09:19:02 GMT) Full text and rfc822 format available.

Message #23 received at 13760 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: boris <at> codesynthesis.com
Cc: 13760 <at> debbugs.gnu.org, automake-patches <at> gnu.org
Subject: [PATCH 0/3] dry-run: don't get confused by '-I' option
Date: Tue, 23 Apr 2013 11:12:45 +0200
Reference: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13760>

Hello, and sorry for the shameful delay.

Boris Kolpackov wrote:
>
> I think if we try to support all make flavors in a combined test,
> things will get messy (my other idea was to resort to executing make if
> MAKEFLAGS contains more than one word). Seeing that the majority is
> probably using GNU make and we can do a really fast test for it, it
> would be bad to resort to some pessimistic tests (like running make)
> just so that we can support other makes.
>
This sounds sensible.  I've taken this approach of using an "optimized"
test for GNU make, and the more messy tests (in a "best-effort" fashion)
for non-GNU makes.

So, this series should fix automake bug#13760.  Testing and comments are
welcome.  I will proceed to push in a few days if there is no objection.

Thanks,
  Stefano

-*-*-*-

Stefano Lattarini (3):
  header vars: can determine whether we are running under GNU make
  dry-run: with GNU make, prefer $(MFLAGS) over $(MAKEFLAGS)
  dry-run: don't get confused by '-I' option

 lib/am/header-vars.am | 57 +++++++++++++++++++++++++++++++-------------
 t/list-of-tests.mk    |  3 ++-
 t/make-dryrun.tap     |  4 ++--
 t/make-is-gnu.sh      | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 111 insertions(+), 19 deletions(-)
 create mode 100755 t/make-is-gnu.sh

-- 
1.8.2.1.389.gcaa7d79





Information forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Tue, 23 Apr 2013 09:19:02 GMT) Full text and rfc822 format available.

Message #26 received at 13760 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: boris <at> codesynthesis.com
Cc: 13760 <at> debbugs.gnu.org, automake-patches <at> gnu.org
Subject: [PATCH 1/3] header vars: can determine whether we are running under
	GNU make
Date: Tue, 23 Apr 2013 11:12:46 +0200
This is mostly a preparatory patch in view of future changes.

* lib/am/header-vars.am (am__is_gnu_make): New, contains shell code that
determines whether we are running under GNU make.
* t/make-is-gnu.sh: New test.
* t/list-of-tests.mk: Add it.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 lib/am/header-vars.am |  6 ++++-
 t/list-of-tests.mk    |  3 ++-
 t/make-is-gnu.sh      | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100755 t/make-is-gnu.sh

diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index 9fda37c..8295a99 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -26,12 +26,16 @@ VPATH = @srcdir@
 ## a vendor make.
 ## DESTDIR =
 
+## Shell code that determines whether we are running under GNU make.
+## This is somewhat of an hack, and might be improved, but is good
+## enough for now.
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+
 ## 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; \
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index f1e3dca..c72a636 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -664,8 +664,9 @@ t/makej.sh \
 t/makej2.sh \
 t/maken.sh \
 t/maken3.sh \
-t/make-dryrun.tap \
 t/makevars.sh \
+t/make-dryrun.tap \
+t/make-is-gnu.sh \
 t/man.sh \
 t/man2.sh \
 t/man3.sh \
diff --git a/t/make-is-gnu.sh b/t/make-is-gnu.sh
new file mode 100755
index 0000000..c37cc17
--- /dev/null
+++ b/t/make-is-gnu.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2013 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that $(am__is_gnu_make) can be used to correctly determine if
+# we are running under GNU make.
+
+. test-init.sh
+
+if using_gmake; then
+ as_expected () { test $1 -eq 0 && test -f ok && test ! -e ko; }
+else
+ as_expected () { test $1 -gt 0 && test -f ko && test ! -e ok; }
+fi
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+all: file
+	$(am__is_gnu_make)
+file:
+	if $(am__is_gnu_make); then : > ok; else : > ko; fi 
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+st=0; $MAKE || st=$?
+if using_gmake; then
+ test $st -eq 0
+ test -f ok
+ test ! -e ko
+else
+ test $st -gt 0
+ test -f ko
+ test ! -e ok
+fi
+
+rm -f ok ko
+
+$MAKE -s file >output 2>&1
+cat output
+if using_gmake; then
+ test -f ok
+ test ! -e ko
+else
+ test -f ko
+ test ! -e ok
+fi
+test ! -s output
+
+:
-- 
1.8.2.1.389.gcaa7d79





Information forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Tue, 23 Apr 2013 09:19:03 GMT) Full text and rfc822 format available.

Message #29 received at 13760 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: boris <at> codesynthesis.com
Cc: 13760 <at> debbugs.gnu.org, automake-patches <at> gnu.org
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 <stefano.lattarini <at> gmail.com>
---
 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





Information forwarded to bug-automake <at> gnu.org:
bug#13760; Package automake. (Tue, 23 Apr 2013 09:19:03 GMT) Full text and rfc822 format available.

Message #32 received at 13760 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: boris <at> codesynthesis.com
Cc: 13760 <at> debbugs.gnu.org, automake-patches <at> gnu.org
Subject: [PATCH 3/3] dry-run: don't get confused by '-I' option
Date: Tue, 23 Apr 2013 11:12:48 +0200
Fixes automake bug#13760 for non-GNU make implementations that still
support the option '-I'.  So far, the only such make implementation
are FreeBSD (8.x) make and NetBSD (5.x) make.

* lib/am/header-vars.am (am__make_dryrun): If a non-GNU make is being
used, try to handle the '-I' option in $MAKEFLAGS correctly.  For GNU
make, that is already done by the proper use of the $MFLAGS variable.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 lib/am/header-vars.am | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/am/header-vars.am b/lib/am/header-vars.am
index 23c627e..d2f0984 100644
--- a/lib/am/header-vars.am
+++ b/lib/am/header-vars.am
@@ -61,9 +61,17 @@ am__make_dryrun = \
            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 ;;\
-- 
1.8.2.1.389.gcaa7d79





Added tag(s) patch. Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Apr 2013 09:19:04 GMT) Full text and rfc822 format available.

Reply sent to Stefano Lattarini <stefano.lattarini <at> gmail.com>:
You have taken responsibility. (Fri, 26 Apr 2013 18:26:02 GMT) Full text and rfc822 format available.

Notification sent to Boris Kolpackov <boris <at> codesynthesis.com>:
bug acknowledged by developer. (Fri, 26 Apr 2013 18:26:03 GMT) Full text and rfc822 format available.

Message #39 received at 13760-done <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: boris <at> codesynthesis.com
Cc: 13760-done <at> debbugs.gnu.org, automake-patches <at> gnu.org
Subject: Re: [PATCH 0/3] dry-run: don't get confused by '-I' option
Date: Fri, 26 Apr 2013 20:25:06 +0200
tags 13760 + patch
stop

On 04/23/2013 11:12 AM, Stefano Lattarini wrote:
> Reference: <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13760>
> 
> Hello, and sorry for the shameful delay.
> 
> Boris Kolpackov wrote:
>>
>> I think if we try to support all make flavors in a combined test,
>> things will get messy (my other idea was to resort to executing make if
>> MAKEFLAGS contains more than one word). Seeing that the majority is
>> probably using GNU make and we can do a really fast test for it, it
>> would be bad to resort to some pessimistic tests (like running make)
>> just so that we can support other makes.
>>
> This sounds sensible.  I've taken this approach of using an "optimized"
> test for GNU make, and the more messy tests (in a "best-effort" fashion)
> for non-GNU makes.
> 
> So, this series should fix automake bug#13760.  Testing and comments are
> welcome.  I will proceed to push in a few days if there is no objection.
> 
Pushed now.  I'm thus closing this bug report.

Thanks,
  Stefano




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 25 May 2013 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 27 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.