+2001-08-02 Richard Boulton <richard@tartarus.org>
+
+ * automake.in (variable_conditions_sub): Handle variable
+ substitution refs when computing conditions based on subvariable
+ conditions. Fixes substitution refs of system variables when sub
+ variable is conditional.
+ (SUBST_REF_PATTERN): New global.
+ * tests/cond16.test: New file: regression test for variable
+ substitution refs.
+ * test/Makefile.am (TESTS): Added cond16.test.
+
2001-08-03 Tom Tromey <tromey@redhat.com>
* tests/substref.test: Require GNU make; backed out previous
my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
+
+# This handles substitution references like ${foo:.a=.b}.
+my $SUBST_REF_PATTERN = "^([^:]*):([^=]*)=(.*)\$";
+
# Note that there is no AC_PATH_TOOL. But we don't really care.
my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
# Handle variable substitutions.
if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
{
+ my $varname = $1;
+ if ($varname =~ /$SUBST_REF_PATTERN/o)
+ {
+ $varname = $1;
+ }
+
# Here we compute all the conditions under which the
# subvariable is defined. Then we go through and add
# $VCOND to each.
- my @svc = &variable_conditions_sub ($1, $var);
+ my @svc = &variable_conditions_sub ($varname, $var);
foreach my $item (@svc)
{
my $val = conditional_string ($vcond, split (' ', $item));
my ($from, $to);
my @temp_list;
- if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
+ if ($varname =~ /$SUBST_REF_PATTERN/o)
{
$varname = $1;
$to = $3;
--- /dev/null
+#! /bin/sh
+
+# Test for bug in conditionals in SOURCES with variable substitution references.
+# Report from Richard Boulton
+
+. $srcdir/defs || exit 1
+
+cat > configure.in << 'END'
+AC_INIT(hello.c)
+AM_INIT_AUTOMAKE(hello,0.23)
+AC_PROG_CC
+AM_CONDITIONAL(COND1, true)
+AC_OUTPUT(Makefile)
+END
+
+cat > hello.c << 'END'
+END
+
+cat > Makefile.am << 'END'
+
+if COND1
+var = foo.c
+else
+var = foo.c
+endif
+
+bin_PROGRAMS = hell
+hell_SOURCES = $(var:=)
+
+echorule:
+ @echo $(hell_SOURCES) $(hell_OBJECTS)
+
+END
+
+$needs_autoconf
+(gcc -v) > /dev/null 2>&1 || exit 77
+$needs_gnu_make
+
+set -e
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+CC='gcc' ./configure
+
+val=`$MAKE --no-print-directory echorule`;
+echo $val
+test "x$val" = "xfoo.c foo.o"