* automake.in (handle_single_transform_list): Use new global,
`%linkers_used', to store the linkers used, rather than an internal
variable. Enables correct linker to be calculated across a group
of calls to &handle_single_transform_list. Return only list of
objects, since linker to be used is now externally determined.
(handle_source_transform): adapted for new calling conventions of
handle_single_transform_list. Calls resolve_linker() on a set of
all the linkers used for any prefix, rather than for each prefix in
turn.
(linkers_used): New global.
* tests/link_dist.test: New test.
* tests/Makefile.am (TESTS): Added link_dist.test.
diff --git a/ChangeLog b/ChangeLog
index d192e68..4572a2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2001-08-09 Richard Boulton <richard@tartarus.org>
+
+ * automake.in (handle_single_transform_list): Use new global,
+ `%linkers_used', to store the linkers used, rather than an internal
+ variable. Enables correct linker to be calculated across a group
+ of calls to &handle_single_transform_list. Return only list of
+ objects, since linker to be used is now externally determined.
+ (handle_source_transform): adapted for new calling conventions of
+ handle_single_transform_list. Calls resolve_linker() on a set of
+ all the linkers used for any prefix, rather than for each prefix in
+ turn.
+ (linkers_used): New global.
+ * tests/link_dist.test: New test.
+ * tests/Makefile.am (TESTS): Added link_dist.test.
+
2001-08-08 Raja R Harinath <harinath@cs.umn.edu>
Dissociate testsuite 'make' invocations from outer 'make'.
diff --git a/automake.in b/automake.in
index a49d9a7..93f0503 100755
--- a/automake.in
+++ b/automake.in
@@ -631,6 +631,10 @@
# we should no longer push on dist_common.
my $handle_dist_run;
+# Used to store a set of linkers needed to generate the sources currently
+# under consideration.
+my %linkers_used;
+
# True if we need `LINK' defined. This is a hack.
my $need_link;
@@ -1731,7 +1735,7 @@
}
-# ($LINKER, @OBJECTS)
+# @OBJECTS
# handle_single_transform_list ($VAR, $DERIVED, $OBJ, @FILES)
# -----------------------------------------------------------
# Does much of the actual work for handle_source_transform.
@@ -1739,16 +1743,14 @@
# $DERIVED is the name of resulting executable or library
# $OBJ is the object extension (e.g., `$U.lo')
# @FILES is the list of source files to transform
-# Result is a list
-# $LINKER is name of linker to use (empty string for default linker)
-# @OBJECTS are names of objects
+# Result is a list of the names of objects
+# %linkers_used will be updated with any linkers needed
sub handle_single_transform_list ($$$@)
{
my ($var, $derived, $obj, @files) = @_;
my @result = ();
my $nonansi_obj = $obj;
$nonansi_obj =~ s/\$U//g;
- my %linkers_used = ();
# Turn sources into objects. We use a while loop like this
# because we might add to @files in the loop.
@@ -2012,7 +2014,7 @@
}
}
- return (&resolve_linker (%linkers_used), @result);
+ return @result;
}
@@ -2041,6 +2043,8 @@
}
my %used_pfx = ();
+ my $needlinker;
+ %linkers_used = ();
foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
'dist_EXTRA_', 'nodist_EXTRA_')
{
@@ -2063,12 +2067,11 @@
foreach my $cond (variable_conditions ($var))
{
my @files = &variable_value_as_list ($var, $cond);
- my ($temp, @result) =
+ my (@result) =
&handle_single_transform_list ($var, $one_file, $obj,
@files);
# If there are no files to compile, don't require a linker (yet).
- $linker ||= $temp
- if @files;
+ $needlinker ||= "true" if @result;
# Define _OBJECTS conditionally.
&define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
@@ -2076,6 +2079,10 @@
unless $prefix =~ /EXTRA_/;
}
}
+ if ($needlinker)
+ {
+ $linker ||= &resolve_linker (%linkers_used);
+ }
my @keys = sort keys %used_pfx;
if (scalar @keys == 0)
@@ -2084,11 +2091,12 @@
push (@sources, $unxformed . '.c');
push (@dist_sources, $unxformed . '.c');
- my ($temp, @result) =
+ %linkers_used = ();
+ my (@result) =
&handle_single_transform_list ($one_file . '_SOURCES',
$one_file, $obj,
"$unxformed.c");
- $linker = $temp if $linker eq '';
+ $linker ||= &resolve_linker (%linkers_used);
&define_pretty_variable ($one_file . "_OBJECTS", '', @result)
}
else
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8590ae6..bad25a6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -190,6 +190,7 @@
libtool.test \
libtool2.test \
link_c_cxx.test \
+link_dist.test \
link_f_c.test \
link_f_c_cxx.test \
link_f_cxx.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 215e8f3..691aef0 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -258,6 +258,7 @@
libtool.test \
libtool2.test \
link_c_cxx.test \
+link_dist.test \
link_f_c.test \
link_f_c_cxx.test \
link_f_cxx.test \
diff --git a/tests/link_dist.test b/tests/link_dist.test
new file mode 100755
index 0000000..f085c9a
--- /dev/null
+++ b/tests/link_dist.test
@@ -0,0 +1,37 @@
+#! /bin/sh
+
+# Test to make sure the linker for a dist_*_SOURCES can override that for
+# *_SOURCES
+# Richard Boulton <richard@tartarus.org>
+
+. $srcdir/defs || exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lavalamp
+lavalamp_SOURCES = lava.c
+dist_lavalamp_SOURCES = lamp.cxx
+END
+
+: > lava.c
+: > lamp.cxx
+
+$ACLOCAL || exit 1
+$AUTOMAKE || exit 1
+
+
+# We should only see the C++ linker in the rules of `Makefile.in'.
+
+# Look for this macro not at the beginning of any line; that will have
+# to be good enough for now.
+grep '.\$(CXXLINK)' Makefile.in || exit 1
+
+# We should not see these patterns:
+grep '.\$(FLINK)' Makefile.in && exit 1
+grep '.\$(LINK)' Makefile.in && exit 1
+
+exit 0