[PATCH] Don't let an envvar setting of "$fail" cause build failure.

View: New views
2 Messages — Rating Filter:   Alert me  

[PATCH] Don't let an envvar setting of "$fail" cause build failure.

by Jim Meyering :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Ralf,

While fixing similar problems in coreutils' test suite, I found
that with an automake-generated Makefile, "make" always fails
when I set e.g, fail=1 in the environment.

This fix works for me in that now, with regenerated Makefile.in files,
coreutils' "make check fail=1" now passes.

From ffcd00af02f97d8990ee0f45ab82706803f10578 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@...>
Date: Fri, 30 Oct 2009 12:02:22 +0100
Subject: [PATCH] Don't let an envvar setting of "$fail" cause build failure.

Without this change, in a project using an automake-generated
Makefile, "make fail=anything" would fail inappropriately,
due to the `test -z "$$fail"' at the end of this emitted rule:
* lib/am/subdirs.am ($(RECURSIVE_TARGETS)): Initialize "fail=" to keep
an envvar setting of that variable from causing unwarranted failure.
($(RECURSIVE_CLEAN_TARGETS)): Likewise.
---
 ChangeLog         |   10 ++++++++++
 lib/am/subdirs.am |    4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2fe0566..90af382 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-10-30  Jim Meyering  <meyering@...>
+
+ Don't let an envvar setting of "$fail" cause build failure.
+ Without this change, in a project using an automake-generated
+ Makefile, "make fail=anything" would fail inappropriately,
+ due to the `test -z "$$fail"' at the end of this emitted rule:
+ * lib/am/subdirs.am ($(RECURSIVE_TARGETS)): Initialize "fail=" to keep
+ an envvar setting of that variable from causing unwarranted failure.
+ ($(RECURSIVE_CLEAN_TARGETS)): Likewise.
+
 2009-10-18  Ralf Wildenhues  <Ralf.Wildenhues@...>

  Simplify Variable::_check_ambiguous_condition.
diff --git a/lib/am/subdirs.am b/lib/am/subdirs.am
index b86e674..9c01a8c 100644
--- a/lib/am/subdirs.am
+++ b/lib/am/subdirs.am
@@ -36,7 +36,7 @@ AM_RECURSIVE_TARGETS += $(RECURSIVE_TARGETS:-recursive=) \
 $(RECURSIVE_TARGETS):
 ## Using $failcom allows "-k" to keep its natural meaning when running a
 ## recursive rule.
- @failcom='exit 1'; \
+ @fail= failcom='exit 1'; \
  for f in x $$MAKEFLAGS; do \
   case $$f in \
     *=* | --[!k]*);; \
@@ -75,7 +75,7 @@ maintainer-clean: maintainer-clean-recursive
 $(RECURSIVE_CLEAN_TARGETS):
 ## Using $failcom allows "-k" to keep its natural meaning when running a
 ## recursive rule.
- @failcom='exit 1'; \
+ @fail= failcom='exit 1'; \
  for f in x $$MAKEFLAGS; do \
   case $$f in \
     *=* | --[!k]*);; \
--
1.6.5.2.375.g164f1



Re: [PATCH] Don't let an envvar setting of "$fail" cause build failure.

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jim,

* Jim Meyering wrote on Fri, Oct 30, 2009 at 12:15:45PM CET:
> While fixing similar problems in coreutils' test suite, I found
> that with an automake-generated Makefile, "make" always fails
> when I set e.g, fail=1 in the environment.

Thanks for the report and patch.  I'm adding a tests and committing the
following to maint, intended for master and branch-1.11.

Cheers,
Ralf

2009-10-31  Jim Meyering  <meyering@...>
            Ralf Wildenhues  <Ralf.Wildenhues@...>

        Don't let an envvar setting of "$fail" cause build failure.
        Without this change, in a project using an automake-generated
        Makefile, "make fail=anything" would fail inappropriately,
        due to the `test -z "$$fail"' at the end of this emitted rule:
        * lib/am/subdirs.am ($(RECURSIVE_TARGETS)): Initialize "fail=" to keep
        an envvar setting of that variable from causing unwarranted failure.
        ($(RECURSIVE_CLEAN_TARGETS)): Likewise.
        * tests/subdir10.test: New test.
        * tests/Makefile.am: Update.

diff --git a/lib/am/subdirs.am b/lib/am/subdirs.am
index b86e674..9c01a8c 100644
--- a/lib/am/subdirs.am
+++ b/lib/am/subdirs.am
@@ -36,7 +36,7 @@ AM_RECURSIVE_TARGETS += $(RECURSIVE_TARGETS:-recursive=) \
 $(RECURSIVE_TARGETS):
 ## Using $failcom allows "-k" to keep its natural meaning when running a
 ## recursive rule.
- @failcom='exit 1'; \
+ @fail= failcom='exit 1'; \
  for f in x $$MAKEFLAGS; do \
   case $$f in \
     *=* | --[!k]*);; \
@@ -75,7 +75,7 @@ maintainer-clean: maintainer-clean-recursive
 $(RECURSIVE_CLEAN_TARGETS):
 ## Using $failcom allows "-k" to keep its natural meaning when running a
 ## recursive rule.
- @failcom='exit 1'; \
+ @fail= failcom='exit 1'; \
  for f in x $$MAKEFLAGS; do \
   case $$f in \
     *=* | --[!k]*);; \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 98829c9..2c2e89a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -617,6 +617,7 @@ subdir6.test \
 subdir7.test \
 subdir8.test \
 subdir9.test \
+subdir10.test \
 subdirbuiltsources.test \
 subcond.test \
 subcond2.test \
diff --git a/tests/subdir10.test b/tests/subdir10.test
new file mode 100755
index 0000000..c71216b
--- /dev/null
+++ b/tests/subdir10.test
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2009  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/>.
+
+# SUDBIRS with $fail set in the environment.
+
+. ./defs || Exit 1
+
+set -e
+
+mkdir sub
+
+cat >> configure.in <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+echo SUBDIRS = sub >Makefile.am
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+env fail=1 $MAKE all clean
+
+Exit 0