automake
[Top][All Lists]
Advanced

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

Re: linking against libraries which a not in the local directory


From: Ralf Wildenhues
Subject: Re: linking against libraries which a not in the local directory
Date: Tue, 13 Jan 2009 08:09:00 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hello,

* gromeck wrote on Mon, Jan 12, 2009 at 12:05:44PM CET:
> 
>    src/
>    src/dirA/  holds lib A and program A
>    src/dirB/  holds lib B and program B
> 
> Both, program A and B have to linked against lib A and B!
> Yes, I know that this is not a good layout but I have
> currently no other chance to rearrange it (the real project
> is somewhat larger).
> 
> In src/dirA/Makefile.am I've set
> 
>    progA_LDADD=libA.a ../dirB/libB.a
> 
> but the build of libB.a is not triggered automatically.

First, does src/Makefile.am list dirB before dirA in SUBDIRS?

> A workaround is to add the following target to
> src/dirA/Makefile.am:
> 
>    ../dirB/libB.a:
>        make -C ../dirB/ libB.a

Note, for portability, the action should be
        cd ../dirB && $(MAKE) $(AM_MAKEFLAGS) libB.a

and the rule should either be phony (which would make it less efficient
than it could be) or list dependencies of libB (which would require you
to add even more information manually).

> But I think, this is a hack.

Agreed.

>  1. is there a way to setup the dependencies in a way which
>     triggers build of the lib which is not in the local
>     directory?

You can instead use a nonrecursive makefile setup.  See
  info Automake Alternative

for pointers.  This is what I'd do.  Example:

  lib_LIBRARIES = dirA/libA.a dirB/libB.a
  dirA_libA_a_SOURCES = ...
  dirB_libB_a_SOURCES = ...
  bin_PROGRAMS = dirA/A dirB/B
  dirA_A_LDADD = dirA/libA.a dirB/libB.a
  ...

>  2. is there a way to trigger building all libs in a source
>     tree ("make libs")?

You can add rules yourself to Makefile.am files.  Note that
unfortunately, you will have to implement the recursion yourself, too.

Hope that helps.

Cheers,
Ralf




reply via email to

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