[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The automake/libtool way to make a dynamic lib from multiple sources
From: |
Ralf Wildenhues |
Subject: |
Re: The automake/libtool way to make a dynamic lib from multiple sources |
Date: |
Fri, 22 Sep 2006 04:34:15 +0200 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
* Ryan McDougall wrote on Fri, Sep 22, 2006 at 02:54:21AM CEST:
> On Thu, 2006-09-21 at 13:32 +0200, Ralf Wildenhues wrote:
> > * Ryan McDougall wrote on Thu, Sep 21, 2006 at 11:40:37AM CEST:
> > >
> > 1) If you prefer recursive makefiles then you can have each directory
> > create one (or a number of) libtool convenience archives
> > (noinst_LTLIBRARIES), which you can merge into the real modules
> > (A_la_LIBADD = ../foo/libfoo.la)
> >
> > You should keep in mind that the convenience archives will end up in
> > total (i.e., all their symbols, not just needed ones) in the resulting
> > module.
>
> This is a good point, thank you. Do you have any more information
> somewhere that elaborates on this point?
The Libtool manual has more details about this (but it's arguably a bit
cryptic about convenience archives). I'm not sure what you need to
know.
> > 2) If you prefer nonrecursive makefiles (you may include makefile
> > snippets from one into another), then you can just
> >
> > AUTOMAKE_OPTIONS = subdir-objects
> > module_LTLIBRARIES = libA.la libB.la libC.la
> > libA_la_SOURCES = foo/foo1.c bar/bar2.c A/a1.c ...
> > libB_la_SOURCES = baz/baz1/c bar/bar2.c B/b1.c ..
>
> I thought of this, but in this case libA_la_SOURCES could be on the
> order of 100-50 files long, which Id like to avoid if possible.
You don't have to set this in one, and you can use variables (and
Automake conditionals) to factor. For example:
-- Makefile.am --
AUTOMAKE_OPTIONS = subdir-objects
module_LTLIBRARIES = libA.la libB.la libC.la
libA_la_SOURCES =
libB_la_SOURCES =
common_sources =
include foo/snippet.am
include bar/snippet.am
if CONDITION_BAZ
libB_la_SOURCES += baz/baz1.c
endif
libA_la_SOURCES += $(common_sources)
libB_la_SOURCES += $(common_sources)
-- foo/snippet.am --
## Note the file name including the subdir here: we are being included
## from a level up (Automake includes just do literal replacement):
libA_la_SOURCES += foo/foo1.c
-- bar/snippet.am
common_sources += \
bar/bar2.c \
...
-- end
> AUTOMAKE_OPTIONS=subdir-objects tells automake to build temporary
> objects ("foo.lo") in the sub directories
Yes.
> to improve build times?
No, I don't think so. Well. For one, subdir-objects appear cleaner to
some users (i.e., purely a matter of taste). Then, more often objects
are not renamed by Automake in subdir-objects mode. The option also has
an impact on the size of the generated Makefile.in, but I'm not sure it
can be said generally whether that's for the better or worse (depends
for example on whether per-target compile flags are used).
> What is the "module" target?
Oh, I forgot. If you install the modules in $(libdir), just use
lib_LTLIBRARIES; for the above to work you need something like
moduledir = $(libdir)/foo
or similar (e.g., pkglibdir; or a setting in configure.ac).
You should not forget the libtool link flag -module (libA_la_LDFLAGS).
Cheers,
Ralf
Re: The automake/libtool way to make a dynamic lib from multiple sources, Ryan McDougall, 2006/09/21