Implement conditional AC_CONFIG_FILES: AM_COND_IF.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Wed, 26 Mar 2008 06:00:44 +0000 (07:00 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Wed, 26 Mar 2008 06:24:59 +0000 (07:24 +0100)
* automake.in (%ac_config_files_condition): New.
(scan_autoconf_config_files): Record condition if any.
(scan_autoconf_traces): Trace _AM_COND_IF, _AM_COND_ELSE,
_AM_COND_ENDIF, updating @cond_stack as appropriate.
(handle_configure): Prefix config.status rule with condition.
Check that m4 quotation is done consistently.
* m4/cond.m4 (AM_CONDITION): Define `_AM_COND_VALUE_name'
with `name' being the name of the condition, to its shell
condition.
* m4/cond-if.m4: New file.
(_AM_COND_IF, _AM_COND_ELSE, _AM_COND_ENDIF): New trace helpers.
(AM_COND_IF): New macro, implements conditionals.
* m4/Makefile.am: Adjust.
* doc/automake.texi (Requirements, Optional, Conditionals):
Document AM_COND_IF.
* NEWS: Update.
* tests/cond39.test, tests/cond40.test, tests/cond41.test,
tests/cond42.test, tests/cond43.test: New tests.
* tests/Makefile.am: Adjust.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
15 files changed:
ChangeLog
NEWS
automake.in
doc/automake.texi
m4/Makefile.am
m4/Makefile.in
m4/cond-if.m4 [new file with mode: 0644]
m4/cond.m4
tests/Makefile.am
tests/Makefile.in
tests/cond39.test [new file with mode: 0755]
tests/cond40.test [new file with mode: 0755]
tests/cond41.test [new file with mode: 0755]
tests/cond42.test [new file with mode: 0755]
tests/cond43.test [new file with mode: 0755]

index c054c5d..4ba504d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2008-03-26  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Implement conditional AC_CONFIG_FILES: AM_COND_IF.
+       * automake.in (%ac_config_files_condition): New.
+       (scan_autoconf_config_files): Record condition if any.
+       (scan_autoconf_traces): Trace _AM_COND_IF, _AM_COND_ELSE,
+       _AM_COND_ENDIF, updating @cond_stack as appropriate.
+       (handle_configure): Prefix config.status rule with condition.
+       Check that m4 quotation is done consistently.
+       * m4/cond.m4 (AM_CONDITION): Define `_AM_COND_VALUE_name'
+       with `name' being the name of the condition, to its shell
+       condition.
+       * m4/cond-if.m4: New file.
+       (_AM_COND_IF, _AM_COND_ELSE, _AM_COND_ENDIF): New trace helpers.
+       (AM_COND_IF): New macro, implements conditionals.
+       * m4/Makefile.am: Adjust.
+       * doc/automake.texi (Requirements, Optional, Conditionals):
+       Document AM_COND_IF.
+       * NEWS: Update.
+       * tests/cond39.test, tests/cond40.test, tests/cond41.test,
+       tests/cond42.test, tests/cond43.test: New tests.
+       * tests/Makefile.am: Adjust.
+
 2008-03-24  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * doc/automake.texi (@ovar): New macro, from autoconf.texi.
diff --git a/NEWS b/NEWS
index 39ae49a..72081f1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -60,6 +60,9 @@ New in 1.10a:
   - New prefix `notrans_' for manpages which should not be transformed
     by --program-transform.
 
+  - New macro AM_COND_IF for conditional evaluation and conditional
+    config files.
+
 Bugs fixed in 1.10a:
 
 * Long standing bugs:
index 3d679fb..68647e9 100755 (executable)
@@ -326,6 +326,8 @@ my @other_input_files = ();
 # Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADER appears.
 # The keys are the files created by these macros.
 my %ac_config_files_location = ();
+# The condition under which AC_CONFIG_FOOS appears.
+my %ac_config_files_condition = ();
 
 # Directory to search for configure-required files.  This
 # will be computed by &locate_aux_dir and can be set using
@@ -4196,10 +4198,13 @@ sub handle_configure ($$$@)
       # Cannot output rules for shell variables.
       next if (substitute_ac_subst_variables $local) =~ /\$/;
 
-      $output_rules .= ($local . ': '
+      my $condstr = '';
+      $condstr = $ac_config_files_condition{$lfile}->subst_string
+        if ($ac_config_files_condition{$lfile});
+      $output_rules .= ($condstr . $local . ': '
                        . '$(top_builddir)/config.status '
                        . "@rewritten_inputs\n"
-                       . "\t"
+                       . $condstr . "\t"
                        . 'cd $(top_builddir) && '
                        . '$(SHELL) ./config.status '
                        . ($relative_dir eq '.' ? '' : '$(subdir)/')
@@ -4844,6 +4849,9 @@ sub scan_autoconf_config_files ($$)
          push (@other_input_files, $_);
        }
       $ac_config_files_location{$local} = $where;
+      $ac_config_files_condition{$local} =
+        new Automake::Condition (@cond_stack)
+          if (@cond_stack);
     }
 }
 
@@ -4881,6 +4889,9 @@ sub scan_autoconf_traces ($)
                AM_MAINTAINER_MODE => 0,
                AM_PROG_CC_C_O => 0,
                _AM_SUBST_NOTMAKE => 1,
+               _AM_COND_IF => 1,
+               _AM_COND_ELSE => 1,
+               _AM_COND_ENDIF => 1,
                LT_SUPPORTED_TAG => 1,
                _LT_AC_TAGCONFIG => 0,
                m4_include => 1,
@@ -4893,17 +4904,20 @@ sub scan_autoconf_traces ($)
   # Use a separator unlikely to be used, not `:', the default, which
   # has a precise meaning for AC_CONFIG_FILES and so on.
   $traces .= join (' ',
-                  map { "--trace=$_" . ':\$f:\$l::\$n::\${::}%' }
+                  map { "--trace=$_" . ':\$f:\$l::\$d::\$n::\${::}%' }
                   (keys %traced));
 
   my $tracefh = new Automake::XFile ("$traces $filename |");
   verb "reading $traces";
 
+  @cond_stack = ();
+  my $where;
+
   while ($_ = $tracefh->getline)
     {
       chomp;
-      my ($here, @args) = split (/::/);
-      my $where = new Automake::Location $here;
+      my ($here, $depth, @args) = split (/::/);
+      $where = new Automake::Location $here;
       my $macro = $args[0];
 
       prog_error ("unrequested trace `$macro'")
@@ -5067,6 +5081,24 @@ sub scan_autoconf_traces ($)
        {
          $seen_cc_c_o = $where;
        }
+      elsif ($macro eq '_AM_COND_IF')
+        {
+         cond_stack_if ('', $args[1], $where);
+         error ($where, "missing m4 quoting, macro depth $depth")
+           if ($depth != 1);
+       }
+      elsif ($macro eq '_AM_COND_ELSE')
+        {
+         cond_stack_else ('!', $args[1], $where);
+         error ($where, "missing m4 quoting, macro depth $depth")
+           if ($depth != 1);
+       }
+      elsif ($macro eq '_AM_COND_ENDIF')
+        {
+         cond_stack_endif (undef, undef, $where);
+         error ($where, "missing m4 quoting, macro depth $depth")
+           if ($depth != 1);
+       }
       elsif ($macro eq '_AM_SUBST_NOTMAKE')
        {
          $ignored_configure_vars{$args[1]} = $where;
@@ -5112,6 +5144,9 @@ sub scan_autoconf_traces ($)
        }
     }
 
+  error ($where, "condition stack not properly closed")
+    if (@cond_stack);
+
   $tracefh->close;
 }
 
index c326c89..baf5c77 100644 (file)
@@ -2662,6 +2662,10 @@ to check whether @file{Makefile.am} exists.  (In the very hairy case
 that your setup requires such use of variables, you will have to tell
 Automake which @file{Makefile.in}s to generate on the command-line.)
 
+It is possible to let @command{automake} emit conditional rules for
+@code{AC_CONFIG_FILES} with the help of @code{AM_COND_IF}
+(@pxref{Optional}).
+
 To summarize:
 @itemize @bullet
 @item
@@ -2839,6 +2843,15 @@ you can use these variables in any @file{Makefile.am} if
 This is required when using the obsolete de-ANSI-fication feature; see
 @ref{ANSI}.
 
+@item AM_CONDITIONAL
+This introduces an Automake conditional (@pxref{Conditionals}).
+
+@item AM_COND_IF
+This macro allows @code{automake} to detect subsequent access within
+@file{configure.ac} to a conditional previously introduced with
+@code{AM_CONDITIONAL}, thus enabling conditional @code{AC_CONFIG_FILES}
+(@pxref{Conditionals}).
+
 @item AM_GNU_GETTEXT
 This macro is required for packages that use GNU gettext
 (@pxref{gettext}).  It is distributed with gettext.  If Automake sees
@@ -8941,6 +8954,32 @@ The @code{else} branch of the above two examples could be omitted,
 since assigning the empty string to an otherwise undefined variable
 makes no difference.
 
+@acindex AM_COND_IF
+In order to allow access to the condition registered by
+@code{AM_CONDITIONAL} inside @file{configure.ac}, and to allow
+conditional @code{AC_CONFIG_FILES}, @code{AM_COND_IF} may be used:
+
+@defmac AM_COND_IF (@var{conditional}, @ovar{if-true}, @ovar{if-false})
+If @var{conditional} is fulfilled, execute @var{if-true}, otherwise
+execute @var{if-false}.  If either branch contains @code{AC_CONFIG_FILES},
+it will cause @command{automake} to output the rules for the respective
+files only for the given condition.
+@end defmac
+
+@code{AM_COND_IF} macros may be nested when m4 quotation is used
+properly (@pxref{M4 Quotation, ,, autoconf, The Autoconf Manual}).
+
+@cindex Example conditional @code{AC_CONFIG_FILES}
+@cindex @code{AC_CONFIG_FILES}, conditional
+
+Here is an example of how to define a conditional config file:
+
+@example
+AM_CONDITIONAL([SHELL_WRAPPER], [test "x$with_wrapper" = xtrue])
+AM_COND_IF([SHELL_WRAPPER],
+          [AC_CONFIG_FILES([wrapper:wrapper.in])])
+@end example
+
 @unnumberedsec Portability
 
 Note that conditionals in Automake are not the same as conditionals in
index 8d09e4d..9f5e1c2 100644 (file)
@@ -2,8 +2,8 @@
 
 ## Makefile for Automake m4.
 
-## Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2006
-## Free Software Foundation, Inc.
+## Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2006,
+## 2008 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
@@ -26,6 +26,7 @@ as.m4 \
 auxdir.m4 \
 ccstdc.m4 \
 cond.m4 \
+cond-if.m4 \
 depend.m4 \
 depout.m4 \
 dmalloc.m4 \
index 762a891..3a8fbcd 100644 (file)
@@ -159,6 +159,7 @@ as.m4 \
 auxdir.m4 \
 ccstdc.m4 \
 cond.m4 \
+cond-if.m4 \
 depend.m4 \
 depout.m4 \
 dmalloc.m4 \
diff --git a/m4/cond-if.m4 b/m4/cond-if.m4
new file mode 100644 (file)
index 0000000..9f2611e
--- /dev/null
@@ -0,0 +1,39 @@
+# AM_COND_IF                                            -*- Autoconf -*-
+
+# Copyright (C) 2008 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 1
+
+# _AM_COND_IF
+# _AM_COND_ELSE
+# _AM_COND_ENDIF
+# --------------
+# These macros are only used for tracing.
+m4_define([_AM_COND_IF])
+m4_define([_AM_COND_ELSE])
+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).
+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
+  m4_default([$2], [:])
+m4_ifval([$3],
+[_AM_COND_ELSE([$1])dnl
+else
+  $3
+])dnl
+_AM_COND_ENDIF([$1])dnl
+fi[]dnl
+])
index d9a58d2..fd248b2 100644 (file)
@@ -1,13 +1,13 @@
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 8
+# serial 9
 
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
@@ -20,6 +20,7 @@ AC_SUBST([$1_TRUE])dnl
 AC_SUBST([$1_FALSE])dnl
 _AM_SUBST_NOTMAKE([$1_TRUE])dnl
 _AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
 if $2; then
   $1_TRUE=
   $1_FALSE='#'
index 1221672..00f1785 100644 (file)
@@ -157,6 +157,11 @@ cond35.test \
 cond36.test \
 cond37.test \
 cond38.test \
+cond39.test \
+cond40.test \
+cond41.test \
+cond42.test \
+cond43.test \
 condd.test \
 condhook.test \
 condinc.test \
index 15951f2..de5d003 100644 (file)
@@ -307,6 +307,11 @@ cond35.test \
 cond36.test \
 cond37.test \
 cond38.test \
+cond39.test \
+cond40.test \
+cond41.test \
+cond42.test \
+cond43.test \
 condd.test \
 condhook.test \
 condinc.test \
diff --git a/tests/cond39.test b/tests/cond39.test
new file mode 100755 (executable)
index 0000000..93f0363
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/sh
+# Copyright (C) 2008  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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 3, or (at your option)
+# any later version.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Build either as CONFIG_FILE or as PROGRAM.
+
+. ./defs
+set -e
+
+cat >>configure.in <<'END'
+AC_PROG_CC
+AM_CONDITIONAL([COND], [test "$COND" = true])
+AM_COND_IF([COND], [],
+          [AC_CONFIG_FILES([prog], [chmod 755 prog])])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+if COND
+bin_PROGRAMS = prog
+prog_SOURCES = prog.c
+else
+# FIXME: the next line is still needed to get automake to output the
+# bin_PROGRAMS above in the right condition only.
+prog:
+bin_SCRIPTS = prog
+CLEANFILES = prog
+endif
+END
+
+cat >prog.c <<'END'
+int main () { return 42; }
+END
+
+cat >prog.in <<'END'
+#! /bin/sh
+bindir='@bindir@'
+echo "hi, this is $0, and bindir is $bindir"
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure COND=true
+$MAKE 2>stderr
+cat stderr
+grep 'overriding commands' stderr && exit 1
+./prog && exit 1
+$MAKE clean
+$MAKE
+./prog && exit 1
+$MAKE distclean
+
+./configure COND=false
+$MAKE 2>stderr
+cat stderr
+grep 'overriding commands' stderr && exit 1
+./prog
+$MAKE clean
+$MAKE
+./prog
diff --git a/tests/cond40.test b/tests/cond40.test
new file mode 100755 (executable)
index 0000000..d567a68
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/sh
+# Copyright (C) 2008  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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 3, or (at your option)
+# any later version.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test AM_COND_IF.
+
+. ./defs
+set -e
+
+cat >>configure.in <<'END'
+AC_DEFUN([FOO],
+        [AC_CONFIG_FILES([$1])])
+
+AM_CONDITIONAL([COND], [test "$cond" = yes])
+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])
+
+AM_COND_IF([COND1],
+          [AM_COND_IF([COND2], [FOO([file2])],
+                      [AM_COND_IF([COND3],
+                                  [FOO([file3])])])])
+
+AC_OUTPUT
+END
+
+: >Makefile.am
+: >file1.in
+: >file2.in
+: >file3.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure cond=yes cond1=yes cond2=no cond3=yes
+test -f file1
+test ! -f file2
+test -f file3
+rm -f file1 file3
+$MAKE file1 file3
+$MAKE file2 && exit 1
+test -f file1
+test ! -f file2
+test -f file3
+$MAKE distclean
+
+./configure cond=no cond1=yes cond2=yes
+test ! -f file1
+test -f file2
+test ! -f file3
+rm -f file2
+$MAKE file1 && exit 1
+$MAKE file2
+$MAKE file3 && exit 1
+test ! -f file1
+test -f file2
+test ! -f file3
+:
diff --git a/tests/cond41.test b/tests/cond41.test
new file mode 100755 (executable)
index 0000000..281e484
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Copyright (C) 2008  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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 3, or (at your option)
+# any later version.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# AM_COND_IF with an undefined condition should fail.
+
+. ./defs
+set -e
+
+cat >>configure.in <<'END'
+AM_COND_IF([COND],
+          [AC_CONFIG_FILES([file1])])
+AC_OUTPUT
+END
+
+$ACLOCAL && exit 1
+:
diff --git a/tests/cond42.test b/tests/cond42.test
new file mode 100755 (executable)
index 0000000..4b9e604
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Copyright (C) 2008  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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 3, or (at your option)
+# any later version.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Ensure an error with inconsistent state of conditionals in configure.ac.
+# This shouldn't happen with user input, as _AM_COND_* are not documented,
+# but better to be safe.
+
+. ./defs
+set -e
+
+cat >>configure.in <<'END'
+AM_CONDITIONAL([COND], [:])
+# next line needed so that cond-if.m4 is pulled in.
+AM_COND_IF([COND])
+_AM_COND_IF([COND])
+AC_OUTPUT
+END
+: >Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'condition stack' stderr
+
+sed 's/_AM_COND_IF/_AM_COND_ELSE/' < configure.in >configure.int
+mv -f configure.int configure.in
+rm -rf autom4te*.cache
+AUTOMAKE_fails
+grep 'else without if' stderr
+
+sed 's/_AM_COND_ELSE/_AM_COND_ENDIF/' < configure.in >configure.int
+mv -f configure.int configure.in
+rm -rf autom4te*.cache
+AUTOMAKE_fails
+grep 'endif without if' stderr
+
+sed 's/\(_AM_COND_ENDIF\).*/_AM_COND_IF\
+_AM_COND_ENDIF/' < configure.in >configure.int
+mv -f configure.int configure.in
+rm -rf autom4te*.cache
+AUTOMAKE_fails
+test 2 = `grep -c 'not enough arguments' stderr`
+:
diff --git a/tests/cond43.test b/tests/cond43.test
new file mode 100755 (executable)
index 0000000..d1a863d
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Copyright (C) 2008  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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 3, or (at your option)
+# any later version.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Ensure an error with underquoted usage of AM_COND_IF in configure.ac.
+
+. ./defs
+set -e
+
+cat >>configure.in <<'END'
+AM_CONDITIONAL([COND1], [:])
+AM_CONDITIONAL([COND2], [:])
+AM_COND_IF([COND1],
+          AM_COND_IF([COND2], [:])
+)
+AC_OUTPUT
+END
+: >Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+
+sed '/.AM_COND_IF/{
+       s/^/[/
+       s/$/]/
+     }' < configure.in > configure.int
+mv -f configure.int configure.in
+rm -rf autom4te*.cache
+$AUTOMAKE