+dnl ***********************
+dnl *** Tests for iconv ***
+dnl ***********************
+dnl
+dnl We do this before the gettext checks, to avoid distortion
+
+AC_ARG_WITH(libiconv, [ --with-libiconv=[no/gnu/native] use the libiconv library ],,with_libiconv=maybe)
+
+found_iconv=no
+case $with_libiconv in
+ maybe)
+ # Check in the C library first
+ AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
+ # Check if we have GNU libiconv
+ if test $found_iconv = "no"; then
+ AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
+ fi
+ # Check if we have a iconv in -liconv, possibly from vendor
+ if test $found_iconv = "no"; then
+ AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
+ fi
+ ;;
+ no)
+ AC_CHECK_FUNC(iconv_open, with_libiconv=no; found_iconv=yes)
+ ;;
+ gnu|yes)
+ AC_CHECK_LIB(iconv, libiconv_open, with_libiconv=gnu; found_iconv=yes)
+ ;;
+ native)
+ AC_CHECK_LIB(iconv, iconv_open, with_libiconv=native; found_iconv=yes)
+ ;;
+esac
+
+if test "x$found_iconv" = "xno" ; then
+ AC_MSG_ERROR([*** No iconv() implementation found in C library or libiconv])
+fi
+