File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / confuse / m4 / iconv.m4
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Jan 24 14:48:55 2017 UTC (7 years, 7 months ago) by misho
Branches: confuse, MAIN
CVS tags: v2_7, HEAD
confuse 2.7

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>