From man pkg-config
PKG_INSTALLDIR(DIRECTORY)
Substitutes the variable pkgconfigdir as the location where a module should install pkg-config .pc files. By default the
directory is $libdir/pkgconfig, but the default can be changed by passing DIRECTORY. The user can override through the
--with-pkgconfigdir
parameter.
This allows you expose the install-directory of the pkg-config file to the user (and - if your distribution patched pkg-config to use non-standard search-paths, it hopefully will pick the proper default for your system).
Example:
configure.ac:
[...]
PKG_INSTALLDIR
[...]
Makefile.am:
[...]
pkgconfig_DATA = lib1.pc
[...]
Usage
$ ./configure --prefix=/usr --with-pkgconfigdir=/usr/lib64/pkgconfig
Note
Please do not make distro-specific assumptions about where pkg-config
will look for files.
Always use the defaults (they are defaults for good reasons), and provide a way to override these defaults for non-standard systems.
There are a lot distributions out there, and just because in my community one is prevailing, this doesn't mean that this is true for other communities (or not going to change).
If your distro does not follow the standard that's ok, but it should be consistent; if it fails to do be consistent (e.g. pkg-config
looking for files in /foo/baz
, but PKG_INSTALLDIR
expanding pkgconfigdir
to /usr/lib/pkg-config
), then you should report a bug at your distribution.
Also I think it rather weird, that your pkg-config
won't search for files in /usr/local
.
E.g. on my Debian/sid system, it first searches /usr/local
and then /usr
:
$ which pkg-config
/usr/bin/pkg-config
$ strace -e trace=open pkg-config --cflags foo 2>&1 | grep /usr
open("/usr/local/lib/x86_64-linux-gnu/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/share/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/lib/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
open("/usr/share/pkgconfig", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
$