[Top][All Lists]

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

Re: Conditional modules and libraries.

From: Alexandre Duret-Lutz
Subject: Re: Conditional modules and libraries.
Date: Wed, 26 Mar 2003 22:12:10 +0100
User-agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/21.2 (gnu/linux)

[mfu2: address@hidden

>>> "Bill" == Bill Moseley <address@hidden> writes:


 Bill> I've tried to read all the docs (a few times), but it's
 Bill> still not clear for me.

If there are specific parts of the manual that you think should
be augmented or clarified, please report them.  This will help


 Bill> My existing script checks for libxml2 and then sets:

 Bill> AC_DEFINE(HAVE_LIBXML2,[],[libxml support])
 Bill> LIBXML2_OBJS="parser.lo"


 Bill> The last two are set from xml2-config --libs and --cflags commands.

 Bill> I use parser.lo because I'm building with libtool, but I'm not sure if
 Bill> that's the correct method.

 Bill> So, what I'm trying is:


 Bill> [other library and binary built in this snipped]

 Bill> noinst_LTLIBRARIES =
 Bill> libswishindex_la_LIBADD = @LIBXML2_LIB@ @LIBXML2_OBJS@  
 Bill> libswishindex_la_DEPENDENCIES = @LIBXML2_OBJS@
 Bill> ##libswishindex_la_LDADD = @LIBXML2_OBJS@
 Bill> EXTRA_libswishindex_la_SOURCES = parser.c parser.h

 Bill> libswishindex_la_SOURCES = \
 Bill> fs.c fs.h \
 Bill> http.c http.h \
 Bill> ...

$(LIBXML2_LIB) -- nowadays we prefer this syntax over @LIBXML2_LIB@ --
should probably go into libswishindex_la_LDFLAGS, not _LIBADD.

 Bill> Automake is telling me to use LIBADD not LDADD although I was trying to
 Bill> follow the example on page 43 of the Autoconf book -- I still don't get
 Bill> the difference between LDADD and LIBADD.

LIBADD is for libraries and LDADD is for binaries.   That's all.

 Bill> So, basically:

 Bill> - I want to conditionally add -lxml2 and the CPPFLAGS and the parser.o
 Bill> module in only that one convenience library.  I guess it doesn't hurt
 Bill> that AM_CPPFLAGS adds the flags to the other library build, but it would
 Bill> seem best to add them just when building parser.o.

For conditional sources, see
(what applies to programs applies to libraries as well once you change

To set per-library CPPFLAGS and LDFLAGS, use
libswishindex_la_LDFLAGS and libswishindex_la_CPPFLAGS.  These
are documented here.

There is now way to have per-object flags (yet).  Unless you
compile this single object as a convenient library and use
per-library flags.

 Bill> - I do not understand what the DEPENDENCIES entry does,
 Bill> if anything.  Is that needed?

The way you achieve conditional compilation, yes.  You do want to be rebuilt when parser.c changes, don't you?

The first URL above shows a second approach that does not
require playing with ugly stuff like _DEPENDENCIES or `.lo'.
Maybe I'll prefer that.

 Bill> By the way, how can I force the complete rebuiding of just one
 Bill> (convenience) library without rebuilding everything?

You can use sub-directories to make partial cleaning easier or
write your own clean rule.  I fail to see why you want to do
that, though (hidden dependencies?)
Alexandre Duret-Lutz

reply via email to

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