pkg-config m4 macros treat empty FOO_CFLAGS, FOO_LIBS as unset
Submitted by Simon McVittie
Assigned to pkg..@..op.org
Link to original bug (#102622)
Description
The recommended way to deal with libraries that might not have working .pc metadata appears to be this:
[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.])
and in the development branch of dbus, we've documented EXPAT_CFLAGS and EXPAT_LIBS as the way to avoid relying on pkg-config metadata for archaic or wrongly-installed versions of Expat (which seems to include SuSE's mingw32-expat, Bug #102613).
However, in a cross-compilation environment with a pre-configured cross-compiler, it's entirely possible that EXPAT_CFLAGS can legitimately be empty: for example, on Bug #102613, <expat.h> appears to already be on the cross-compiler's default search path, so no extra -I flag should be required.
The pkg-config macro ends up doing this:
m4_define([PKG_CONFIG], [if test -n "$$1"; then pkg_cv[]
1="
$1" elif test -n "$PKG_CONFIG"; then ... rely on pkg-config ...
This means that if $1 (in this case EXPAT_CFLAGS) is set, but to an empty value, then we require .pc metadata.
Perhaps the macro should have this pseudo-patch:
m4_define([PKG_CONFIG],
-[if test -n "$$1"; then
+[if test -n "${$1+set}"; then
pkg_cv[]1="
$1"
so that the decision is really between set vs. unset, rather than between (set && non-empty) vs. (unset || empty).