[gnutls-dev] Re: pkg-config support for opencdk

Simon Josefsson jas at extundo.com
Tue Aug 8 14:47:39 CEST 2006


Andreas Metzler <ametzler at downhill.at.eu.org> writes:

>> Btw, I'd recommend people to use standard autoconf-mechanisms to find
>> opencdk,
>
> I did provide this as the current *m4 tests shipped in the gnutls
> software are problematic. They use foo-config to get the needed
> dependency libs and CFLAGS and foo-config is not smart enough. For
> example libgnutls-config --libs generates this output:
>
> -L/usr/lib -lgnutls -L/usr/lib -ltasn1 -lgcrypt -lgpg-error

Right, and I recommend against using gnutls*-config for the same
reason too.

I think Bruno's AC_LIB_HAVE_LINKFLAGS is the best choice.  It works
for cross-compilations, can check for particular versions through the
gnutls.h LIBGNUTLS_VERSION* symbols, and doesn't add unnecessary
libraries to the link line, and works with and without libtool.

Using pkg-config may be simpler, and more well tested than Bruno's
macro, but it doesn't follow the test-for-feature approach.

> However on many systems (Linux, the Hurd, ...) it is not necessary to
> link indirect dependencies when doing symbolic linking. i.e. if you use
> gnutls-functions this will be enough
> gcc -lgnutls -o foo foo.c
> there is no need to link against -ltasn1 -lgcrypt -lgpg-error, the
> symbolic linker will handle these just fine at run-time.

Right.

> This unnecessary linkage hurts us (Debian), because dependency cycles
> get a lot bigger than necessary. The greater part of gnome will link
> against libtasn although only gnutls functions are used, and if tasn
> changes its soname we will need to rebuild a 100 times the packages
> than actually necessary (and until that has happened the yet
> not-rebuilt ones link against two versions of libtasn).

Oops.

> pkg-config can solve this problem because knowledge about whether
> direct linking of dependency libs is necessary is built in,
> the output of "pkg-config --libs gnutls" differs in between "broken"
> and other systems.

Ok.  I think lib-link.m4 does this too; it checks which libraries are
required to link.

> I fail to come up with such a szenario at short time however, and
> googling seems to suggest that crosscompilation of pkg-config using
> software is possible.

Pkg-config works fine for cross-compilation if you point each
configure script at the proper pkg-config script for the already
cross-compiled library.  However, things doesn't happen automatically,
and pkg-config doesn't know for which platform a particular library is
built for.  Bruno's macro uses the compiler/linker to find the
libraries, and this seems like a more reliable approach.

>> and it also breaks the standard autoconf-approach of testing for
>> features.
>
> You can use pkg-config to find the library and then use the standard
> tests.

Yup.

> I am just arguing that pkg-config might do a better job than the
> foo-config scripts.

Agreed, and the gnutls*-config scripts are even more deprecated than
the pkg-config approach.  Maybe we should remove them in 1.5.0 to make
sure people stop using them.

/Simon



More information about the Gnutls-dev mailing list