Subject: Re: bug#11089: LINK determination

From: Peter Breitenlohner <[email-masked]>
Date: Wed, 28 Mar 2012 13:30:52 +0200 (CEST)

On Tue, 27 Mar 2012, Stefano Lattarini wrote:

> [Adding automake-patches]
>
> Reference: <http://debbugs.gnu.org/11089>
>
>> On Sun, Mar 25, 2012 at 11:20 AM, Stefano Lattarini wrote:
>>
>> I'd describe this as an automake limitation; not sure if it's worth
>> fixing (since yours is not a common use case, and the issue you're
>> facing has a simple-enough workaround, as you've already found out);
>> but it would be worth documenting IMHO.

this situation is actually more common than one might think.  E.g., the
Makefile.am for gnuplot-4.6.0/src/ contains
 	gnuplot_SOURCES = alloc.c ETC.
 	if BUILD_WXWIDGETS
 	gnuplot_SOURCES += wxterminal/wxt_gui.cpp
 	endif
but that actually ought to be
 	gnuplot_SOURCES = alloc.c ETC.
 	if BUILD_WXWIDGETS
 	gnuplot_SOURCES += wxterminal/wxt_gui.cpp
 	gnuplot_LINK = $(CXXLINK)
 	else
         gnuplot_LINK = $(LINK)
 	endif

> On a second thought, I've been unable to find a way to document Jason's
> workaround that doesn't sound cumbersome and clumsy; so maybe it's better
> to just drop this documentation change.
>
> Still, having a test case verifying that such a workaround actually works
> is still worthwhile and easy to do.  This is what the attached patch does.
> I will push it this evening or tomorrow if there is no objection.

the workaround described earlier in this thread and used in the test case:
 	if HAVE_CXX
 	foo_LINK = $(CXXLINK)
 	else
 	foo_LINK = $(LINK)
 	endif
works nicely and is simple enough when not using libtool libraries.  When
linking foo with (installed or uninstalled) libtool libraries, the default
definition of foo_LINK generated by Automake would be something like
 	foo_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
 	        --mode=link $(CXXLD) $(foo_CXXFLAGS) $(CXXFLAGS) \
 	        $(foo_LDFLAGS) $(LDFLAGS) -o $@
and a more elaborate workaround is needed.

What is the best way to handle this situation?  An additional test case?

Regards
Peter Breitenlohner <[email-masked]>