diff -u -r automake/ChangeLog automake_patch1/ChangeLog --- automake/ChangeLog Thu Aug 9 00:41:14 2001 +++ automake_patch1/ChangeLog Thu Aug 9 17:55:46 2001 @@ -1,3 +1,18 @@ +2001-08-09 Richard Boulton + + * 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 Dissociate testsuite 'make' invocations from outer 'make'. diff -u -r automake/automake.in automake_patch1/automake.in --- automake/automake.in Wed Aug 8 17:43:51 2001 +++ automake_patch1/automake.in Thu Aug 9 17:48:33 2001 @@ -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,9 @@ unless $prefix =~ /EXTRA_/; } } + if ($needlinker) { + $linker ||= &resolve_linker (%linkers_used); + } my @keys = sort keys %used_pfx; if (scalar @keys == 0) @@ -2084,11 +2090,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 -u -r automake/tests/Makefile.am automake_patch1/tests/Makefile.am --- automake/tests/Makefile.am Wed Aug 8 18:40:07 2001 +++ automake_patch1/tests/Makefile.am Thu Aug 9 17:22:54 2001 @@ -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 -u -r automake/tests/Makefile.in automake_patch1/tests/Makefile.in --- automake/tests/Makefile.in Wed Aug 8 18:40:08 2001 +++ automake_patch1/tests/Makefile.in Thu Aug 9 17:23:20 2001 @@ -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 -u -r automake/tests/link_dist.test automake_patch1/tests/link_dist.test --- automake/tests/link_dist.test Thu Jan 1 01:00:00 1970 +++ automake_patch1/tests/link_dist.test Thu Aug 9 17:09:42 2001 @@ -0,0 +1,37 @@ +#! /bin/sh + +# Test to make sure the linker for a dist_*_SOURCES can override that for +# *_SOURCES +# Richard Boulton + +. $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