configure: Simplify iconv linking logic

This commit is contained in:
Jookia 2022-09-09 11:09:29 +10:00 committed by 宋文武
parent c365baae63
commit 166997aa84

View File

@ -644,15 +644,7 @@ AC_CHECK_HEADER(slirp/libslirp.h,have_slirp_h=yes,)
AC_CHECK_LIB(slirp, slirp_input, have_slirp_lib=yes, ,-lz) AC_CHECK_LIB(slirp, slirp_input, have_slirp_lib=yes, ,-lz)
dnl LIBRARY TEST: libiconv dnl LIBRARY TEST: libiconv
dnl This may be provided by libc itself, -liconv may not be needed.
AC_CHECK_HEADER(iconv.h,have_iconv_h=yes,) AC_CHECK_HEADER(iconv.h,have_iconv_h=yes,)
AC_CHECK_LIB(iconv, libiconv_open, have_iconv_lib=yes, ,-liconv)
case "$host" in
*-*-openbsd*)
LIBS="$LIBS -liconv"
;;
esac
dnl TEST: check if iconv uses const char dnl TEST: check if iconv uses const char
AC_MSG_CHECKING([whether iconv uses const char**]) AC_MSG_CHECKING([whether iconv uses const char**])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
@ -1062,23 +1054,15 @@ if test x$enable_libslirp = xyes ; then
LIBS="$LIBS "`pkg-config slirp --libs` LIBS="$LIBS "`pkg-config slirp --libs`
CFLAGS="$CFLAGS "`pkg-config slirp --cflags` CFLAGS="$CFLAGS "`pkg-config slirp --cflags`
CPPFLAGS="$CPPFLAGS "`pkg-config slirp --cflags` CPPFLAGS="$CPPFLAGS "`pkg-config slirp --cflags`
case "$host" in
*-*-cygwin* | *-*-mingw32*)
LIBS="$LIBS -lintl"
;;
esac
else else
have_slirp=no have_slirp=no
AC_MSG_WARN([Can't find libslirp, userspace TCP/IP emulation disabled]) AC_MSG_WARN([Can't find libslirp, userspace TCP/IP emulation disabled])
fi fi
case "$host" in
*-*-cygwin* | *-*-mingw32*)
if test x$have_slirp = xyes; then
LIBS="$LIBS -lintl -liconv"
fi
;;
esac
else
case "$host" in
*-*-cygwin* | *-*-mingw32*)
LIBS="$LIBS -liconv"
;;
esac
fi fi
if test x$enable_x11 != xno; then if test x$enable_x11 != xno; then
@ -1194,16 +1178,13 @@ AM_CONDITIONAL(C_DIRECT3D, test x"$do_d3d" = x"1")
AH_TEMPLATE(C_ICONV,[Define to 1 to use iconv]) AH_TEMPLATE(C_ICONV,[Define to 1 to use iconv])
if test x$have_iconv_h = xyes; then if test x$have_iconv_h = xyes; then
AC_DEFINE(C_ICONV,1) AC_DEFINE(C_ICONV,1)
case "$host" in AC_MSG_CHECKING([whether we must link against -liconv])
*-*-darwin*) AC_LINK_IFELSE([AC_LANG_PROGRAM([[
LIBS="$LIBS -liconv" #include <iconv.h>
;; iconv_t wrap_open(const char *tocode, const char *fromcode) {
*-*-cygwin* | *-*-mingw32*) return iconv_open(tocode, fromcode);
if test x$have_slirp = xno; then }]])],
LIBS="$LIBS -liconv" AC_MSG_RESULT(no), [AC_MSG_RESULT(yes);LIBS="$LIBS -liconv"])
fi
;;
esac
fi fi
dnl placeholder dnl placeholder