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