From 6b2c5e0ba468079d7cd94f8c7aeede71cd7380b5 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Fri, 16 May 2025 18:03:52 -0600 Subject: [PATCH] autotools: Fix iconv issues in generated .pc file The goal is to make everyone (including msys2) happy. Fixes #1766 and #1819. Signed-off-by: Zhaofeng Li --- configure.ac | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 8713827e8..362553964 100644 --- a/configure.ac +++ b/configure.ac @@ -458,14 +458,17 @@ if test "x$with_iconv" != "xno"; then AC_CHECK_HEADERS([iconv.h],[],[],[#include ]) if test "x$am_cv_func_iconv" = "xyes"; then AC_CHECK_HEADERS([localcharset.h]) - am_save_LIBS="$LIBS" LIBS="${LIBS} ${LIBICONV}" if test -n "$LIBICONV"; then - AC_DEFINE([HAVE_LIBICONV], [1], [Define to 1 if you have the `iconv' library (-liconv).]) - LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv" + AC_DEFINE([HAVE_LIBICONV], [1], [Define to 1 if you have the `iconv' library (-liconv).]) + + # Most platforms do not provide iconv.pc, but MSYS2 MinGW does. + # We add it to our Requires.private only if it exists. + PKG_CHECK_MODULES(ICONV_PC, [iconv], [ + LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv" + ], [true]) fi AC_CHECK_FUNCS([locale_charset]) - LIBS="${am_save_LIBS}" if test "x$ac_cv_func_locale_charset" != "xyes"; then # If locale_charset() is not in libiconv, we have to find libcharset. AC_CHECK_LIB(charset,locale_charset) -- 2.47.2