diff -u -r automake_patch1/ChangeLog automake_patch2/ChangeLog --- automake_patch1/ChangeLog Thu Aug 2 01:16:58 2001 +++ automake_patch2/ChangeLog Thu Aug 2 01:39:14 2001 @@ -1,3 +1,13 @@ +2001-08-02 Richard Boulton + + * 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. + + * tests/cond16.test: New file: regression test for variable + substitution refs. + 2001-08-01 Richard Boulton * automake.in (file_contents_internal): if a rule is conditionally diff -u -r automake_patch1/automake.in automake_patch2/automake.in --- automake_patch1/automake.in Thu Aug 2 01:16:58 2001 +++ automake_patch2/automake.in Thu Aug 2 01:08:28 2001 @@ -5909,11 +5909,16 @@ # Handle variable substitutions. if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/) { + my $varname = $1; + if ($varname =~ /^([^:]*):([^=]*)=(.*)$/) + { + $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)); diff -u -r automake_patch1/tests/Makefile.am automake_patch2/tests/Makefile.am --- automake_patch1/tests/Makefile.am Thu Aug 2 01:16:58 2001 +++ automake_patch2/tests/Makefile.am Thu Aug 2 01:42:44 2001 @@ -69,6 +69,7 @@ cond13.test \ cond14.test \ cond15.test \ +cond16.test \ condincl.test \ condincl2.test \ condlib.test \ diff -u -r automake_patch1/tests/Makefile.in automake_patch2/tests/Makefile.in --- automake_patch1/tests/Makefile.in Thu Aug 2 01:16:58 2001 +++ automake_patch2/tests/Makefile.in Thu Aug 2 01:42:51 2001 @@ -137,6 +137,7 @@ cond13.test \ cond14.test \ cond15.test \ +cond16.test \ condincl.test \ condincl2.test \ condlib.test \ diff -u -r automake_patch1/tests/cond16.test automake_patch2/tests/cond16.test --- automake_patch1/tests/cond16.test Thu Jan 1 01:00:00 1970 +++ automake_patch2/tests/cond16.test Thu Aug 2 01:06:20 2001 @@ -0,0 +1,48 @@ +#! /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 + +set -e + +$ACLOCAL +$AUTOCONF +$AUTOMAKE -a + +CC='gcc' ./configure + +val=`$MAKE echorule`; +echo $val +test "x$val" = "xfoo.c foo.o"