1 dnl Check for iconv support. It may be in libiconv and may be iconv()
5 AC_DEFUN([NMH_CHECK_ICONV],
7 AC_CHECK_HEADER([iconv.h],
8 [AC_CHECK_FUNC([iconv],
9 [dnl This is where iconv is found in the default libraries (LIBS)
11 dnl Handle the case where there is a native iconv but iconv.h is
13 AC_CHECK_DECL([_libiconv_version],
14 [AC_CHECK_LIB([iconv], [libiconv], [LIBS="-liconv $LIBS"])],,
15 [#include <iconv.h>])],
16 [dnl Since we didn't find iconv in LIBS, check libiconv
17 AC_CHECK_LIB([iconv], [iconv], [nmh_found_iconv=yes],
18 [dnl Also check for a function called libiconv()
19 AC_CHECK_LIB([iconv], [libiconv], [nmh_found_iconv=yes])])
20 dnl If either of these tests pass, set ICONVLIB
21 AS_IF([test "x$nmh_found_iconv" = "xyes"], [ICONVLIB="-liconv"])])
22 dnl If we came out of that by finding iconv in some form, define
24 AS_IF([test "x$nmh_found_iconv" = "xyes"],
25 [AC_DEFINE([HAVE_ICONV], [1],
26 [Define if you have the iconv() function.])
28 AC_CACHE_CHECK([for iconv declaration], [nmh_cv_iconv_const],
29 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
34 #if defined(__STDC__) || defined(__cplusplus)
35 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
39 [nmh_cv_iconv_const=],
40 [nmh_cv_iconv_const=const])])
41 AC_DEFINE_UNQUOTED([ICONV_CONST], [$nmh_cv_iconv_const],
42 [Define as const if the declaration of iconv() needs const.])])])
43 AC_SUBST([ICONVLIB])])
44 AC_SUBST([ICONV_ENABLED])