bottleneck testcase based on rubbos
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr-util / build / apu-iconv.m4
1 dnl
2 dnl custom autoconf rules for APRUTIL
3 dnl
4
5 dnl
6 dnl APU_TRY_ICONV[ IF-SUCCESS, IF-FAILURE ]: try to compile for iconv.
7 dnl
8 AC_DEFUN(APU_TRY_ICONV,[
9   AC_TRY_LINK([
10 #include <stdlib.h>
11 #include <iconv.h>
12 ],
13 [
14   iconv_t cd = iconv_open("", "");
15   iconv(cd, NULL, NULL, NULL, NULL);
16 ], [$1], [$2])
17 ])
18
19 dnl
20 dnl APU_FIND_ICONV: find an iconv library
21 dnl
22 AC_DEFUN(APU_FIND_ICONV,[
23
24 apu_iconv_dir="unknown"
25 AC_ARG_WITH(iconv,[  --with-iconv[=DIR]        path to iconv installation],
26   [ apu_iconv_dir="$withval"
27     if test "$apu_iconv_dir" != "yes"; then
28       APR_ADDTO(CPPFLAGS,[-I$apu_iconv_dir/include])
29       APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib])
30     fi
31   ])
32
33 AC_CHECK_HEADER(iconv.h, [
34   APU_TRY_ICONV([ have_iconv="1" ], [
35
36    APR_ADDTO(LIBS,[-liconv])
37
38    APU_TRY_ICONV([
39      APR_ADDTO(APRUTIL_LIBS,[-liconv])
40      APR_ADDTO(APRUTIL_EXPORT_LIBS,[-liconv])
41      have_iconv="1" ],
42      [ have_iconv="0" ])
43
44    APR_REMOVEFROM(LIBS,[-liconv])
45
46  ])
47 ], [ have_iconv="0" ])
48
49 if test "$apu_iconv_dir" != "unknown"; then
50   if test "$have_iconv" != "1"; then
51     AC_MSG_ERROR([iconv support requested, but not found])
52   fi
53   APR_REMOVEFROM(CPPFLAGS,[-I$apu_iconv_dir/include])
54   APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib])
55   APR_ADDTO(APRUTIL_INCLUDES,[-I$apu_iconv_dir/include])
56   APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib])
57 fi
58
59 if test "$have_iconv" = "1"; then
60   APU_CHECK_ICONV_INBUF
61 fi
62
63 APR_FLAG_HEADERS(iconv.h langinfo.h)
64 APR_FLAG_FUNCS(nl_langinfo)
65 APR_CHECK_DEFINE(CODESET, langinfo.h, [CODESET defined in langinfo.h])
66
67 AC_SUBST(have_iconv)
68 ])dnl
69
70 dnl
71 dnl APU_CHECK_ICONV_INBUF
72 dnl
73 dnl  Decide whether or not the inbuf parameter to iconv() is const.
74 dnl
75 dnl  We try to compile something without const.  If it fails to 
76 dnl  compile, we assume that the system's iconv() has const.  
77 dnl  Unfortunately, we won't realize when there was a compile
78 dnl  warning, so we allow a variable -- apu_iconv_inbuf_const -- to
79 dnl  be set in hints.m4 to specify whether or not iconv() has const
80 dnl  on this parameter.
81 dnl
82 AC_DEFUN(APU_CHECK_ICONV_INBUF,[
83 AC_MSG_CHECKING(for type of inbuf parameter to iconv)
84 if test "x$apu_iconv_inbuf_const" = "x"; then
85     APR_TRY_COMPILE_NO_WARNING([
86     #include <stddef.h>
87     #include <iconv.h>
88     ],[
89     iconv(0,(char **)0,(size_t *)0,(char **)0,(size_t *)0);
90     ], apu_iconv_inbuf_const="0", apu_iconv_inbuf_const="1")
91 fi
92 if test "$apu_iconv_inbuf_const" = "1"; then
93     AC_DEFINE(APU_ICONV_INBUF_CONST, 1, [Define if the inbuf parm to iconv() is const char **])
94     msg="const char **"
95 else
96     msg="char **"
97 fi
98 AC_MSG_RESULT([$msg])
99 ])dnl