+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'.
# 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;
}
-# ($LINKER, @OBJECTS)
+# @OBJECTS
# handle_single_transform_list ($VAR, $DERIVED, $OBJ, @FILES)
# -----------------------------------------------------------
# Does much of the actual work for handle_source_transform.
# $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.
}
}
- return (&resolve_linker (%linkers_used), @result);
+ return @result;
}
}
my %used_pfx = ();
+ my $needlinker;
+ %linkers_used = ();
foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
'dist_EXTRA_', 'nodist_EXTRA_')
{
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',
unless $prefix =~ /EXTRA_/;
}
}
+ if ($needlinker)
+ {
+ $linker ||= &resolve_linker (%linkers_used);
+ }
my @keys = sort keys %used_pfx;
if (scalar @keys == 0)
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
--- /dev/null
+#! /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