Regenerated with autoconf-2.52.
[libiconv.git] / extras / iconv.m4
blobe6ddea7859833e6438b555a36b13bf16c6018b48
1 #serial 3
3 dnl From Bruno Haible.
5 AC_DEFUN(jm_ICONV,
7   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
8   dnl those with the standalone portable GNU libiconv installed).
9   AC_CACHE_CHECK(for iconv, jm_cv_func_iconv, [
10     jm_cv_func_iconv="no, consider installing GNU libiconv"
11     jm_cv_lib_iconv=no
12     AC_TRY_LINK([#include <stdlib.h>
13 #include <iconv.h>],
14       [iconv_t cd = iconv_open("","");
15        iconv(cd,NULL,NULL,NULL,NULL);
16        iconv_close(cd);],
17       jm_cv_func_iconv=yes)
18     if test "$jm_cv_func_iconv" != yes; then
19       jm_save_LIBS="$LIBS"
20       LIBS="$LIBS -liconv"
21       AC_TRY_LINK([#include <stdlib.h>
22 #include <iconv.h>],
23         [iconv_t cd = iconv_open("","");
24          iconv(cd,NULL,NULL,NULL,NULL);
25          iconv_close(cd);],
26         jm_cv_lib_iconv=yes
27         jm_cv_func_iconv=yes)
28       LIBS="$jm_save_LIBS"
29     fi
30   ])
31   if test "$jm_cv_func_iconv" = yes; then
32     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
33     AC_MSG_CHECKING([for iconv declaration])
34     AC_CACHE_VAL(jm_cv_proto_iconv, [
35       AC_TRY_COMPILE([
36 #include <stdlib.h>
37 #include <iconv.h>
38 extern
39 #ifdef __cplusplus
40 "C"
41 #endif
42 #if defined(__STDC__) || defined(__cplusplus)
43 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
44 #else
45 size_t iconv();
46 #endif
47 ], [], jm_cv_proto_iconv_arg1="", jm_cv_proto_iconv_arg1="const")
48       jm_cv_proto_iconv="extern size_t iconv (iconv_t cd, $jm_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
49     jm_cv_proto_iconv=`echo "[$]jm_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
50     AC_MSG_RESULT([$]{ac_t:-
51          }[$]jm_cv_proto_iconv)
52     AC_DEFINE_UNQUOTED(ICONV_CONST, $jm_cv_proto_iconv_arg1,
53       [Define as const if the declaration of iconv() needs const.])
54   fi
55   LIBICONV=
56   if test "$jm_cv_lib_iconv" = yes; then
57     LIBICONV="-liconv"
58   fi
59   AC_SUBST(LIBICONV)