1 # iconv.m4 serial AM4 (gettext-0.11.3)
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.
10 dnl with modifications to support building with in-tree libiconv
12 AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
14 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
15 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
16 AC_REQUIRE([AC_LIB_RPATH])
18 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
20 AC_LIB_LINKFLAGS_BODY([iconv])
23 AC_DEFUN([AM_ICONV_LINK],
25 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
26 dnl those with the standalone portable GNU libiconv installed).
28 dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
30 AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
32 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
33 am_cv_func_iconv="no, consider installing GNU libiconv"
35 dnl Add $INCICONV to CPPFLAGS before performing the first check,
36 dnl because if the user has installed libiconv and not disabled its use
37 dnl via --without-libiconv-prefix, he wants to use it. This first
38 dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
39 am_save_CPPFLAGS="$CPPFLAGS"
40 CPPFLAGS="$CPPFLAGS $INCICONV"
41 AC_TRY_LINK([#include <stdlib.h>
43 [iconv_t cd = iconv_open("","");
44 iconv(cd,NULL,NULL,NULL,NULL);
47 CPPFLAGS="$am_save_CPPFLAGS"
49 if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
50 for _libs in .libs _libs; do
51 am_save_CPPFLAGS="$CPPFLAGS"
53 CPPFLAGS="$CPPFLAGS -I../libiconv/include"
54 LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
55 AC_TRY_LINK([#include <stdlib.h>
57 [iconv_t cd = iconv_open("","");
58 iconv(cd,NULL,NULL,NULL,NULL);
60 INCICONV="-I../libiconv/include"
61 LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a
62 LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
65 CPPFLAGS="$am_save_CPPFLAGS"
67 if test "$am_cv_func_iconv" = "yes"; then
73 if test "$am_cv_func_iconv" != yes; then
74 am_save_CPPFLAGS="$CPPFLAGS"
76 CPPFLAGS="$LIBS $INCICONV"
77 LIBS="$LIBS $LIBICONV"
78 AC_TRY_LINK([#include <stdlib.h>
80 [iconv_t cd = iconv_open("","");
81 iconv(cd,NULL,NULL,NULL,NULL);
85 CPPFLAGS="$am_save_CPPFLAGS"
89 if test "$am_cv_func_iconv" = yes; then
90 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
92 if test "$am_cv_lib_iconv" = yes; then
93 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
94 AC_MSG_CHECKING([how to link with libiconv])
95 AC_MSG_RESULT([$LIBICONV])
107 if test "$am_cv_func_iconv" = yes; then
108 AC_MSG_CHECKING([for iconv declaration])
109 AC_CACHE_VAL(am_cv_proto_iconv, [
117 #if defined(__STDC__) || defined(__cplusplus)
118 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
122 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
123 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);"])
124 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
125 AC_MSG_RESULT([$]{ac_t:-
126 }[$]am_cv_proto_iconv)
127 AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
128 [Define as const if the declaration of iconv() needs const.])