Don't treat spidermonkeydir="" and luadir="" as special.
[elinks.git] / config / m4 / iconv.m4
blob8019f37a34e33f0f83e8574561679856a9b69c3c
1 #serial AM2
3 dnl From Bruno Haible.
5 AC_DEFUN([AM_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).
10   EL_SAVE_FLAGS
12   AC_ARG_WITH([libiconv],
13 [  --with-libiconv=DIR     search for libiconv in DIR/include and DIR/lib], [
14     for dir in `echo "$withval" | tr : ' '`; do
15       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
16       if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
17     done
18    ])
20   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
21     am_cv_func_iconv="no, consider installing GNU libiconv"
22     am_cv_lib_iconv=no
23     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
24 #include <iconv.h>]], [[iconv_t cd = iconv_open("","");
25        iconv(cd,NULL,NULL,NULL,NULL);
26        iconv_close(cd);]])],[am_cv_func_iconv=yes],[])
27     if test "$am_cv_func_iconv" != yes; then
28       am_save_LIBS="$LIBS"
29       LIBS="$LIBS -liconv"
30       AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
31 #include <iconv.h>]], [[iconv_t cd = iconv_open("","");
32          iconv(cd,NULL,NULL,NULL,NULL);
33          iconv_close(cd);]])],[am_cv_lib_iconv=yes
34         am_cv_func_iconv=yes],[])
35       LIBS="$am_save_LIBS"
36     fi
37   ])
38   if test "$am_cv_func_iconv" = yes; then
39     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
40     AC_MSG_CHECKING([for iconv declaration])
41     AC_CACHE_VAL(am_cv_proto_iconv, [
42       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
43 #include <stdlib.h>
44 #include <iconv.h>
45 extern
46 #ifdef __cplusplus
47 "C"
48 #endif
49 #if defined(__STDC__) || defined(__cplusplus)
50 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
51 #else
52 size_t iconv();
53 #endif
54 ]], [[]])],[am_cv_proto_iconv_arg1=""],[am_cv_proto_iconv_arg1="const"])
55       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);"])
56     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
57     AC_MSG_RESULT([$]{ac_t:-
58          }[$]am_cv_proto_iconv)
59     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
60       [Define as const if the declaration of iconv() needs const.])
61   fi
62   LIBICONV=
63   if test "$am_cv_lib_iconv" = yes; then
64     LIBICONV="-liconv"
65   else
66     EL_RESTORE_FLAGS
67   fi