Disable build system pkg-config when cross-compiling to non-Linux

This restores a modified form of the original commit 893ebbab0c (Disable
use of build system pkg-config files when cross-compiling, 2020-12-13),
thus mostly reverting 6dbf59f34f (Revert "Disable use of build system
pkg-config files when cross-compiling", 2022-10-25) and now disables the
use of build system pkg-config files only when cross-compiling for
non-Linux hosts.

This seems like the best behaviour by default because it avoids
unexpected problems when cross-compiling for MSW or iOS where build
system .pc files should never be used, but still uses these files, if
they are available, when cross-compiling for other Linux systems.

This is Linux-specific currently but should probably be extended to
other Unix systems too. In any case, the default behaviour can always be
overridden by setting PKG_CONFIG_LIBDIR manually.

See #22886.
This commit is contained in:
Vadim Zeitlin 2022-11-30 02:18:38 +01:00
parent 48d226bb84
commit d6ddfe87e1
2 changed files with 53 additions and 0 deletions

20
configure vendored
View file

@ -25051,6 +25051,26 @@ $as_echo "no" >&6; }
fi fi
if test "$build" != "$host"; then
case "${host}" in
*-linux-*)
;;
*)
disable_build_system_pkg_config=1
;;
esac
fi
if test "$disable_build_system_pkg_config" = 1; then
if test -z "$PKG_CONFIG_LIBDIR"; then
PKG_CONFIG_LIBDIR=/dev/null
export PKG_CONFIG_LIBDIR
fi
fi
if test "$wxUSE_REGEX" != "no"; then if test "$wxUSE_REGEX" != "no"; then

View file

@ -2093,6 +2093,39 @@ fi
dnl Find pkg-config outside of any conditional. Done before any PKG_* call. dnl Find pkg-config outside of any conditional. Done before any PKG_* call.
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
dnl When cross-compiling for another system from Linux, don't use .pc files on
dnl the build system, they are at best useless and can be harmful (e.g. they
dnl may define options inappropriate for the cross-build, resulting in the
dnl failure of all the subsequent tests).
dnl
dnl Note that we only do it in this particular case because in other cases we
dnl may want to use .pc files on the build system, e.g. it's common to have
dnl them when cross-compiling from x86_64 Linux to ARM Linux.
if test "$build" != "$host"; then
case "${host}" in
*-linux-*)
;;
*)
disable_build_system_pkg_config=1
;;
esac
fi
if test "$disable_build_system_pkg_config" = 1; then
dnl pkg.m4 forbids the use of PKG_XXX, so undo it here to avoid autoconf
dnl errors.
m4_pattern_allow([PKG_CONFIG_LIBDIR])
dnl If pkg-config libdir is already defined, we suppose that they know what
dnl they're doing and leave it alone, but if not, set it to a path in which
dnl no .pc files will be found.
if test -z "$PKG_CONFIG_LIBDIR"; then
PKG_CONFIG_LIBDIR=/dev/null
export PKG_CONFIG_LIBDIR
fi
fi
dnl --------------------------------------------------------------------------- dnl ---------------------------------------------------------------------------
dnl Optional libraries dnl Optional libraries
dnl dnl