automake
[Top][All Lists]
Advanced

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

Re: Common Source code


From: Ralf Wildenhues
Subject: Re: Common Source code
Date: Fri, 12 May 2006 15:45:03 +0200
User-agent: Mutt/1.5.11

* Paulo J. Matos wrote on Fri, May 12, 2006 at 03:01:55PM CEST:
> On 12/05/06, Paulo J. Matos <address@hidden> wrote:
> >
> >Ah, that's most probably what I need. Thanks a lot!

I don't know if you _need_ a convenience archive.  You should not link
it into two different shared libraries that one program may later be
linked against (quoting info Libtool "Static libraries"):

|    As a rule of thumb, link a libtool convenience library into at most
| one libtool library, and never into a program, and link libtool static
| convenience libraries only into programs, and only if you need to carry
| library dependency information to the user of the static convenience
| library.

That is because otherwise you are bound to get duplicate symbols
eventually.

To avoid this, you can use a real library instead.

> After reading the chapter you mentioned and browsing the rest of the
> very nice book I implemented things that way and set up the structure
> (I'll forget lib2):
> tree
> |- lib
> |    |- install-libs
> |    |          |- lib1
> |    |- convenience-libs
> |               |- liblogger
> |- src

Note while the book isn't so bad, it's quite old; this tutorial explains
newer autotools concepts:
http://www-src.lip6.fr/homepages/Alexandre.Duret-Lutz/autotools.html

> And I have only one Makefile.am in lib logger and the source files.
> The Makefile.am in liblogger is:
> noinst_LTLIBRARIES = liblogger.la
> libesatlogger_la_SOURCES = logger.cc logger.hh
> 
> The configure.ac in lib1 specifies:
> AC_CONFIG_FILES([Makefile
>                                       src/Makefile
> 
> ../../convenience-libs/liblogger/Makefile])

Nono.  Don't specify ../../convenience-libs/liblogger/Makefile here.

> And in Makefile.am in lib1:
> SUBDIRS = ../../convenience-libs/liblogger src

The collective SUBDIRS listings in your source tree must form an acyclic
directed graph, i.e., a tree.  As a rule of thumb, only specify direct
or insirect subdirectories of the current directory in SUBDIRS (i.e.,
containing no `../').

> Makefile of liblogger is generated OK, however I get an error:
> make[2]: Entering directory 
> `/home/pmatos/soft/lib/convenience-libs/liblogger'
> make[2]: *** No rule to make target `../../../../configure.ac', needed
> by `Makefile.in'.  Stop.

Exactly.

> The problem is that the generated Makefile in liblogger has:
> top_srcdir = ../../../..
> 
> And the top_srcdir is the one in lib1 which is ../../usable-libs/lib1
> and not ../../../..

Exactly.

> Probably liblogger would have to be inside the lib1 tree but what
> happens in lib2 also needs liblogger as a convinience library? Do I
> have to duplicate liblogger inside lib2 tree? Don't think this is the
> way to go.
> 
> Is this a bug or a problem of my configuration?

Your setup isn't right.

If you want to ensure from within both lib1 and lib2 that liblogger is
up to date, you can add something of this form to their Makefile.am's:

../../../liblogger/src/liblogger.la:
        cd ../../../liblogger/src && $(MAKE) $(AM_MAKEFLAGS) liblogger.la

(or possibly going into ../../../liblogger and issuing just `$(MAKE)
$(AM_MAKEFLAGS)', depending on your needs).

This has the disadvantage of not updating liblogger if it already
exists, since you don't provide the complete dependency information for
liblogger.la inside lib1's Makefile.  You could declare the target
`../../../liblogger/src/liblogger.la' phony, or have it depend on
something that never exists; that would cause liblogger to be up to date
on each build of lib1, but it would also cause unnecessary rebuilds each
time you issue `make', at least with some make implementations.

Cheers,
Ralf




reply via email to

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