RFC: PKG_CHECK_MODULES() should honor ${libdir} and ${datadir}

Dan Nicholson dbn.lists at gmail.com
Fri Mar 26 08:43:26 PDT 2010


On Fri, Mar 26, 2010 at 6:37 AM, Benjamin Otte <otte at gnome.org> wrote:
> Hi,
>
> Recently complained[1] on the Cairo mailing list about not being able
> to compile into a custom prefix. It turned out he hadn't yet learned
> about the need to set PKG_CONFIG_PATH when running configure. In the
> discussion following that, someone asked why configure didn't look
> into prefix by default[2], as that seems like a natural thing to do.

Looking at [1], it seems like some of the pain would be alleviated if
the default error messages for PKG_CHECK_MODULES were let through. If
pkg-config wasn't found you get this:

"""
The pkg-config script could not be found or is too old.  Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.

Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

To get pkg-config, see <http://pkg-config.freedesktop.org/>.
"""

Or, if the module wasn't found:

"""
Package requirements ($2) were not met:

$$1_PKG_ERRORS

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
"""

So, there is useful information for the user if you're not overriding it.

> So I'm proposing that the pkg-config autotools macros should add
> ${libdir}/pkgconfig and ${datadir}/pkgconfig to the paths they look in
> for pc files, preferring them to the default paths, but preferring
> user-set environment variables.
>
> This should get rid of the need to set PKG_CONFIG_PATH in a lot of
> cases where people custom-compile software. I suppose jhbuild wouldn't
> need to set it anymore. But most importantly it wouldn't require new
> users who try to setup some libraries for their custom hacking to
> learn about PKG_CONFIG_PATH.

Here are some issues that come to mind.

* Since the primary way people interact with pkg-config is through
PKG_CHECK_MODULES, this would essentially change the default behavior
of pkg-config.

* There are bound to be cases where this isn't the right thing to do,
so you'd probably need a way to opt out. I don't see any easy way to
do that.

* If I'm already setting PKG_CONFIG_PATH because I know what I'm
doing, I'd prefer that it not be mangled behind my back. Others may
feel differently.

* Do we know how this would interact with cross compiling and
PKG_CONFIG_SYSROOT_DIR? I have a feeling that you'd want to append
$sysroot/$libdir/pkgconfig and friends, but I don't know.

--
Dan


More information about the pkg-config mailing list