But this isn't the case depending on the .pc file. It's possible that --cflags fails and --libs succeeds, but as the error value is only checked after --libs pkg.m4 believes that the calls succeeded. This results in the _CFLAGS variable being empty, leading to confused looks and scratched heads.
PKG_CHECK_MODULES calls _PKG_CONFIG for both --cflags and --libs, which calls PKG_CHECK_EXISTS. What's supposed to happen is that --exists exits if package requirements for --cflags or --libs can't be met. Unfortunately, there was a bug where --exists was ignoring Requires completely. See bug 43149. What version of pkg-config are you using? That bug should be fixed in 0.28. Still, whether it's that bug or something else, the right thing to do is have PKG_CHECK_MODULES check status after each call to _PKG_CONFIG.
Turns out we're running a relatively old pkgconfig 0.25.
Created attachment 79489 [details] [review] [PATCH] Error from PKG_CHECK_MODULES if either --cflags or --libs fails Older pkg-config (versions 0.24-0.26) had a bug where --exists failed to honor Requires. See commit 3ead3dfb. This means that some versions can fail --cflags but pass --libs. Ensure that PKG_CHECK_MODULES will return an error if either fails. Freedesktop #64674 (https://bugs.freedesktop.org/show_bug.cgi?id=64674) --- pkg.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
I think this patch should fix things. Can you check? Unfortunately, it still leaves you in the position that you have to update pkg-config or autoreconf every package. By the way, the fix went into pkg-config-0.27, not 0.28. I've put a lot of effort into beefing up the test suite to make sure there are no regressions, so I think you'd be pretty safe if you want to upgrade.
Actually, I think this was already fixed some time ago and you're just being hit with old pkg.m4. Commit 4366f58 fixing bug 36039 is in pkg-config-0.26 and newer. This should make any failures in the --exists/--cflags/--libs chain error out. Maybe you can grab a newer pkg.m4 or just try to patch yours with this: http://cgit.freedesktop.org/pkg-config/commit/?id=4366f58 I tried to reproduce this with pkg-config-0.25 and found that patch prevented it. I'm going to close this, but reopen if that doesn't fix things for you. *** This bug has been marked as a duplicate of bug 36039 ***
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.