Debian Codegraph @

m4/iconv.m4

raw
1 # Configure paths for iconv
2
3 dnl Usage:
4 dnl AC_ICONV(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
5 dnl Test for ares, and defines
6 dnl - ICONV_CFLAGS (compiler flags)
7 dnl - ICONV_LIBS (linker flags, stripping and path)
8 dnl prerequisites:
9
10 AC_DEFUN([AC_ICONV],
11 [
12 dnl check it it is part of the libc
13 AC_CHECK_LIB(c, iconv_open, ac_cv_have_iconv=yes, ac_cv_have_iconv=no)
14
15 ICONV_CFLAGS=
16 ICONV_LIBS=
17 AC_ARG_WITH(iconv, [ --with-iconv=PATH where iconv is installed],
18 [
19 if test x$ac_cv_have_iconv = xno; then
20 ac_iconv_path=
21 case "$with_iconv" in
22 'yes') ac_iconv_path="/usr" ;;
23 'no') ;;
24 *) ac_iconv_path=$with_iconv ;;
25 esac
26 if test -n "$ac_iconv_path"; then
27 ac_save_ICONVLIBS=$LIBS
28 LIBS="-L$ac_iconv_path/lib $LIBS"
29 AC_CHECK_LIB(iconv, iconv_open, ac_cv_have_iconv=yes, [])
30 if test "$ac_cv_have_iconv" = yes; then
31 ICONV_LIBS="-liconv"
32 if test "$ac_iconv_path" != "/usr"; then
33 ICONV_CFLAGS="-I$ac_iconv_path/include"
34 ICONV_LIBS="$ac_iconv_path/lib $ICONV_LIBS"
35 fi
36 fi
37 LIBS=$ac_save_ICONVLIBS
38 fi
39 fi
40 ])
41
42 if test x$ac_cv_have_iconv = xyes ; then
43 AC_MSG_CHECKING([for iconv declaration])
44 AC_CACHE_VAL(ac_cv_proto_iconv,
45 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([
46 #include <stdlib.h>
47 #include <iconv.h>
48 #ifdef __cplusplus
49 extern "C"
50 #endif
51 #if defined(__STDC__) || defined(__cplusplus)
52 size_t iconv(iconv_t cd, char**, size_t*, char**, size_t*);
53 #else
54 size_t iconv();
55 #endif
56 ], []), ac_cv_proto_iconv="", ac_cv_proto_iconv="const")
57 )
58 AC_DEFINE_UNQUOTED(ICONV_CONST_CAST, $ac_cv_proto_iconv, [Use casting for iconv's inputbuffer - don't ask me.])
59 if test "$ac_cv_proto_iconv" = const; then
60 AC_MSG_RESULT([using const])
61 else
62 AC_MSG_RESULT([not using const])
63 fi
64 ifelse([$2], , :, [$2])
65 else
66 ICONV_CFLAGS=""
67 ICONV_LIBS=""
68 ifelse([$3], , :, [$3])
69 fi
70
71 AC_SUBST(ICONV_CFLAGS)
72 AC_SUBST(ICONV_LIBS)
73 ])
74