automake-patches
[Top][All Lists]
Advanced

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

Fix AM_COND_IF for gone-invalid condition shell expression.


From: Ralf Wildenhues
Subject: Fix AM_COND_IF for gone-invalid condition shell expression.
Date: Tue, 27 Jul 2010 21:38:15 +0200
User-agent: Mutt/1.5.20 (2010-04-22)

Fixing this kind of nasty (silent wrong-code) bug, for maint.
Hope AM_COND_IF hasn't seen a lot of uses this way yet.

Cheers,
Ralf

    Fix AM_COND_IF for gone-invalid condition shell expression.
    
    * m4/cond-if.m4 (AM_COND_IF): test contents of $COND_TRUE
    variable, rather than re-evaluating the shell expression for
    the condition.
    * tests/cond40.test: Extend test.
    * NEWS: Update.

diff --git a/NEWS b/NEWS
index b8a0f08..b3d4131 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,9 @@ Bugs fixed in 1.11.0a:
 
   - The `dist-xz' option now uses `xz -9' for maximum compression.
 
+  - The AM_COND_IF macro also works if the shell expression for the conditional
+    is no longer valid for the condition.
+
 * Long standing bugs:
 
   - On Darwin 9, `pythondir' and `pyexecdir' pointed below `/Library/Python'
diff --git a/m4/cond-if.m4 b/m4/cond-if.m4
index 2500422..3a25e32 100644
--- a/m4/cond-if.m4
+++ b/m4/cond-if.m4
@@ -6,7 +6,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 2
+# serial 3
 
 # _AM_COND_IF
 # _AM_COND_ELSE
@@ -20,14 +20,14 @@ m4_define([_AM_COND_ENDIF])
 
 # AM_COND_IF(COND, [IF-TRUE], [IF-FALSE])
 # ---------------------------------------
-# If the shell condition matching COND is true, execute IF-TRUE,
-# otherwise execute IF-FALSE.  Allow automake to learn about conditional
-# instantiating macros (the AC_CONFIG_FOOS).
+# If the shell condition COND is true, execute IF-TRUE, otherwise execute
+# IF-FALSE.  Allow automake to learn about conditional instantiating macros
+# (the AC_CONFIG_FOOS).
 AC_DEFUN([AM_COND_IF],
 [m4_ifndef([_AM_COND_VALUE_$1],
           [m4_fatal([$0: no such condition "$1"])])dnl
 _AM_COND_IF([$1])dnl
-if _AM_COND_VALUE_$1; then :
+if test -z "$$1_TRUE"; then :
   m4_n([$2])[]dnl
 m4_ifval([$3],
 [_AM_COND_ELSE([$1])dnl
diff --git a/tests/cond40.test b/tests/cond40.test
index d30f0ab..c0bde5c 100755
--- a/tests/cond40.test
+++ b/tests/cond40.test
@@ -35,9 +35,14 @@ AM_COND_IF([COND],
 AM_COND_IF([COND],
           [AC_CONFIG_FILES([file1])])
 
-AM_CONDITIONAL([COND1], [test "$cond1" = yes])
-AM_CONDITIONAL([COND2], [test "$cond2" = yes])
-AM_CONDITIONAL([COND3], [test "$cond3" = yes])
+# Things should work even at a time when the shell expressions
+# for the conditional are not valid any more.
+ok=$cond1
+AM_CONDITIONAL([COND1], [test "$ok" = yes])
+ok=$cond2
+AM_CONDITIONAL([COND2], [test "$ok" = yes])
+ok=$cond3
+AM_CONDITIONAL([COND3], [test "$ok" = yes])
 
 AM_COND_IF([COND1],
           [AM_COND_IF([COND2], [FOO([file2])],



reply via email to

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