I uploaded a few patches to the pkg-config bugzilla recently, which will hopefully make their way into the next release.
The patch adds a Requires.private field to .pc files that contains a list of required packages like Requires currently does, which has the following properties:
- When verifying that a particular package name is available with “pkg-config --exists“, dependencies in both Requires and Requires.private are checked.
- When running “pkg-config --cflags“, flags from dependencies in Requires are included.
- When running “pkg-config --libs“, flags from dependencies in Requires are included.
- When running “pkg-config --static --libs“, flags from dependencies in both Requires and Requires.private are included.
The purpose of this is to list dependencies that are not exposed in the API of the library in question while not making users of the library link directly to those dependencies. This means that private dependencies can be upgraded to new incompatible versions without breaking applications that only depend on them indirectly.
This is intended for cases like Cairo, which links to libpng, but doesn’t expose any of the libpng API itself. It is not intended for dependencies like gtk+ depending on pango. Of course, this header will cause the .pc file to be incompatible with pkg-config versions prior to 0.16, because those versions don’t tolerate unknown fields.
The other changes are related to the associated autoconf macros:
- Add a PKG_CHECK_EXISTS() macro. This would be similar to PKG_CHECK_MODULES(), except that no variables would be set or substitutes — it would simply run the ACTION-IF-FOUND or ACTION-IF-NOT-FOUND arguments. It is basically a less heavy weight macro for cases where you just want to see if a set of modules is available (bug 3530).
- Get rid of the caching behaviour in PKG_CHECK_MODULES(). Since 0.16, this macro has cached the result of the check based on the variable prefix passed as the first argument. Since pkg-config is quite fast and configure doesn’t store its cache between runs by default, this doesn’t result in any noticable speed improvement and causes build problems for configure scripts that call PKG_CHECK_MODULES multiple times with the same variable name prefix but different package lists (e.g. Eye of Gnome). It seems simplest to just remove the caching, resulting in a simpler and more reliable macro (bug 3550, patch not yet uploaded).
With these changes, hopefully 0.18 will fix up the last few small incompatibilities in the recent releases.