+# We can't just use AC_SEARCH_LIBS for this, as on OpenBSD the iconv.h
+# header needs to be included as iconv_open is #define'd to something
+# else. We therefore use our own FP_SEARCH_LIBS_PROTO, which allows us
+# to give prototype text.
+FP_SEARCH_LIBS_PROTO(iconv,
+ [
+#include <stddef.h>
+#include <iconv.h>
+ ],
+ [iconv_t cd;
+ cd = iconv_open("", "");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ iconv,
+ [EXTRA_LIBS="$EXTRA_LIBS $ac_lib"],
+ [case `uname -s` in
+ MINGW*|CYGWIN*) ;;
+ *)
+ AC_MSG_ERROR([iconv is required on non-Windows platforms]);;
+ esac])
+
+# If possible, we use libcharset instead of nl_langinfo(CODESET) to
+# determine the current locale's character encoding.
+FP_SEARCH_LIBS_PROTO(
+ [locale_charset],
+ [#include <libcharset.h>],
+ [const char* charset = locale_charset();],
+ [charset],
+ [AC_DEFINE([HAVE_LIBCHARSET], [1], [Define to 1 if you have libcharset.])
+ EXTRA_LIBS="$EXTRA_LIBS $ac_lib"])