From 778c397d488c0b6ec5db1f9a1aff4d4dc090dbd3 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Fri, 6 May 2016 23:33:04 -0700 Subject: [PATCH] Update 'configure' for libiconv detection; only set HAVE_ICONV_H if header exists *and* an impl we can link with exists. --- configure | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++- configure.in | 7 +++- 2 files changed, 118 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 7136552..3777049 100755 --- a/configure +++ b/configure @@ -5308,7 +5308,7 @@ fi done -for ac_header in unistd.h syslog.h iconv.h langinfo.h sys/statfs.h +for ac_header in unistd.h syslog.h langinfo.h sys/statfs.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -6103,6 +6103,118 @@ fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv in -lc" >&5 +$as_echo_n "checking for iconv in -lc... " >&6; } +if ${ac_cv_lib_c_iconv+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lc $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char iconv (); +int +main () +{ +return iconv (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_c_iconv=yes +else + ac_cv_lib_c_iconv=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_iconv" >&5 +$as_echo "$ac_cv_lib_c_iconv" >&6; } +if test "x$ac_cv_lib_c_iconv" = xyes; then : + + for ac_header in iconv.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default" +if test "x$ac_cv_header_iconv_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ICONV_H 1 +_ACEOF + +fi + +done + + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv in -liconv" >&5 +$as_echo_n "checking for iconv in -liconv... " >&6; } +if ${ac_cv_lib_iconv_iconv+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-liconv $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char iconv (); +int +main () +{ +return iconv (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_iconv_iconv=yes +else + ac_cv_lib_iconv_iconv=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_iconv" >&5 +$as_echo "$ac_cv_lib_iconv_iconv" >&6; } +if test "x$ac_cv_lib_iconv_iconv" = xyes; then : + + LIBS="-liconv $LIBS" + for ac_header in iconv.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default" +if test "x$ac_cv_header_iconv_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_ICONV_H 1 +_ACEOF + +fi + +done + + +else + : +fi + +fi + + ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' diff --git a/configure.in b/configure.in index b56ce9d..18e5990 100644 --- a/configure.in +++ b/configure.in @@ -64,7 +64,7 @@ AC_CHECK_HEADERS(sys/mount.h,,, #endif ]]) AC_CHECK_HEADERS(sys/ustat.h sys/sysmacros.h sys/syslog.h) -AC_CHECK_HEADERS(unistd.h syslog.h iconv.h langinfo.h sys/statfs.h) +AC_CHECK_HEADERS(unistd.h syslog.h langinfo.h sys/statfs.h) AC_CHECK_HEADERS(signum.h bits/signum.h, break ) AC_CHECK_HEADERS(stdarg.h varargs.h, break ) @@ -128,9 +128,12 @@ AC_CHECK_LIB(c, gethostbyname, [:], [ ]) ]) dnl iconv? check the usual locations -AC_CHECK_LIB(c, iconv, [:], [ +AC_CHECK_LIB(c, iconv, [ + AC_CHECK_HEADERS(iconv.h) + ], [ AC_CHECK_LIB(iconv, iconv, [ LIBS="-liconv $LIBS" + AC_CHECK_HEADERS(iconv.h) ], [:]) ]) dnl check for stl library