|
Packit |
352660 |
# iconv.m4 serial 19 (gettext-0.18.2)
|
|
Packit |
352660 |
dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc.
|
|
Packit |
352660 |
dnl This file is free software; the Free Software Foundation
|
|
Packit |
352660 |
dnl gives unlimited permission to copy and/or distribute it,
|
|
Packit |
352660 |
dnl with or without modifications, as long as this notice is preserved.
|
|
Packit |
352660 |
|
|
Packit |
352660 |
dnl From Bruno Haible.
|
|
Packit |
352660 |
|
|
Packit |
352660 |
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
|
|
Packit |
352660 |
[
|
|
Packit |
352660 |
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
|
|
Packit |
352660 |
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
|
Packit |
352660 |
AC_REQUIRE([AC_LIB_RPATH])
|
|
Packit |
352660 |
|
|
Packit |
352660 |
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
|
|
Packit |
352660 |
dnl accordingly.
|
|
Packit |
352660 |
AC_LIB_LINKFLAGS_BODY([iconv])
|
|
Packit |
352660 |
])
|
|
Packit |
352660 |
|
|
Packit |
352660 |
AC_DEFUN([AM_ICONV_LINK],
|
|
Packit |
352660 |
[
|
|
Packit |
352660 |
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
|
|
Packit |
352660 |
dnl those with the standalone portable GNU libiconv installed).
|
|
Packit |
352660 |
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
Packit |
352660 |
|
|
Packit |
352660 |
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
|
|
Packit |
352660 |
dnl accordingly.
|
|
Packit |
352660 |
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
|
|
Packit |
352660 |
|
|
Packit |
352660 |
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
|
|
Packit |
352660 |
dnl because if the user has installed libiconv and not disabled its use
|
|
Packit |
352660 |
dnl via --without-libiconv-prefix, he wants to use it. The first
|
|
Packit |
352660 |
dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
|
|
Packit |
352660 |
am_save_CPPFLAGS="$CPPFLAGS"
|
|
Packit |
352660 |
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
|
|
Packit |
352660 |
|
|
Packit |
352660 |
AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
|
|
Packit |
352660 |
am_cv_func_iconv="no, consider installing GNU libiconv"
|
|
Packit |
352660 |
am_cv_lib_iconv=no
|
|
Packit |
352660 |
AC_LINK_IFELSE(
|
|
Packit |
352660 |
[AC_LANG_PROGRAM(
|
|
Packit |
352660 |
[[
|
|
Packit |
352660 |
#include <stdlib.h>
|
|
Packit |
352660 |
#include <iconv.h>
|
|
Packit |
352660 |
]],
|
|
Packit |
352660 |
[[iconv_t cd = iconv_open("","");
|
|
Packit |
352660 |
iconv(cd,NULL,NULL,NULL,NULL);
|
|
Packit |
352660 |
iconv_close(cd);]])],
|
|
Packit |
352660 |
[am_cv_func_iconv=yes])
|
|
Packit |
352660 |
if test "$am_cv_func_iconv" != yes; then
|
|
Packit |
352660 |
am_save_LIBS="$LIBS"
|
|
Packit |
352660 |
LIBS="$LIBS $LIBICONV"
|
|
Packit |
352660 |
AC_LINK_IFELSE(
|
|
Packit |
352660 |
[AC_LANG_PROGRAM(
|
|
Packit |
352660 |
[[
|
|
Packit |
352660 |
#include <stdlib.h>
|
|
Packit |
352660 |
#include <iconv.h>
|
|
Packit |
352660 |
]],
|
|
Packit |
352660 |
[[iconv_t cd = iconv_open("","");
|
|
Packit |
352660 |
iconv(cd,NULL,NULL,NULL,NULL);
|
|
Packit |
352660 |
iconv_close(cd);]])],
|
|
Packit |
352660 |
[am_cv_lib_iconv=yes]
|
|
Packit |
352660 |
[am_cv_func_iconv=yes])
|
|
Packit |
352660 |
LIBS="$am_save_LIBS"
|
|
Packit |
352660 |
fi
|
|
Packit |
352660 |
])
|
|
Packit |
352660 |
if test "$am_cv_func_iconv" = yes; then
|
|
Packit |
352660 |
AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
|
|
Packit |
352660 |
dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
|
|
Packit |
352660 |
dnl Solaris 10.
|
|
Packit |
352660 |
am_save_LIBS="$LIBS"
|
|
Packit |
352660 |
if test $am_cv_lib_iconv = yes; then
|
|
Packit |
352660 |
LIBS="$LIBS $LIBICONV"
|
|
Packit |
352660 |
fi
|
|
Packit |
352660 |
am_cv_func_iconv_works=no
|
|
Packit |
352660 |
for ac_iconv_const in '' 'const'; do
|
|
Packit |
352660 |
AC_RUN_IFELSE(
|
|
Packit |
352660 |
[AC_LANG_PROGRAM(
|
|
Packit |
352660 |
[[
|
|
Packit |
352660 |
#include <iconv.h>
|
|
Packit |
352660 |
#include <string.h>
|
|
Packit |
352660 |
|
|
Packit |
352660 |
#ifndef ICONV_CONST
|
|
Packit |
352660 |
# define ICONV_CONST $ac_iconv_const
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
]],
|
|
Packit |
352660 |
[[int result = 0;
|
|
Packit |
352660 |
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
|
|
Packit |
352660 |
returns. */
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
|
|
Packit |
352660 |
if (cd_utf8_to_88591 != (iconv_t)(-1))
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */
|
|
Packit |
352660 |
char buf[10];
|
|
Packit |
352660 |
ICONV_CONST char *inptr = input;
|
|
Packit |
352660 |
size_t inbytesleft = strlen (input);
|
|
Packit |
352660 |
char *outptr = buf;
|
|
Packit |
352660 |
size_t outbytesleft = sizeof (buf);
|
|
Packit |
352660 |
size_t res = iconv (cd_utf8_to_88591,
|
|
Packit |
352660 |
&inptr, &inbytesleft,
|
|
Packit |
352660 |
&outptr, &outbytesleft);
|
|
Packit |
352660 |
if (res == 0)
|
|
Packit |
352660 |
result |= 1;
|
|
Packit |
352660 |
iconv_close (cd_utf8_to_88591);
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
/* Test against Solaris 10 bug: Failures are not distinguishable from
|
|
Packit |
352660 |
successful returns. */
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
|
|
Packit |
352660 |
if (cd_ascii_to_88591 != (iconv_t)(-1))
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
static ICONV_CONST char input[] = "\263";
|
|
Packit |
352660 |
char buf[10];
|
|
Packit |
352660 |
ICONV_CONST char *inptr = input;
|
|
Packit |
352660 |
size_t inbytesleft = strlen (input);
|
|
Packit |
352660 |
char *outptr = buf;
|
|
Packit |
352660 |
size_t outbytesleft = sizeof (buf);
|
|
Packit |
352660 |
size_t res = iconv (cd_ascii_to_88591,
|
|
Packit |
352660 |
&inptr, &inbytesleft,
|
|
Packit |
352660 |
&outptr, &outbytesleft);
|
|
Packit |
352660 |
if (res == 0)
|
|
Packit |
352660 |
result |= 2;
|
|
Packit |
352660 |
iconv_close (cd_ascii_to_88591);
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
/* Test against AIX 6.1..7.1 bug: Buffer overrun. */
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
|
|
Packit |
352660 |
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
static ICONV_CONST char input[] = "\304";
|
|
Packit |
352660 |
static char buf[2] = { (char)0xDE, (char)0xAD };
|
|
Packit |
352660 |
ICONV_CONST char *inptr = input;
|
|
Packit |
352660 |
size_t inbytesleft = 1;
|
|
Packit |
352660 |
char *outptr = buf;
|
|
Packit |
352660 |
size_t outbytesleft = 1;
|
|
Packit |
352660 |
size_t res = iconv (cd_88591_to_utf8,
|
|
Packit |
352660 |
&inptr, &inbytesleft,
|
|
Packit |
352660 |
&outptr, &outbytesleft);
|
|
Packit |
352660 |
if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
|
|
Packit |
352660 |
result |= 4;
|
|
Packit |
352660 |
iconv_close (cd_88591_to_utf8);
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
#if 0 /* This bug could be worked around by the caller. */
|
|
Packit |
352660 |
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
|
|
Packit |
352660 |
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
|
Packit |
352660 |
{
|
|
Packit |
352660 |
static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
|
|
Packit |
352660 |
char buf[50];
|
|
Packit |
352660 |
ICONV_CONST char *inptr = input;
|
|
Packit |
352660 |
size_t inbytesleft = strlen (input);
|
|
Packit |
352660 |
char *outptr = buf;
|
|
Packit |
352660 |
size_t outbytesleft = sizeof (buf);
|
|
Packit |
352660 |
size_t res = iconv (cd_88591_to_utf8,
|
|
Packit |
352660 |
&inptr, &inbytesleft,
|
|
Packit |
352660 |
&outptr, &outbytesleft);
|
|
Packit |
352660 |
if ((int)res > 0)
|
|
Packit |
352660 |
result |= 8;
|
|
Packit |
352660 |
iconv_close (cd_88591_to_utf8);
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
}
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
|
|
Packit |
352660 |
provided. */
|
|
Packit |
352660 |
if (/* Try standardized names. */
|
|
Packit |
352660 |
iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
|
|
Packit |
352660 |
/* Try IRIX, OSF/1 names. */
|
|
Packit |
352660 |
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
|
|
Packit |
352660 |
/* Try AIX names. */
|
|
Packit |
352660 |
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
|
|
Packit |
352660 |
/* Try HP-UX names. */
|
|
Packit |
352660 |
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
|
|
Packit |
352660 |
result |= 16;
|
|
Packit |
352660 |
return result;
|
|
Packit |
352660 |
]])],
|
|
Packit |
352660 |
[am_cv_func_iconv_works=yes], ,
|
|
Packit |
352660 |
[case "$host_os" in
|
|
Packit |
352660 |
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
|
|
Packit |
352660 |
*) am_cv_func_iconv_works="guessing yes" ;;
|
|
Packit |
352660 |
esac])
|
|
Packit |
352660 |
test "$am_cv_func_iconv_works" = no || break
|
|
Packit |
352660 |
done
|
|
Packit |
352660 |
LIBS="$am_save_LIBS"
|
|
Packit |
352660 |
])
|
|
Packit |
352660 |
case "$am_cv_func_iconv_works" in
|
|
Packit |
352660 |
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
|
|
Packit |
352660 |
*) am_func_iconv=yes ;;
|
|
Packit |
352660 |
esac
|
|
Packit |
352660 |
else
|
|
Packit |
352660 |
am_func_iconv=no am_cv_lib_iconv=no
|
|
Packit |
352660 |
fi
|
|
Packit |
352660 |
if test "$am_func_iconv" = yes; then
|
|
Packit |
352660 |
AC_DEFINE([HAVE_ICONV], [1],
|
|
Packit |
352660 |
[Define if you have the iconv() function and it works.])
|
|
Packit |
352660 |
fi
|
|
Packit |
352660 |
if test "$am_cv_lib_iconv" = yes; then
|
|
Packit |
352660 |
AC_MSG_CHECKING([how to link with libiconv])
|
|
Packit |
352660 |
AC_MSG_RESULT([$LIBICONV])
|
|
Packit |
352660 |
else
|
|
Packit |
352660 |
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
|
|
Packit |
352660 |
dnl either.
|
|
Packit |
352660 |
CPPFLAGS="$am_save_CPPFLAGS"
|
|
Packit |
352660 |
LIBICONV=
|
|
Packit |
352660 |
LTLIBICONV=
|
|
Packit |
352660 |
fi
|
|
Packit |
352660 |
AC_SUBST([LIBICONV])
|
|
Packit |
352660 |
AC_SUBST([LTLIBICONV])
|
|
Packit |
352660 |
])
|
|
Packit |
352660 |
|
|
Packit |
352660 |
dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
|
|
Packit |
352660 |
dnl avoid warnings like
|
|
Packit |
352660 |
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
|
|
Packit |
352660 |
dnl This is tricky because of the way 'aclocal' is implemented:
|
|
Packit |
352660 |
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
|
|
Packit |
352660 |
dnl Otherwise aclocal's initial scan pass would miss the macro definition.
|
|
Packit |
352660 |
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
|
|
Packit |
352660 |
dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
|
|
Packit |
352660 |
dnl warnings.
|
|
Packit |
352660 |
m4_define([gl_iconv_AC_DEFUN],
|
|
Packit |
352660 |
m4_version_prereq([2.64],
|
|
Packit |
352660 |
[[AC_DEFUN_ONCE(
|
|
Packit |
352660 |
[$1], [$2])]],
|
|
Packit |
352660 |
[m4_ifdef([gl_00GNULIB],
|
|
Packit |
352660 |
[[AC_DEFUN_ONCE(
|
|
Packit |
352660 |
[$1], [$2])]],
|
|
Packit |
352660 |
[[AC_DEFUN(
|
|
Packit |
352660 |
[$1], [$2])]])]))
|
|
Packit |
352660 |
gl_iconv_AC_DEFUN([AM_ICONV],
|
|
Packit |
352660 |
[
|
|
Packit |
352660 |
AM_ICONV_LINK
|
|
Packit |
352660 |
if test "$am_cv_func_iconv" = yes; then
|
|
Packit |
352660 |
AC_MSG_CHECKING([for iconv declaration])
|
|
Packit |
352660 |
AC_CACHE_VAL([am_cv_proto_iconv], [
|
|
Packit |
352660 |
AC_COMPILE_IFELSE(
|
|
Packit |
352660 |
[AC_LANG_PROGRAM(
|
|
Packit |
352660 |
[[
|
|
Packit |
352660 |
#include <stdlib.h>
|
|
Packit |
352660 |
#include <iconv.h>
|
|
Packit |
352660 |
extern
|
|
Packit |
352660 |
#ifdef __cplusplus
|
|
Packit |
352660 |
"C"
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
|
|
Packit |
352660 |
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
|
|
Packit |
352660 |
#else
|
|
Packit |
352660 |
size_t iconv();
|
|
Packit |
352660 |
#endif
|
|
Packit |
352660 |
]],
|
|
Packit |
352660 |
[[]])],
|
|
Packit |
352660 |
[am_cv_proto_iconv_arg1=""],
|
|
Packit |
352660 |
[am_cv_proto_iconv_arg1="const"])
|
|
Packit |
352660 |
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);"])
|
|
Packit |
352660 |
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
|
|
Packit |
352660 |
AC_MSG_RESULT([
|
|
Packit |
352660 |
$am_cv_proto_iconv])
|
|
Packit |
352660 |
AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
|
|
Packit |
352660 |
[Define as const if the declaration of iconv() needs const.])
|
|
Packit |
352660 |
dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
|
|
Packit |
352660 |
m4_ifdef([gl_ICONV_H_DEFAULTS],
|
|
Packit |
352660 |
[AC_REQUIRE([gl_ICONV_H_DEFAULTS])
|
|
Packit |
352660 |
if test -n "$am_cv_proto_iconv_arg1"; then
|
|
Packit |
352660 |
ICONV_CONST="const"
|
|
Packit |
352660 |
fi
|
|
Packit |
352660 |
])
|
|
Packit |
352660 |
fi
|
|
Packit |
352660 |
])
|