From 32f8982b318c36d9f25baaf6751d81f1d0c351d7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 4 Aug 2001 04:02:40 +0000 Subject: [PATCH] 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. (SUBST_REF_PATTERN): New global. * tests/cond16.test: New file: regression test for variable substitution refs. * test/Makefile.am (TESTS): Added cond16.test. --- ChangeLog | 11 +++++++++++ automake.in | 14 ++++++++++++-- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/cond16.test | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100755 tests/cond16.test diff --git a/ChangeLog b/ChangeLog index ef972401..20a78aa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +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. + (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 * tests/substref.test: Require GNU make; backed out previous diff --git a/automake.in b/automake.in index cecb270f..ab50ebd6 100755 --- a/automake.in +++ b/automake.in @@ -164,6 +164,10 @@ my $INCLUDE_PATTERN = ('^include\s+' 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+)'; @@ -5909,11 +5913,17 @@ sub variable_conditions_sub # 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)); @@ -6102,7 +6112,7 @@ sub value_to_list my ($from, $to); my @temp_list; - if ($varname =~ /^([^:]*):([^=]*)=(.*)$/) + if ($varname =~ /$SUBST_REF_PATTERN/o) { $varname = $1; $to = $3; diff --git a/tests/Makefile.am b/tests/Makefile.am index 7932b2ce..3fcf63a9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -67,6 +67,7 @@ cond10.test \ cond11.test \ cond12.test \ cond13.test \ +cond16.test \ condincl.test \ condincl2.test \ condlib.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 542e78e8..3cc48ad6 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -135,6 +135,7 @@ cond10.test \ cond11.test \ cond12.test \ cond13.test \ +cond16.test \ condincl.test \ condincl2.test \ condlib.test \ diff --git a/tests/cond16.test b/tests/cond16.test new file mode 100755 index 00000000..407185d9 --- /dev/null +++ b/tests/cond16.test @@ -0,0 +1,49 @@ +#! /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" -- 2.43.5