]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Fix AM_COND_IF for gone-invalid condition shell expression.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 27 Jul 2010 19:35:19 +0000 (21:35 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 27 Jul 2010 19:35:19 +0000 (21:35 +0200)
* 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.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
NEWS
m4/cond-if.m4
tests/cond40.test

index 231230120effb7d56ba2bef815f9b91a955978a8..cf332c98006ece368a68fa075c4393f7c1031655 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-07-27  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       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.
+
        Avoid syntax error if IF-TRUE part of AM_COND_IF expands empty.
        * m4/cond-if.m4 (AM_COND_IF): Ensure IF-TRUE part is never empty
        to avoid shell syntax error if the m4 expansion is empty.
diff --git a/NEWS b/NEWS
index b8a0f08c8deaa35cdc4b6ccf68607cd0221bc3f1..b3d41313df819886085a6a079e42d7c59823bce8 100644 (file)
--- 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'
index 250042247f22015b14c9d941289890dcdb0e441d..3a25e3206b61066b2dd30a0fd494ac70018da49f 100644 (file)
@@ -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
index d30f0abf9090414d7fdc63fb8e31975452cc3b50..c0bde5c42c56a596691da9d6ad27e267c54f06cd 100755 (executable)
@@ -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])],