automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: program specific LDFLAGS


From: Ralf Wildenhues
Subject: Re: program specific LDFLAGS
Date: Sat, 27 Jan 2007 16:52:25 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Hello David, Bob, all,

* Bob Rossi wrote on Sat, Jan 27, 2007 at 02:38:23PM CET:
> On Fri, Jan 26, 2007 at 11:04:36PM -0800, David Byron wrote:
> > 
> > # Use these flags for all the programs built here
> > LDADD = $(top_builddir)/util/util.a $(BOOST_LIBS) ${PTHREAD_LIBS}

> > # testrunner needs testmain and some other things
> > testrunner_LDADD = $(top_builddir)/testmain/libtestmain.a $(BOOST_LIBS)
> > $(CPPUNIT_LIBS) $(GETOPT_LIBS) $(LDADD)
> 
> Well, I could be wrong about this, since I'm not an expert. But I do,
>   testrunner_LDADD = -ltestmain $(BOOST_LIBS)
>   $(CPPUNIT_LIBS) $(GETOPT_LIBS) $(LDADD)
>   testrunner_LDFLAGS = -L$(top_builddir)/testmain
> don't know if that makes a big difference.

It makes a difference.  For in-tree libraries, referring to them as
libfoo.a (or libfoo.la) with relative paths (using $(top_builddir) is
usually ok), it allows Automake to know that libfoo.a is a dependency
of the program.  That way, the program is rebuilt when libfoo.a is
newer.  Also, if a rule for libfoo.a exists in the same Makefile (or you
have ensured, by ordering of Makefiles), then libfoo.a will be built
before the program if it does not exist.

So a good rule of thumb is: write "-L/absolute/path -lfoo" for installed
libraries, and ../lib/libfoo.a resp. ../libfoo.la for uninstalled
libraries.  Put them in *_LDADD resp. *_LIBADD.  Actually, the -L can
(and, due to ordering issues, sometimes should) go in *_LFLAGS.

Surely writing libfoo.a is a problem when using MSVC + LIB for archive
creation.  But then again that doesn't work well out of the box anyway;
you could be using Libtool, name it libfoo.la and put -static in
libfoo_la_LDFLAGS.

> > if PLATFORM_WINDOWS
> >     testrunner_LDADD += $(top_builddir)/minidumper/libminidumper.a
> >     testrunner_LDFLAGS = /ENTRY:testrunnerCRTStartup
> >     LIBS += version.lib
> > endif
> 
> Again, I would consider doing this very different. In autoconf, figure
> out if you are on windows with the AC_CANONICAL_TARGET, ..

Actually, I don't see any issue at all with David's very first code
snippet.  And casual inspection shows that it seems to be expanded just
right by Automake-1.10.  David, which version do you use?

Of course, Bob's suggestions seem fine as well.  There's more than one
way to do it.

A small nit (and probably one cause for problems): write -ENTRY instead
of /ENTRY for MSVC (that's what you're after, right?), so the MSYS shell
won't mangle it for you.

Hope that helps.  If not, then I'm not seeing the actual problem
(either due to blindness, or insufficient information ;-)

Cheers,
Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]