From: Zhaofeng Li Date: Sat, 17 May 2025 00:03:52 +0000 (-0600) Subject: autotools: Fix iconv issues in generated .pc file X-Git-Tag: v3.8.0~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2611%2Fhead;p=thirdparty%2Flibarchive.git 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 --- 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)