This is the mail archive of the
automake@gnu.org
mailing list for the automake project.
Re: Automake 1.4j: Release Candidate
- To: Robert Boehne <rboehne at ricardo-us dot com>
- Subject: Re: Automake 1.4j: Release Candidate
- From: Richard Boulton <richard at tartarus dot org>
- Date: Wed, 1 Aug 2001 12:33:37 +0100
- Cc: Automake List <automake at gnu dot org>
- List-Id: Discussion list for automake <automake.gnu.org>
- References: <878zh54nbg.fsf@creche.redhat.com> <20010731120649.A11612@sim.no> <3B6712B8.DD8DE339@ricardo-us.com> <20010801000028.A18332@ixion.tartarus.org>
On Tue, Jul 31, 2001 at 06:23:51PM -0500, Robert Boehne wrote:
> If it helps, CVS Automake as of 12 days ago seems to work properly
> in this case.
In that case, it's probably Tom Tromey's "(file_contents_internal): Only
define rule if rule_define allows us to." that caused it to break. Not
that that fix was wrong, but that it didn't do enough. I suspect you were
having the rule defined multiple times in some situations before that
change.
Okay, here's a patch. I would have submitted it sooner, but for a network
outage. It seems a little clunky to me, but I can't see a neater way to
solve this.
The gist of it is that if a user defines a rule to conditionally override
an automake generated rule, automake must still define the rule for all the
conditions for which it hasn't already been defined. Therefore, for a rule
which is conditionally defined by the user, I calculate the list of
conditions for which it is not conditionally defined, and define the rule
for each of these.
I added a couple more tests to check this behaviour.
--
Richard
Index: ChangeLog
===================================================================
RCS file: /cvs/automake/automake/ChangeLog,v
retrieving revision 1.1514
diff -u -r1.1514 ChangeLog
--- ChangeLog 2001/08/01 06:04:15 1.1514
+++ ChangeLog 2001/08/01 11:27:52
@@ -1,3 +1,14 @@
+2001-08-01 Richard Boulton <richard@tartarus.org>
+
+ * automake.in (file_contents_internal): if a rule is conditionally
+ defined, define the standard automake definition for it for those
+ conditions which are not conditionally defined.
+ (reverse_conditions): New function: reverse a list of conditionals.
+
+ * tests/cond14.test: New file.
+ * tests/cond15.test: New file.
+ * tests/Makefile.am (TESTS): Added cond14.test and cond15.test.
+
2001-07-31 Richard Boulton <richard@tartarus.org>
Raja R Harinath <harinath@cs.umn.edu>
Index: automake.in
===================================================================
RCS file: /cvs/automake/automake/automake.in,v
retrieving revision 1.1165
diff -u -r1.1165 automake.in
--- automake.in 2001/08/01 06:04:15 1.1165
+++ automake.in 2001/08/01 11:28:07
@@ -6002,6 +6002,28 @@
return @ret;
}
+# Reverse a list of conditionals
+sub reverse_conditions
+{
+ my (@conds) = @_;
+ my %conds;
+ foreach my $cond (@conds)
+ {
+ $conds{$cond} = 1;
+ }
+
+ my %notconds = ();
+ foreach my $cond (@conds)
+ {
+ foreach my $perm (variable_conditions_permutations (split(' ', $cond)))
+ {
+ $notconds{$perm} = 1
+ if ! defined $conds{$perm};
+ }
+ }
+ return sort keys %notconds;
+}
+
# Return a list of permutations of a conditional string.
sub variable_conditions_permutations
{
@@ -6930,14 +6952,38 @@
}
else
{
- # Free lance dependency. Output the rule for all the
+ # Free-lance dependency. Output the rule for all the
# targets instead of one by one.
- if (!defined $targets{$targets}
- && $cond ne 'FALSE')
+
+ # Work out all the conditions for which the target hasn't
+ # been defined
+ my @undefined_conds;
+ if (defined $target_conditional{$targets})
+ {
+ my @defined_conds = keys %{$target_conditional{$targets}};
+ @undefined_conds = reverse_conditions(@defined_conds);
+ }
+ else
+ {
+ if (defined $targets{$targets})
+ {
+ @undefined_conds = ();
+ }
+ else
+ {
+ @undefined_conds = ("");
+ }
+ }
+
+ if ($cond ne 'FALSE')
{
- $paragraph =~ s/^/make_condition (@cond_stack)/gme;
- $result_rules .= "$spacing$comment$paragraph\n"
- if rule_define ($targets, $is_am, $cond, $file);
+ my $undefined_cond;
+ for $undefined_cond (@undefined_conds) {
+ my $condparagraph = $paragraph;
+ $condparagraph =~ s/^/make_condition (@cond_stack, $undefined_cond)/gme;
+ $result_rules .= "$spacing$comment$condparagraph\n"
+ if rule_define ($targets, $is_am, "$cond $undefined_cond", $file);
+ }
}
$comment = $spacing = '';
last;
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.336
diff -u -r1.336 Makefile.am
--- Makefile.am 2001/08/01 06:04:16 1.336
+++ Makefile.am 2001/08/01 11:28:08
@@ -67,6 +67,8 @@
cond11.test \
cond12.test \
cond13.test \
+cond14.test \
+cond15.test \
condincl.test \
condincl2.test \
condlib.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.438
diff -u -r1.438 Makefile.in
--- Makefile.in 2001/08/01 06:04:16 1.438
+++ Makefile.in 2001/08/01 11:28:08
@@ -135,6 +135,8 @@
cond11.test \
cond12.test \
cond13.test \
+cond14.test \
+cond15.test \
condincl.test \
condincl2.test \
condlib.test \
Index: tests/cond14.test
===================================================================
RCS file: cond14.test
diff -N cond14.test
--- /dev/null Tue May 5 13:32:27 1998
+++ cond14.test Wed Aug 1 04:28:09 2001
@@ -0,0 +1,36 @@
+#! /bin/sh
+
+# Test for bug in conditionals.
+# Report from Robert Boehne
+
+. $srcdir/defs || exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_CONDITIONAL(COND1, true)
+END
+
+cat > Makefile.am << 'END'
+
+if COND1
+BUILD_helldl = helldl
+helldl_SOURCES = dlmain.c
+helldl_DEPENDENCIES = libhello.la
+else
+BUILD_helldl =
+bin_SCRIPTS = helldl
+helldl$(EXEEXT):
+ rm -f $@
+ echo '#! /bin/sh' > $@
+ echo '-dlopen is unsupported' >> $@
+ chmod +x $@
+endif
+
+bin_PROGRAMS = $(BUILD_helldl)
+END
+
+$ACLOCAL || exit 1
+$AUTOMAKE || exit 1
+
+num=`grep 'helldl$(EXEEXT):' Makefile.in | wc -l`
+test $num -eq 2
Index: tests/cond15.test
===================================================================
RCS file: cond15.test
diff -N cond15.test
--- /dev/null Tue May 5 13:32:27 1998
+++ cond15.test Wed Aug 1 04:28:09 2001
@@ -0,0 +1,45 @@
+#! /bin/sh
+
+# Regression test for conditionally defined overriding of automatic rules.
+
+. $srcdir/defs || exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_CONDITIONAL(COND1, true)
+AM_CONDITIONAL(COND2, true)
+END
+
+cat > Makefile.am << 'END'
+
+if COND1
+if COND2
+bin_SCRIPTS = helldl
+helldl$(EXEEXT):
+ rm -f $@
+ echo '#! /bin/sh' > $@
+ echo '-dlopen is unsupported' >> $@
+ chmod +x $@
+endif
+else
+if COND2
+else
+bin_SCRIPTS = helldl
+helldl$(EXEEXT):
+ rm -f $@
+ echo '#! /bin/sh' > $@
+ echo '-dlopen is unsupported' >> $@
+ chmod +x $@
+endif
+endif
+
+bin_PROGRAMS = helldl
+END
+
+$ACLOCAL || exit 1
+$AUTOMAKE || exit 1
+
+num1=`grep 'helldl$(EXEEXT):' Makefile.in | wc -l`
+num2=`grep '@COND1_FALSE@@COND2_TRUE@helldl$(EXEEXT):' Makefile.in | wc -l`
+test $num1 -eq 4 || exit 1
+test $num2 -eq 1 || exit 1