| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], |
|---|
| 10 |
[ |
|---|
| 11 |
|
|---|
| 12 |
AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) |
|---|
| 13 |
AC_REQUIRE([AC_LIB_RPATH]) |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
AC_LIB_LINKFLAGS_BODY([iconv]) |
|---|
| 18 |
]) |
|---|
| 19 |
|
|---|
| 20 |
AC_DEFUN([AM_ICONV_LINK], |
|---|
| 21 |
[ |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
am_save_CPPFLAGS="$CPPFLAGS" |
|---|
| 35 |
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) |
|---|
| 36 |
|
|---|
| 37 |
AC_CACHE_CHECK([for iconv], am_cv_func_iconv, [ |
|---|
| 38 |
am_cv_func_iconv="no, consider installing GNU libiconv" |
|---|
| 39 |
am_cv_lib_iconv=no |
|---|
| 40 |
AC_TRY_LINK([ |
|---|
| 41 |
|
|---|
| 42 |
[iconv_t cd = iconv_open("",""); |
|---|
| 43 |
iconv(cd,NULL,NULL,NULL,NULL); |
|---|
| 44 |
iconv_close(cd);], |
|---|
| 45 |
am_cv_func_iconv=yes) |
|---|
| 46 |
if test "$am_cv_func_iconv" != yes; then |
|---|
| 47 |
am_save_LIBS="$LIBS" |
|---|
| 48 |
LIBS="$LIBS $LIBICONV" |
|---|
| 49 |
AC_TRY_LINK([ |
|---|
| 50 |
|
|---|
| 51 |
[iconv_t cd = iconv_open("",""); |
|---|
| 52 |
iconv(cd,NULL,NULL,NULL,NULL); |
|---|
| 53 |
iconv_close(cd);], |
|---|
| 54 |
am_cv_lib_iconv=yes |
|---|
| 55 |
am_cv_func_iconv=yes) |
|---|
| 56 |
LIBS="$am_save_LIBS" |
|---|
| 57 |
fi |
|---|
| 58 |
]) |
|---|
| 59 |
if test "$am_cv_func_iconv" = yes; then |
|---|
| 60 |
AC_CACHE_CHECK([for working iconv], am_cv_func_iconv_works, [ |
|---|
| 61 |
|
|---|
| 62 |
am_save_LIBS="$LIBS" |
|---|
| 63 |
if test $am_cv_lib_iconv = yes; then |
|---|
| 64 |
LIBS="$LIBS $LIBICONV" |
|---|
| 65 |
fi |
|---|
| 66 |
AC_TRY_RUN([ |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
int main () |
|---|
| 70 |
{ |
|---|
| 71 |
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful |
|---|
| 72 |
returns. */ |
|---|
| 73 |
{ |
|---|
| 74 |
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); |
|---|
| 75 |
if (cd_utf8_to_88591 != (iconv_t)(-1)) |
|---|
| 76 |
{ |
|---|
| 77 |
static const char input[] = "\342\202\254"; /* EURO SIGN */ |
|---|
| 78 |
char buf[10]; |
|---|
| 79 |
const char *inptr = input; |
|---|
| 80 |
size_t inbytesleft = strlen (input); |
|---|
| 81 |
char *outptr = buf; |
|---|
| 82 |
size_t outbytesleft = sizeof (buf); |
|---|
| 83 |
size_t res = iconv (cd_utf8_to_88591, |
|---|
| 84 |
(char **) &inptr, &inbytesleft, |
|---|
| 85 |
&outptr, &outbytesleft); |
|---|
| 86 |
if (res == 0) |
|---|
| 87 |
return 1; |
|---|
| 88 |
} |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ |
|---|
| 92 |
{ |
|---|
| 93 |
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); |
|---|
| 94 |
if (cd_88591_to_utf8 != (iconv_t)(-1)) |
|---|
| 95 |
{ |
|---|
| 96 |
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; |
|---|
| 97 |
char buf[50]; |
|---|
| 98 |
const char *inptr = input; |
|---|
| 99 |
size_t inbytesleft = strlen (input); |
|---|
| 100 |
char *outptr = buf; |
|---|
| 101 |
size_t outbytesleft = sizeof (buf); |
|---|
| 102 |
size_t res = iconv (cd_88591_to_utf8, |
|---|
| 103 |
(char **) &inptr, &inbytesleft, |
|---|
| 104 |
&outptr, &outbytesleft); |
|---|
| 105 |
if ((int)res > 0) |
|---|
| 106 |
return 1; |
|---|
| 107 |
} |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is |
|---|
| 111 |
provided. */ |
|---|
| 112 |
if (/* Try standardized names. */ |
|---|
| 113 |
iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) |
|---|
| 114 |
/* Try IRIX, OSF/1 names. */ |
|---|
| 115 |
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) |
|---|
| 116 |
/* Try AIX names. */ |
|---|
| 117 |
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) |
|---|
| 118 |
/* Try HP-UX names. */ |
|---|
| 119 |
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) |
|---|
| 120 |
return 1; |
|---|
| 121 |
return 0; |
|---|
| 122 |
}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], |
|---|
| 123 |
[case "$host_os" in |
|---|
| 124 |
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; |
|---|
| 125 |
*) am_cv_func_iconv_works="guessing yes" ;; |
|---|
| 126 |
esac]) |
|---|
| 127 |
LIBS="$am_save_LIBS" |
|---|
| 128 |
]) |
|---|
| 129 |
case "$am_cv_func_iconv_works" in |
|---|
| 130 |
*no) am_func_iconv=no am_cv_lib_iconv=no ;; |
|---|
| 131 |
*) am_func_iconv=yes ;; |
|---|
| 132 |
esac |
|---|
| 133 |
else |
|---|
| 134 |
am_func_iconv=no am_cv_lib_iconv=no |
|---|
| 135 |
fi |
|---|
| 136 |
if test "$am_func_iconv" = yes; then |
|---|
| 137 |
AC_DEFINE(HAVE_ICONV, 1, |
|---|
| 138 |
[Define if you have the iconv() function and it works.]) |
|---|
| 139 |
fi |
|---|
| 140 |
if test "$am_cv_lib_iconv" = yes; then |
|---|
| 141 |
AC_MSG_CHECKING([how to link with libiconv]) |
|---|
| 142 |
AC_MSG_RESULT([$LIBICONV]) |
|---|
| 143 |
else |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
CPPFLAGS="$am_save_CPPFLAGS" |
|---|
| 147 |
LIBICONV= |
|---|
| 148 |
LTLIBICONV= |
|---|
| 149 |
fi |
|---|
| 150 |
AC_SUBST(LIBICONV) |
|---|
| 151 |
AC_SUBST(LTLIBICONV) |
|---|
| 152 |
]) |
|---|
| 153 |
|
|---|
| 154 |
AC_DEFUN([AM_ICONV], |
|---|
| 155 |
[ |
|---|
| 156 |
AM_ICONV_LINK |
|---|
| 157 |
if test "$am_cv_func_iconv" = yes; then |
|---|
| 158 |
AC_MSG_CHECKING([for iconv declaration]) |
|---|
| 159 |
AC_CACHE_VAL(am_cv_proto_iconv, [ |
|---|
| 160 |
AC_TRY_COMPILE([ |
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
extern |
|---|
| 164 |
|
|---|
| 165 |
"C" |
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); |
|---|
| 169 |
|
|---|
| 170 |
size_t iconv(); |
|---|
| 171 |
|
|---|
| 172 |
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") |
|---|
| 173 |
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);"]) |
|---|
| 174 |
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` |
|---|
| 175 |
AC_MSG_RESULT([$]{ac_t:- |
|---|
| 176 |
}[$]am_cv_proto_iconv) |
|---|
| 177 |
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, |
|---|
| 178 |
[Define as const if the declaration of iconv() needs const.]) |
|---|
| 179 |
fi |
|---|
| 180 |
]) |
|---|