From: Ralf Wildenhues Date: Tue, 27 Jul 2010 19:35:19 +0000 (+0200) Subject: Fix AM_COND_IF for gone-invalid condition shell expression. X-Git-Tag: v1.11.1b~67^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f6e3288fe16b140d86014f2395c510984786c52;p=thirdparty%2Fautomake.git 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. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index 231230120..cf332c980 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2010-07-27 Ralf Wildenhues + 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 b8a0f08c8..b3d41313d 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 250042247..3a25e3206 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 d30f0abf9..c0bde5c42 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])],