1 |
330 |
jeremybenn |
# 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.
|
8 |
|
|
|
9 |
|
|
dnl From Bruno Haible.
|
10 |
|
|
|
11 |
|
|
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
|
12 |
|
|
[
|
13 |
|
|
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
|
14 |
|
|
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
15 |
|
|
AC_REQUIRE([AC_LIB_RPATH])
|
16 |
|
|
|
17 |
|
|
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
|
18 |
|
|
dnl accordingly.
|
19 |
|
|
AC_LIB_LINKFLAGS_BODY([iconv])
|
20 |
|
|
])
|
21 |
|
|
|
22 |
|
|
AC_DEFUN([AM_ICONV_LINK],
|
23 |
|
|
[
|
24 |
|
|
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
|
25 |
|
|
dnl those with the standalone portable GNU libiconv installed).
|
26 |
|
|
|
27 |
|
|
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
|
28 |
|
|
dnl accordingly.
|
29 |
|
|
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
|
30 |
|
|
|
31 |
|
|
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
|
32 |
|
|
dnl because if the user has installed libiconv and not disabled its use
|
33 |
|
|
dnl via --without-libiconv-prefix, he wants to use it. The first
|
34 |
|
|
dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
|
35 |
|
|
am_save_CPPFLAGS="$CPPFLAGS"
|
36 |
|
|
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
|
37 |
|
|
|
38 |
|
|
AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
|
39 |
|
|
am_cv_func_iconv="no, consider installing GNU libiconv"
|
40 |
|
|
am_cv_lib_iconv=no
|
41 |
|
|
AC_TRY_LINK([#include <stdlib.h>
|
42 |
|
|
#include <iconv.h>],
|
43 |
|
|
[iconv_t cd = iconv_open("","");
|
44 |
|
|
iconv(cd,NULL,NULL,NULL,NULL);
|
45 |
|
|
iconv_close(cd);],
|
46 |
|
|
am_cv_func_iconv=yes)
|
47 |
|
|
if test "$am_cv_func_iconv" != yes; then
|
48 |
|
|
am_save_LIBS="$LIBS"
|
49 |
|
|
LIBS="$LIBS $LIBICONV"
|
50 |
|
|
AC_TRY_LINK([#include <stdlib.h>
|
51 |
|
|
#include <iconv.h>],
|
52 |
|
|
[iconv_t cd = iconv_open("","");
|
53 |
|
|
iconv(cd,NULL,NULL,NULL,NULL);
|
54 |
|
|
iconv_close(cd);],
|
55 |
|
|
am_cv_lib_iconv=yes
|
56 |
|
|
am_cv_func_iconv=yes)
|
57 |
|
|
LIBS="$am_save_LIBS"
|
58 |
|
|
fi
|
59 |
|
|
])
|
60 |
|
|
if test "$am_cv_func_iconv" = yes; then
|
61 |
|
|
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
|
62 |
|
|
fi
|
63 |
|
|
if test "$am_cv_lib_iconv" = yes; then
|
64 |
|
|
AC_MSG_CHECKING([how to link with libiconv])
|
65 |
|
|
AC_MSG_RESULT([$LIBICONV])
|
66 |
|
|
else
|
67 |
|
|
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
|
68 |
|
|
dnl either.
|
69 |
|
|
CPPFLAGS="$am_save_CPPFLAGS"
|
70 |
|
|
LIBICONV=
|
71 |
|
|
LTLIBICONV=
|
72 |
|
|
fi
|
73 |
|
|
AC_SUBST(LIBICONV)
|
74 |
|
|
AC_SUBST(LTLIBICONV)
|
75 |
|
|
])
|
76 |
|
|
|
77 |
|
|
AC_DEFUN([AM_ICONV],
|
78 |
|
|
[
|
79 |
|
|
AM_ICONV_LINK
|
80 |
|
|
if test "$am_cv_func_iconv" = yes; then
|
81 |
|
|
AC_MSG_CHECKING([for iconv declaration])
|
82 |
|
|
AC_CACHE_VAL(am_cv_proto_iconv, [
|
83 |
|
|
AC_TRY_COMPILE([
|
84 |
|
|
#include <stdlib.h>
|
85 |
|
|
#include <iconv.h>
|
86 |
|
|
extern
|
87 |
|
|
#ifdef __cplusplus
|
88 |
|
|
"C"
|
89 |
|
|
#endif
|
90 |
|
|
#if defined(__STDC__) || defined(__cplusplus)
|
91 |
|
|
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
|
92 |
|
|
#else
|
93 |
|
|
size_t iconv();
|
94 |
|
|
#endif
|
95 |
|
|
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
|
96 |
|
|
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);"])
|
97 |
|
|
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
|
98 |
|
|
AC_MSG_RESULT([$]{ac_t:-
|
99 |
|
|
}[$]am_cv_proto_iconv)
|
100 |
|
|
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
|
101 |
|
|
[Define as const if the declaration of iconv() needs const.])
|
102 |
|
|
fi
|
103 |
|
|
])
|