Move struct io's argv and dir members to struct view
[tig.git] / acinclude.m4
blobd3d618f27a0a69ea5971e198facbe0b52182b3c1
1 dnl From Bruno Haible.
2 AC_DEFUN([AM_ICONV],
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
12     done
13    ])
15   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
16     am_cv_func_iconv="no, consider installing GNU libiconv"
17     am_cv_lib_iconv=no
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
23       am_save_LIBS="$LIBS"
24       LIBS="$LIBS -liconv"
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],[])
30       LIBS="$am_save_LIBS"
31     fi
32   ])
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([[
38 #include <stdlib.h>
39 #include <iconv.h>
40 extern
41 #ifdef __cplusplus
42 "C"
43 #endif
44 #if defined(__STDC__) || defined(__cplusplus)
45 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
46 #else
47 size_t iconv();
48 #endif
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.])
56   else
57     AC_MSG_FAILURE([iconv() not found. Please install libiconv and use --with-libiconv=/path/to/dir.],[1])
58   fi
59   if test "$am_cv_lib_iconv" = yes; then
60     LIBS="$LIBS -liconv"
61   fi