4 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
5 dnl those with the standalone portable GNU libiconv installed).
7 AC_ARG_WITH([libiconv],
8 [ --with-libiconv=DIR search for libiconv in DIR/include and DIR/lib], [
9 for dir in `echo "$withval" | tr : ' '`; do
10 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
11 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
15 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
16 am_cv_func_iconv="no, consider installing GNU libiconv"
18 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
19 #include <iconv.h>]], [[iconv_t cd = iconv_open("","");
20 iconv(cd,NULL,NULL,NULL,NULL);
21 iconv_close(cd);]])],[am_cv_func_iconv=yes],[])
22 if test "$am_cv_func_iconv" != yes; then
25 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
26 #include <iconv.h>]], [[iconv_t cd = iconv_open("","");
27 iconv(cd,NULL,NULL,NULL,NULL);
28 iconv_close(cd);]])],[am_cv_lib_iconv=yes
29 am_cv_func_iconv=yes],[])
33 if test "$am_cv_func_iconv" = yes; then
34 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
35 AC_MSG_CHECKING([for iconv declaration])
36 AC_CACHE_VAL(am_cv_proto_iconv, [
37 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
44 #if defined(__STDC__) || defined(__cplusplus)
45 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
49 ]], [[]])],[am_cv_proto_iconv_arg1=""],[am_cv_proto_iconv_arg1="const"])
50 am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
51 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
52 AC_MSG_RESULT([$]{ac_t:-
53 }[$]am_cv_proto_iconv)
54 AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
55 [Define as const if the declaration of iconv() needs const.])
57 AC_MSG_FAILURE([iconv() not found. Please install libiconv and use --with-libiconv=/path/to/dir.],[1])
59 if test "$am_cv_lib_iconv" = yes; then