autoconf
[Top][All Lists]
Advanced

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

Re: AC_SEARCH_LIBS and two programs


From: Andrey Simonenko
Subject: Re: AC_SEARCH_LIBS and two programs
Date: Tue, 3 Apr 2007 17:17:45 +0300
User-agent: Mutt/1.5.14 (2007-02-12)

Hello,

On Mon, Apr 02, 2007 at 09:15:05AM +0200, Ralf Wildenhues wrote:
> Hi Andrey,
> 
> * Andrey Simonenko wrote on Fri, Mar 30, 2007 at 10:53:45AM CEST:
> > 
> > There are two programs t1 and t2, one configure and
> > one Makefile which are used for building them.
> > 
> > t2 uses the cos() function, and t1 does not use cos().
> [...]
> 
> Your solution looks just about right to me.
> 
> > May be "LIBS=" in configure.ac can be removed, but in this case
> > I see "... -lm -lz -lz" for t2.
> 
> Well, I assume the -lz parts then come from a different part of the
> original code not shown in the example; optimizing that should be done
> independently of the issue presented here.

The configure invocation string was given in the original letter:

% env LIBS=-lz ./configure

> 
> FWIW, I would omit the `LIBS=' part for another reason: on some obscure
> system, cos() may be found in another library.  The user knows this, but
> the developer (you) doesn't.  If you don't override LIBS, then you
> retain his choice by
>   ./configure LIBS=-lcoolmathlib
> 

This is right, that's why I do not like `LIBS='.

My situation is the following: one configure script and several programs,
each of them can use different library.  I simply do not want to add some
library for a program, if that program does not use any function from this
library and want everything to be built with one configure and one make
call.  As the result each program should get different -l flags.

Another way to solve problem with user libraries: create t1_LIBS and t2_LIBS
environment variables.  Now before each AC_SEARCH_LIBS() the LIBS will be
set to ${t1_LIBS} or ${t2_LIBS}, and the result value of LIBS after
AC_SEARCH_LIBS() will be saved in some variable and later AC_SUBSTituted
in Makefile.in:

% env t2_LIBS=-lcoolmathlib ./configure

Now t1 will get no -l flags,
t2 will get "-lcoolmathlib" or "-lcoolmathlib -lm".

As a side effect the same library can be specified several times
for each program: like "-lcoolmathlib -lcoolmathlib -lcoolmathlib",
if several AC_SEARCH_LIBS() are used.  I do not know if this can
be a problem for some linker.

> This is no unusual example: optimized math libraries are abundant with
> some compiler suites.

The cos() function was given just as an example.

Thank you for the answer.




reply via email to

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