1 dnl -------------------------------------------------------- -*- autoconf -*-
2 dnl Licensed to the Apache Software Foundation (ASF) under one or more
3 dnl contributor license agreements. See the NOTICE file distributed with
4 dnl this work for additional information regarding copyright ownership.
5 dnl The ASF licenses this file to You under the Apache License, Version 2.0
6 dnl (the "License"); you may not use this file except in compliance with
7 dnl the License. You may obtain a copy of the License at
9 dnl http://www.apache.org/licenses/LICENSE-2.0
11 dnl Unless required by applicable law or agreed to in writing, software
12 dnl distributed under the License is distributed on an "AS IS" BASIS,
13 dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 dnl See the License for the specific language governing permissions and
15 dnl limitations under the License.
18 dnl APU_TRY_ICONV[ IF-SUCCESS, IF-FAILURE ]: try to compile for iconv.
20 AC_DEFUN([APU_TRY_ICONV], [
26 iconv_t cd = iconv_open("", "");
27 iconv(cd, NULL, NULL, NULL, NULL);
32 dnl APU_FIND_ICONV: find an iconv library
34 AC_DEFUN([APU_FIND_ICONV], [
36 apu_iconv_dir="unknown"
39 AC_ARG_WITH(iconv,[ --with-iconv[=DIR] path to iconv installation],
40 [ apu_iconv_dir="$withval"
41 if test "$apu_iconv_dir" = "no"; then
45 elif test "$apu_iconv_dir" != "yes"; then
46 if test -f "$apu_iconv_dir/include/apr-1/api_version.h"; then
49 APR_ADDTO(APRUTIL_INCLUDES,[-I$apu_iconv_dir/include/apr-1])
50 APR_ADDTO(APRUTIL_LIBS,[$apu_iconv_dir/lib/libapriconv-1.la])
51 AC_MSG_RESULT(using apr-iconv)
52 elif test -f "$apu_iconv_dir/include/iconv.h"; then
55 APR_ADDTO(CPPFLAGS,[-I$apu_iconv_dir/include])
56 APR_ADDTO(LDFLAGS,[-L$apu_iconv_dir/lib])
61 if test "$want_iconv" = "1" -a "$have_apr_iconv" != "1"; then
62 AC_CHECK_HEADER(iconv.h, [
63 APU_TRY_ICONV([ have_iconv="1" ], [
65 APR_ADDTO(LIBS,[-liconv])
68 APR_ADDTO(APRUTIL_LIBS,[-liconv])
69 APR_ADDTO(APRUTIL_EXPORT_LIBS,[-liconv])
73 APR_REMOVEFROM(LIBS,[-liconv])
76 ], [ have_iconv="0" ])
79 if test "$want_iconv" = "1" -a "$apu_iconv_dir" != "unknown"; then
80 if test "$have_iconv" != "1"; then
81 if test "$have_apr_iconv" != "1"; then
82 AC_MSG_ERROR([iconv support requested, but not found])
85 APR_REMOVEFROM(CPPFLAGS,[-I$apu_iconv_dir/include])
86 APR_REMOVEFROM(LDFLAGS,[-L$apu_iconv_dir/lib])
87 APR_ADDTO(APRUTIL_INCLUDES,[-I$apu_iconv_dir/include])
88 APR_ADDTO(APRUTIL_LDFLAGS,[-L$apu_iconv_dir/lib])
91 if test "$have_iconv" = "1"; then
95 APR_FLAG_HEADERS(iconv.h langinfo.h)
96 APR_FLAG_FUNCS(nl_langinfo)
97 APR_CHECK_DEFINE(CODESET, langinfo.h, [CODESET defined in langinfo.h])
100 AC_SUBST(have_apr_iconv)
104 dnl APU_CHECK_ICONV_INBUF
106 dnl Decide whether or not the inbuf parameter to iconv() is const.
108 dnl We try to compile something without const. If it fails to
109 dnl compile, we assume that the system's iconv() has const.
110 dnl Unfortunately, we won't realize when there was a compile
111 dnl warning, so we allow a variable -- apu_iconv_inbuf_const -- to
112 dnl be set in hints.m4 to specify whether or not iconv() has const
113 dnl on this parameter.
115 AC_DEFUN([APU_CHECK_ICONV_INBUF], [
116 AC_MSG_CHECKING(for type of inbuf parameter to iconv)
117 if test "x$apu_iconv_inbuf_const" = "x"; then
118 APR_TRY_COMPILE_NO_WARNING([
122 iconv(0,(char **)0,(size_t *)0,(char **)0,(size_t *)0);
123 ], apu_iconv_inbuf_const="0", apu_iconv_inbuf_const="1")
125 if test "$apu_iconv_inbuf_const" = "1"; then
126 AC_DEFINE(APU_ICONV_INBUF_CONST, 1, [Define if the inbuf parm to iconv() is const char **])
131 AC_MSG_RESULT([$msg])