]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
autotools: Fix iconv issues in generated .pc file 2611/head
authorZhaofeng Li <hello@zhaofeng.li>
Sat, 17 May 2025 00:03:52 +0000 (18:03 -0600)
committerZhaofeng Li <hello@zhaofeng.li>
Sat, 17 May 2025 19:50:16 +0000 (13:50 -0600)
The goal is to make everyone (including msys2) happy.

Fixes #1766 and #1819.

Signed-off-by: Zhaofeng Li <hello@zhaofeng.li>
configure.ac

index 8713827e891ad1688ce10db400e04c1c0f8f7a16..362553964f978cb46f5aea2946697cc724e653df 100644 (file)
@@ -458,14 +458,17 @@ if test "x$with_iconv" != "xno"; then
   AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
   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)