[Top][All Lists]

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

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

From: gromeck
Subject: Re: linking against libraries which a not in the local directory
Date: Tue, 13 Jan 2009 10:09:03 +0100
User-agent: RoundCube Webmail/0.1


On Tue, 13 Jan 2009 08:09:00 +0100, Ralf Wildenhues
<address@hidden> wrote:
> 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/ I've set
>>    progA_LDADD=libA.a ../dirB/libB.a
>> but the build of libB.a is not triggered automatically.
> First, does src/ list dirB before dirA in SUBDIRS?

No, but it doesn't make a difference, because progB also
depends on libA.

>> A workaround is to add the following target to
>> src/dirA/
>>    ../dirB/libB.a:
>>        make -C ../dirB/ libB.a
> Note, for portability, the action should be
>         cd ../dirB && $(MAKE) $(AM_MAKEFLAGS) libB.a

Thanks for the hint.

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

Yes, you're right, thanks.

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

Yes, but this is unfortunately not an option for my
target environment (which is really huge).

>>  2. is there a way to trigger building all libs in a source
>>     tree ("make libs")?
> You can add rules yourself to files.  Note that
> unfortunately, you will have to implement the recursion yourself, too.

This could be an option.

> Hope that helps.

If I got no other option, I will use phony targets for the
dependencies to the non-local libs.


reply via email to

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