Blame m4/iconv.m4

Packit Service 9f2c4a
# iconv.m4 serial AM4 (gettext-0.11.3)
Packit Service 9f2c4a
dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
Packit Service 9f2c4a
dnl This file is free software, distributed under the terms of the GNU
Packit Service 9f2c4a
dnl General Public License.  As a special exception to the GNU General
Packit Service 9f2c4a
dnl Public License, this file may be distributed as part of a program
Packit Service 9f2c4a
dnl that contains a configuration script generated by Autoconf, under
Packit Service 9f2c4a
dnl the same distribution terms as the rest of that program.
Packit Service 9f2c4a
Packit Service 9f2c4a
dnl From Bruno Haible.
Packit Service 9f2c4a
Packit Service 9f2c4a
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
Packit Service 9f2c4a
[
Packit Service 9f2c4a
  dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
Packit Service 9f2c4a
  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
Packit Service 9f2c4a
  AC_REQUIRE([AC_LIB_RPATH])
Packit Service 9f2c4a
Packit Service 9f2c4a
  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
Packit Service 9f2c4a
  dnl accordingly.
Packit Service 9f2c4a
  AC_LIB_LINKFLAGS_BODY([iconv])
Packit Service 9f2c4a
])
Packit Service 9f2c4a
Packit Service 9f2c4a
AC_DEFUN([AM_ICONV_LINK],
Packit Service 9f2c4a
[
Packit Service 9f2c4a
  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
Packit Service 9f2c4a
  dnl those with the standalone portable GNU libiconv installed).
Packit Service 9f2c4a
Packit Service 9f2c4a
  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
Packit Service 9f2c4a
  dnl accordingly.
Packit Service 9f2c4a
  AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
Packit Service 9f2c4a
Packit Service 9f2c4a
  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
Packit Service 9f2c4a
  dnl because if the user has installed libiconv and not disabled its use
Packit Service 9f2c4a
  dnl via --without-libiconv-prefix, he wants to use it. The first
Packit Service 9f2c4a
  dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
Packit Service 9f2c4a
  am_save_CPPFLAGS="$CPPFLAGS"
Packit Service 9f2c4a
  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
Packit Service 9f2c4a
Packit Service 9f2c4a
  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
Packit Service 9f2c4a
    am_cv_func_iconv="no, consider installing GNU libiconv"
Packit Service 9f2c4a
    am_cv_lib_iconv=no
Packit Service 9f2c4a
    AC_TRY_LINK([#include <stdlib.h>
Packit Service 9f2c4a
#include <iconv.h>],
Packit Service 9f2c4a
      [iconv_t cd = iconv_open("","");
Packit Service 9f2c4a
       iconv(cd,NULL,NULL,NULL,NULL);
Packit Service 9f2c4a
       iconv_close(cd);],
Packit Service 9f2c4a
      am_cv_func_iconv=yes)
Packit Service 9f2c4a
    if test "$am_cv_func_iconv" != yes; then
Packit Service 9f2c4a
      am_save_LIBS="$LIBS"
Packit Service 9f2c4a
      LIBS="$LIBS $LIBICONV"
Packit Service 9f2c4a
      AC_TRY_LINK([#include <stdlib.h>
Packit Service 9f2c4a
#include <iconv.h>],
Packit Service 9f2c4a
        [iconv_t cd = iconv_open("","");
Packit Service 9f2c4a
         iconv(cd,NULL,NULL,NULL,NULL);
Packit Service 9f2c4a
         iconv_close(cd);],
Packit Service 9f2c4a
        am_cv_lib_iconv=yes
Packit Service 9f2c4a
        am_cv_func_iconv=yes)
Packit Service 9f2c4a
      LIBS="$am_save_LIBS"
Packit Service 9f2c4a
    fi
Packit Service 9f2c4a
  ])
Packit Service 9f2c4a
  if test "$am_cv_func_iconv" = yes; then
Packit Service 9f2c4a
    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
Packit Service 9f2c4a
  fi
Packit Service 9f2c4a
  if test "$am_cv_lib_iconv" = yes; then
Packit Service 9f2c4a
    AC_MSG_CHECKING([how to link with libiconv])
Packit Service 9f2c4a
    AC_MSG_RESULT([$LIBICONV])
Packit Service 9f2c4a
  else
Packit Service 9f2c4a
    dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
Packit Service 9f2c4a
    dnl either.
Packit Service 9f2c4a
    CPPFLAGS="$am_save_CPPFLAGS"
Packit Service 9f2c4a
    LIBICONV=
Packit Service 9f2c4a
    LTLIBICONV=
Packit Service 9f2c4a
  fi
Packit Service 9f2c4a
  AC_SUBST(LIBICONV)
Packit Service 9f2c4a
  AC_SUBST(LTLIBICONV)
Packit Service 9f2c4a
])
Packit Service 9f2c4a
Packit Service 9f2c4a
AC_DEFUN([AM_ICONV],
Packit Service 9f2c4a
[
Packit Service 9f2c4a
  AM_ICONV_LINK
Packit Service 9f2c4a
  if test "$am_cv_func_iconv" = yes; then
Packit Service 9f2c4a
    AC_MSG_CHECKING([for iconv declaration])
Packit Service 9f2c4a
    AC_CACHE_VAL(am_cv_proto_iconv, [
Packit Service 9f2c4a
      AC_TRY_COMPILE([
Packit Service 9f2c4a
#include <stdlib.h>
Packit Service 9f2c4a
#include <iconv.h>
Packit Service 9f2c4a
extern
Packit Service 9f2c4a
#ifdef __cplusplus
Packit Service 9f2c4a
"C"
Packit Service 9f2c4a
#endif
Packit Service 9f2c4a
#if defined(__STDC__) || defined(__cplusplus)
Packit Service 9f2c4a
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
Packit Service 9f2c4a
#else
Packit Service 9f2c4a
size_t iconv();
Packit Service 9f2c4a
#endif
Packit Service 9f2c4a
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
Packit Service 9f2c4a
      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 Service 9f2c4a
    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
Packit Service 9f2c4a
    AC_MSG_RESULT([$]{ac_t:-
Packit Service 9f2c4a
         }[$]am_cv_proto_iconv)
Packit Service 9f2c4a
    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
Packit Service 9f2c4a
      [Define as const if the declaration of iconv() needs const.])
Packit Service 9f2c4a
  fi
Packit Service 9f2c4a
])