From d6ddfe87e1e75fc26cb50e2e8be215443460d444 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 30 Nov 2022 02:18:38 +0100 Subject: [PATCH] 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. --- configure | 20 ++++++++++++++++++++ configure.in | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/configure b/configure index f35f16bc12..0113ad1754 100755 --- a/configure +++ b/configure @@ -25051,6 +25051,26 @@ $as_echo "no" >&6; } 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 diff --git a/configure.in b/configure.in index 5e3a8cd147..e5daa36694 100644 --- a/configure.in +++ b/configure.in @@ -2093,6 +2093,39 @@ fi dnl Find pkg-config outside of any conditional. Done before any PKG_* call. 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 Optional libraries dnl