automake
[Top][All Lists]
Advanced

[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: Ryan McDougall
Subject: Re: The automake/libtool way to make a dynamic lib from multiple sources
Date: Thu, 28 Sep 2006 18:23:10 +0900

On Fri, 2006-09-22 at 04:34 +0200, Ralf Wildenhues wrote:
> * 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:

> > > 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 \
>   ...
> 

Thanks for all your help Ralf, I _really_ appreciate you taking your
time to help me out.

I am currently attempting to use a version of this (non-recursive)
method. I am avoiding exactly what you wrote since I need to pass
specific -D options to different packages without using libA_CPPFLAGS =
-DFORLIBFOO -DFORLIBBAR -DETC.

What I have now is I have replaced the file names in the recursive
Makefile.am's to be relative to the root directory like so:
libfoo_SOURCES=src/foo.cpp -> libfoo_SOURCES=libfoo/src/foo.cpp
and included libfoo/Makefile.am in the root Makefile.am.

This works well, and would nearly be finished, except in my root
Makefile.am I get this:
noinst_LTLIBRARIES = libfoo.la ...
lib_LTLIBRARIES = libA.la

which Automake dutifully turns into a rule which always builds libA.la
before libfoo.la, despite the fact that libA depends on libfoo (as
expressed by the variable libA_la_LIBADD = -lfoo).

How can I either
1. Express to automake the correct dependancy
2. Trick automake into building lib_LTLIBRARIES last (after
noinst_LTLIBRARIES)

ps. This would have been a lot easier if Automake would have
automatically provided targets for each one of the SUBDIRS. That way I
could have simply wrote one rule, libA: foo bar baz (where foo bar baz
are SUBDIRs that need to be build before the SUBDIR libA).

Should I open a bug/feature request?

Thanks a tonne for your unheralded work!!! Id hate to have to give up on
autotools.

Cheers,





reply via email to

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