Re: {newbie question] dependencies on libraries

Bram Moolenaar <[email protected]> Fri, 06 Feb 2004 17:39:00 +0100
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
John Williams wrote:

> On Fri, 06 Feb 2004 14:30:35 +0100, Bram Moolenaar wrote:
> > Adding a shared library to the sources of a program is not supported.
> > Should it work?
> > 
> > You can specify the dependency explicitly:
> > 
> > 	:dll dog : dog.cpp
> > 	:program go1 
> > 		{var_LIBS= -ldog }
> > 		{var_LDFLAGS= -L. }
> > 		:
> > 		go1.cpp
> > 	go1 : dog
> > 
> > Since you use "-ldog" this is more logical than adding "dog" as a source
> > file.  Aap cannot know which "dog" library you want to link with (could
> > be a system library), thus I don't think this should be done
> > automatically.
> 
> I'm not sure I agree.  What about adding something like this at the end of
> the recipe processing stage:
> 
> for each PROG defined in a ":program" command:
>   for each DIR such that there is an -L$DIR flag in $PROG's $LIBS:
>     for each LIB such that there an -l$LIB flag in $PROG's $LIBS:
>       if there is a target defined for $DIR/$LIB:
>         Add a dependency on $DIR/$LIB to $PROG.
> 
> This should automatically cover situations where the program depends on a
> library that is part of the same project, but ignore system libraries.
> (I intentionally omitted searching for -L flags in $LDFLAGS, since
> these come from the user rather than the recipe author.)

Well, this pseudo-code can make a good guess, but there are too many
flaws in my opinion:

- Not all compilers use "-Ldir" and "-llib" arguments.
- The order of arguments may be important.
- There may be both a shared and static version of a library, need to
  check further arguments to find out which one is being used.

I think it becomes too unreliable to automate this.  While it's not
really difficult for the user to specify the dependency explicitly.

I do think that it might be a good idea to support adding a library as
a source argument to ":program", so that you don't have to specify
$LIBS.  In that case the dependency can also be handled.  At least for
static libraries, which are not much different than an ordinary object
file.

-- 
hundred-and-one symptoms of being an internet addict:
62. If your doorbell rings, you think that new mail has arrived.  And then
    you're disappointed that it's only someone at the door.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn