1 # iconv.m4 serial AM3 (gettext-0.11)
2 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License. As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
11 AC_DEFUN([AM_ICONV_LINK],
13 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
14 dnl those with the standalone portable GNU libiconv installed).
16 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
17 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
18 AC_REQUIRE([AC_LIB_RPATH])
20 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
22 AC_LIB_LINKFLAGS_BODY([iconv])
24 dnl Add $INCICONV to CPPFLAGS before performing the following checks,
25 dnl because if the user has installed libiconv and not disabled its use
26 dnl via --without-libiconv-prefix, he wants to use it. The first
27 dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
28 am_save_CPPFLAGS="$CPPFLAGS"
29 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
31 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
32 am_cv_func_iconv="no, consider installing GNU libiconv"
34 AC_TRY_LINK([#include <stdlib.h>
36 [iconv_t cd = iconv_open("","");
37 iconv(cd,NULL,NULL,NULL,NULL);
40 if test "$am_cv_func_iconv" != yes; then
42 LIBS="$LIBS $LIBICONV"
43 AC_TRY_LINK([#include <stdlib.h>
45 [iconv_t cd = iconv_open("","");
46 iconv(cd,NULL,NULL,NULL,NULL);
53 if test "$am_cv_func_iconv" = yes; then
54 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
56 if test "$am_cv_lib_iconv" = yes; then
57 AC_MSG_CHECKING([how to link with libiconv])
58 AC_MSG_RESULT([$LIBICONV])
60 dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
62 CPPFLAGS="$am_save_CPPFLAGS"
72 AC_REQUIRE([AM_ICONV_LINK])
73 if test "$am_cv_func_iconv" = yes; then
74 AC_MSG_CHECKING([for iconv declaration])
75 AC_CACHE_VAL(am_cv_proto_iconv, [
83 #if defined(__STDC__) || defined(__cplusplus)
84 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
88 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
89 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);"])
90 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
91 AC_MSG_RESULT([$]{ac_t:-
92 }[$]am_cv_proto_iconv)
93 AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
94 [Define as const if the declaration of iconv() needs const.])