bug-gnulib
[Top][All Lists]
Advanced

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

Re: LIBDEPS vs. module Link: directive


From: Bruno Haible
Subject: Re: LIBDEPS vs. module Link: directive
Date: Tue, 1 Apr 2008 03:19:25 +0200
User-agent: KMail/1.5.4

Hi Eric,

> Back in 2006, gnulib-tool added support to generate the variable 
> LIB<FOO>_LIBDEPS that could be used in Makefile.am to pull in any libraries 
> required by gnulib but not the main program.
> http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=a262d09e
> 
> However, this doesn't seem to work unless the module description takes pains 
> to 
> edit gl_libdeps.  And right now, only crypto/gc, striconv, and striconveh do 
> so.
> ...
> On the other hand, there is the more recent addition of the Link: directive 
> in 
> modules, which was added to make gnulib-tool output mention that clients of a 
> gnulib library might need to add $(POW_LIB) to their Makefile.am.

Both approaches work, but they have different effects:
  - The 'Link:' approach is generally the preferrable one, because it allows
    the programmer of a package with multiple programs (e.g. coreutils,
    findutils) to link each program with only those libraries that it needs.
  - The lib_LDFLAGS / gl_libdeps approach has the effect that all programs
    that link with libgnu.a will link with the libraries.

The second approach is therefore only suitable in cases where the use of the
libraries is so pervasive that is normally cannot be avoided.

> This bit me in M4, where strtod now triggers a replacement that requires 
> POW_LIB (-lm) on many more platforms than what it used to do, so I had to 
> edit 
> my Makefile.am to add $(POW_LIB) to m4_LDADD even though it was already using 
> $(LIBM4_LIBDEPS).

In this case, I would try to avoid the dependency. strtod() is not documented
(in the Linux manual page) to require -lm. Therefore it's strange / surprising
that the implementation in gnulib needs -lm. In particular, the need for -lm
comes only from the use of the function pow(10,...), which is wrong anyway
because it leads to rounding errors, as you already noted in the strtod.texi
file.

For printf(), I avoided the need for -lm by creating a few *-nolibm modules.
You can do the same for the primitives needed by strtod.

> Would it be 
> possible to make the existence of the Link: directive smart enough to auto-
> update the gl_libdeps magic so POW_LIB and friends get added to 
> LIB<FOO>_LIBDEPS?  That way, projects that are okay with using the simpler 
> $(LIB<FOO>_LIBDEPS) notation will not need any Makefile.am edits ...

... but it will hamper projects which build several programs.

Bruno





reply via email to

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