From f656610bb6471a8cd4cf700f6d4542eb3f5eda2c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 25 Feb 2001 18:37:40 +0000 Subject: [PATCH] * automake.in (&initialize_per_input): %targets_conditionals is new. (&read_am_file): When slurping a rule, set the target related variable, and no variable related variable. (&file_contents): Likewise. * tests/vartar.test, tests/ctarget1.test: New. --- ChangeLog | 1 - TODO | 9 --------- automake.in | 29 +++++++++++++++-------------- tests/Makefile.am | 2 ++ tests/Makefile.in | 2 ++ tests/ctarget1.test | 28 ++++++++++++++++++++++++++++ tests/vartar.test | 24 ++++++++++++++++++++++++ 7 files changed, 71 insertions(+), 24 deletions(-) create mode 100755 tests/ctarget1.test create mode 100755 tests/vartar.test diff --git a/ChangeLog b/ChangeLog index c6baa6848..b0df21d9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,6 @@ (&file_contents): Likewise. * tests/vartar.test, tests/ctarget1.test: New. - 2001-02-25 Akim Demaille * automake.in (&variable_defined, &variable_value_as_list_worker): diff --git a/TODO b/TODO index fbf67c019..1fc173ed4 100644 --- a/TODO +++ b/TODO @@ -274,7 +274,6 @@ still be able to have a Makefile.am in each directory somehow; this might make editing conceptually easier. * finish up TAGS work -* `acinstall' * only remove libtool at top level? @@ -598,14 +597,6 @@ Then automake can use -MD -MH -MT 'foo.o foo.lo' -MF .deps/... ================================================================ -Things to do for autoconf: - -* patch autoreconf to run automake and aclocal. I've done this but it is - not really available. It can't be made available until automake - is officially released - -================================================================ - Libraries: * Should support standalone library along with subdir library in same diff --git a/automake.in b/automake.in index f99f8a418..5b9be4e3b 100755 --- a/automake.in +++ b/automake.in @@ -5469,7 +5469,7 @@ sub variable_defined ($$) return 1; } - &am_line_error ($var, "\`$var' is target; expected variable") + &am_line_error ($var, "\`$var' is a target; expected a variable") if defined $targets{$var}; return 0; @@ -5813,7 +5813,7 @@ sub variable_value_as_list_worker { if (defined $targets{$var}) { - &am_line_error ($var, "\`$var' is target; expected variable"); + &am_line_error ($var, "\`$var' is a target; expected a variable"); } else { @@ -6126,27 +6126,25 @@ sub read_am_file { # Found a rule. $was_rule = 1; - if (defined $contents{$1} + if (defined $targets{$1} && (@conditional_stack - ? ! defined $conditional{$1} - : defined $conditional{$1})) + ? ! defined $target_conditional{$1} + : defined $target_conditional{$1})) { &am_line_error ($1, "$1 defined both conditionally and unconditionally"); } # Value here doesn't matter; for targets we only note # existence. -# FIXME: I don't understand the next line at all, it seems dead wrong --akim - $contents{$1} = 1; $targets{$1} = 1; my $cond_string = join ('', @conditional_stack); if (@conditional_stack) { - if ($conditional{$1}) + if ($target_conditional{$1}) { &check_ambiguous_conditional ($1, $cond_string); } - ${$conditional{$1}}{$cond_string} = '1'; + ${$target_conditional{$1}}{$cond_string} = '1'; } $content_lines{$1} = $.; $output_trailer .= $comment . $spacing . $cond_string . $_; @@ -6497,10 +6495,6 @@ sub initialize_per_input # read_am_file. %contents = (); - # This holds the names which are targets. These also appear in - # %contents. - %targets = (); - # This maps a variable name onto a flag. The flag is true iff the # variable was first defined with `+='. %var_was_plus_eq = (); @@ -6526,6 +6520,13 @@ sub initialize_per_input # This holds a 1 if a particular variable was examined. %content_seen = (); + # This holds the names which are targets. These also appear in + # %contents. + %targets = (); + + # Same as %CONDITIONAL, but for targets. + %target_conditional = (); + # This is the conditional stack. @conditional_stack = (); @@ -6840,7 +6841,7 @@ sub file_contents { # Free lance dependency. Output the rule for all the # targets instead of one by one. - if (!defined $contents{$targets}) + if (!defined $targets{$targets}) { # Some hair to avoid spurious trailing blank # when there are no dependencies. diff --git a/tests/Makefile.am b/tests/Makefile.am index b688a6f74..090952086 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -74,6 +74,7 @@ confsub.test \ confvar.test \ confvar2.test \ copy.test \ +ctarget1.test \ cxxansi.test \ cxxcpp.test \ cxxlibobj.test \ @@ -262,6 +263,7 @@ texinfo7.test \ texinfo8.test \ texinfo9.test \ unused.test \ +vartar.test \ version.test \ version2.test \ version3.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 8606cf0f1..cf0a25b12 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -151,6 +151,7 @@ confsub.test \ confvar.test \ confvar2.test \ copy.test \ +ctarget1.test \ cxxansi.test \ cxxcpp.test \ cxxlibobj.test \ @@ -339,6 +340,7 @@ texinfo7.test \ texinfo8.test \ texinfo9.test \ unused.test \ +vartar.test \ version.test \ version2.test \ version3.test \ diff --git a/tests/ctarget1.test b/tests/ctarget1.test new file mode 100755 index 000000000..0867712c0 --- /dev/null +++ b/tests/ctarget1.test @@ -0,0 +1,28 @@ +#! /bin/sh + +# Check basic use of conditionals. + +. $srcdir/defs || exit 1 + +cat > configure.in << 'END' +AM_INIT_AUTOMAKE(nonesuch, nonesuch) +AM_CONDITIONAL(TEST, true) +AC_OUTPUT(Makefile) +END + +cat > Makefile.am << 'END' +if TEST +target: true + action +else +target: false +endif +END + +set -e + +$AUTOMAKE +grep '^@TEST_TRUE@target: true' Makefile.in +grep '^@TEST_TRUE@ action' Makefile.in +grep '^@TEST_FALSE@target: false' Makefile.in +exit 0 diff --git a/tests/vartar.test b/tests/vartar.test new file mode 100755 index 000000000..817ae7295 --- /dev/null +++ b/tests/vartar.test @@ -0,0 +1,24 @@ +#! /bin/sh + +# Targets and macros are two different name spaces. + +. $srcdir/defs || exit 1 + +cat > Makefile.am << 'END' +INSTALL = INSTALL +INSTALL: + $(INSTALL) INSTALL +END + +$AUTOMAKE || exit 1 + +grep '^INSTALL = INSTALL$' Makefile.in || exit 1 + +cat > target.expected <<'EOF' +INSTALL: + $(INSTALL) INSTALL +EOF +sed -n '/^INSTALL:/,/^ /p' Makefile.in > target.value +diff target.expected target.value || exit 1 + +exit 0 -- 2.47.2