[PATCH] Add pkg-config support

Niels Möller nisse at lysator.liu.se
Tue Aug 30 12:02:00 UTC 2016


Michael Catanzaro <mcatanzaro at gnome.org> writes:

> It would be desirable for gmp to install a pkg-config file. This makes
> it much easier for other projects to link to gmp, especially projects
> that use Autotools build systems.

The GMP manual includes the recommended autoconf check. See
https://gmplib.org/manual/Autoconf.html#index-Autoconf. If we want to
support, or even encourage, pkg-config, this should be documented.

> diff -r 31d28753a4e1 -r 95850e2b3e2e Makefile.am
> --- a/Makefile.am	Thu Jun 02 15:34:47 2016 +0200
> +++ b/Makefile.am	Mon Aug 29 08:33:58 2016 -0500
> @@ -113,6 +113,8 @@
>  EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf \
>  	     COPYING.LESSERv3 COPYINGv2 COPYINGv3
>  
> +pkgconfigdir = $(libdir)/pkgconfig
> +pkgconfig_DATA = gmp-6.pc

I find the "-6" odd. By which convention should there be a version
number in there?

> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/gmp-6.pc.in	Mon Aug 29 08:33:58 2016 -0500
> @@ -0,0 +1,11 @@
> +prefix=@prefix@
> +exec_prefix=@exec_prefix@
> +libdir=@libdir@
> +includedir=@includedir@
> +
> +Name: gmp
> +Description: A free library for arbitrary precision arithmetic
> +URL: https://gmplib.org/
> +Version: @VERSION@
> +Libs: -L${libdir} -lgmp
> +Cflags: -I${includedir}

A curious question: If and how does the pkg-config machinery add linker
flags like -R or -Wl,-rpath, ? These are needed if using shared
libraries installed in some location not included in the default ld.so
search path. E.g., say I configure gmp with --prefix=/pkg/gmp/6.1.1/x86_64,
without adding the corresponding lib directory to /etc/ld.so.conf or
similar.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list