]> diplodocus.org Git - nmh/blob - m4/iconv.m4
getpass.c: Move interface to own file.
[nmh] / m4 / iconv.m4
1 dnl Check for iconv support. It may be in libiconv and may be iconv()
2 dnl or libiconv()
3 dnl
4
5 AC_DEFUN([NMH_CHECK_ICONV],
6 [ICONV_ENABLED=0
7 AC_CHECK_HEADER([iconv.h],
8 [AC_CHECK_FUNC([iconv],
9 [dnl This is where iconv is found in the default libraries (LIBS)
10 nmh_found_iconv=yes
11 dnl Handle the case where there is a native iconv but iconv.h is
12 dnl from libiconv
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
23 dnl HAVE_ICONV
24 AS_IF([test "x$nmh_found_iconv" = "xyes"],
25 [AC_DEFINE([HAVE_ICONV], [1],
26 [Define if you have the iconv() function.])
27 ICONV_ENABLED=1
28 AC_CACHE_CHECK([for iconv declaration], [nmh_cv_iconv_const],
29 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
30 #include <iconv.h>]],
31 [[#ifdef __cplusplus
32 "C"
33 #endif
34 #if defined(__STDC__) || defined(__cplusplus)
35 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
36 #else
37 size_t iconv();
38 #endif]])],
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])