[gnutls-dev] pkg-config file for libgnutls

Andreas Metzler ametzler at downhill.at.eu.org
Sun Feb 18 12:47:13 CET 2007


On 2007-02-16 Simon Josefsson <simon at josefsson.org> wrote:
> Andreas Metzler <ametzler at downhill.at.eu.org> writes:

> > On 2007-02-15 Simon Josefsson <simon at josefsson.org> wrote:
> > [...]
> >> Possibly we could have a 'Requires: libtasn1' line added,
> >
> > It would not be the right thing imho. Afaik Requires is rarely the
> > right thing for dependencies that are libraries (Only if the API
> > of the required library is intentionally exposed by original library.)>

> The GTK people seem to use plenty of Requires:

> jas at mocca:~$ grep '^Requires:' /usr/lib/pkgconfig/gtk+-2.0.pc
> Requires: gdk-${target}-2.0 atk cairo
> jas at mocca:~$ grep '^Requires:' /usr/lib/pkgconfig/atk.pc
> Requires: gobject-2.0 gmodule-no-export-2.0
> jas at mocca:~$ grep '^Requires:' /usr/lib/pkgconfig/gobject-2.0.pc
> Requires: glib-2.0
> jas at mocca:~$ grep '^Requires:' /usr/lib/pkgconfig/gdk-x11-2.0.pc
> Requires: gdk-pixbuf-2.0 pango pangocairo fontconfig x11 xext xrender xinerama xi xrandr xcursor xfixes
> ...

> Which leads to, on my Debian box:

> jas at mocca:~$ pkg-config --libs gtk+-2.0
> -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
> jas at mocca:~$

> Note that even '-lm' and '-lX11' is there.  IIRC, the gtk people
> invented pkg-config, so they should hopefully use the best practice.

Afaik that is because
a) gtk *does* expose and require the atk
(/usr/include/gtk-2.0/gtk/gtkaccessible.h) and cairo
(/usr/include/gtk-2.0/gdk/gdkcairo.h) APIs/headers

and
b) because Requires.private is currently rather useless
http://bugs.debian.org/390132 forcing GNOME to use Requires instead.

gnutls does not expose the tasn API or require its headers, so it does
not need to use Requires.

> >> which I
> >> think would have the effect as you want: 'pkg-config --libs gnutls'
> >> will mention -ltasn1.

> > Well, it shouldn't.

> That statement seem to be in contrast with the example above and also:

> > There are archs that require direct linking of dependent libaries
> > i.e. if your program is using gnutls_init() you'll need to build it by
> > using

> > cc  -L/usr/lib -lgnutls -ltasn1  -lgcrypt -lgpg-error foo.c

> > since libgnutsls itself is linked against libtasn.

> If some archs require that all dependent libraries are mentioned at
> link-time, it seems 'pkg-config --libs gnutls' should mention all of
> the required library.  Just like the 'gtk+-2.0' example above.

> > The point of pkg-config is to centralize the knowledge about archs
> > needing additional linking and which do not, "pkg-config --libs
> > gnutls" will list the additional dependencies (that is the stuff in
> > Libs.private) if it is necessary for that arch and won't do otherwise.

> Oh!  Is this what is happening?  Is pkg-config clever enough to do
> this?

Yes, when building pkg-config itself it queries libtool to check
whether indirect dependencies should be reported on the arch it is
building for. The result is then hardcoded into the pkg-config binary.

> Anyway, I consider pkg-config a poor design since it doesn't use the
> test-for-a-feature-approach.
[...]

I do not disagree. ;-) It is a little bit better still than using a
separate libfoo-config script. ;-)

thanks, cu andreas
-- 
`What a good friend you are to him, Dr. Maturin. His other friends are
so grateful to you.'
`I sew his ears on from time to time, sure'




More information about the Gnutls-devel mailing list