[PATCH] Add pkg-config support
Michael Catanzaro
mcatanzaro at gnome.org
Tue Aug 30 14:00:15 UTC 2016
Hi,
On Tue, 2016-08-30 at 14:02 +0200, Niels Möller wrote:
> 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.
Right... using AC_CHECK_LIB has been considered primitive for a long
time now. I was really surprised to see GMP doesn't already have pkg-
config file. I can't imagine why you wouldn't want to support it, since
it's just one file to install.
I took a quick peek at the documentation format but it doesn't look
straightforward to update, so I won't send a patch for that. You could
include in the documentation something like this:
"Autoconf based applications can easily check whether GMP is installed.
The recommend method is to use pkg-config. For example,
PKG_CHECK_MODULES([GMP], [gmp-6 >= 6.0])
will set GMP_CFLAGS and GMP_LIBS variables to be used in your Automake
files, or fail the build if GMP version 6.0 or higher is not installed.
As with all libraries that use pkg-config, GMP_CFLAGS should be added
to the CPPFLAGS of your Automake target (not to CFLAGS), and GMP_LIBS
should be added to LIBS or LDADD of your target (not to LDFLAGS).
Alternatively, you can use AC_CHECK_LIB. The only thing to be noted...
[the existing documentation would continue here if you want to keep it]
> I find the "-6" odd. By which convention should there be a version
> number in there?
It's optional. One popular convention is that you never break API
without changing the name of the pkg-config file, and adding an API
version there accomplishes that. It's also required if you want it to
be possible to install multiple versions of GMP on the system at the
same time. Otherwise, it's not required; I guess roughly half of
libraries do this. I like it since it's a nice way to ensure
application developers know an API break has occurred, if API breaks
are rare (as they seem to be for GMP).
> 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.
I have no clue!
Michael
More information about the gmp-devel
mailing list