source: trunk/libs/newlib/src/config/iconv.m4 @ 577

Last change on this file since 577 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 4.4 KB
Line 
1# iconv.m4 serial AM4 (gettext-0.11.3)
2dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
3dnl This file is free software, distributed under the terms of the GNU
4dnl General Public License.  As a special exception to the GNU General
5dnl Public License, this file may be distributed as part of a program
6dnl that contains a configuration script generated by Autoconf, under
7dnl the same distribution terms as the rest of that program.
8
9dnl From Bruno Haible.
10dnl with modifications to support building with in-tree libiconv
11
12AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
13[
14  dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
15  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
16  AC_REQUIRE([AC_LIB_RPATH])
17
18  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
19  dnl accordingly.
20  AC_LIB_LINKFLAGS_BODY([iconv])
21])
22
23AC_DEFUN([AM_ICONV_LINK],
24[
25  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
26  dnl those with the standalone portable GNU libiconv installed).
27
28  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
29  dnl accordingly.
30  AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
31
32  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
33    am_cv_func_iconv="no, consider installing GNU libiconv"
34    am_cv_lib_iconv=no
35    dnl Add $INCICONV to CPPFLAGS before performing the first check,
36    dnl because if the user has installed libiconv and not disabled its use
37    dnl via --without-libiconv-prefix, he wants to use it. This first
38    dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
39    am_save_CPPFLAGS="$CPPFLAGS"
40    CPPFLAGS="$CPPFLAGS $INCICONV"
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    CPPFLAGS="$am_save_CPPFLAGS"
48
49    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
50      for _libs in .libs _libs; do
51        am_save_CPPFLAGS="$CPPFLAGS"
52        am_save_LIBS="$LIBS"
53        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
54        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
55        AC_TRY_LINK([#include <stdlib.h>
56#include <iconv.h>],
57          [iconv_t cd = iconv_open("","");
58           iconv(cd,NULL,NULL,NULL,NULL);
59           iconv_close(cd);],
60          INCICONV="-I../libiconv/include"
61          LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a
62          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
63          am_cv_lib_iconv=yes
64          am_cv_func_iconv=yes)
65        CPPFLAGS="$am_save_CPPFLAGS"
66        LIBS="$am_save_LIBS"
67        if test "$am_cv_func_iconv" = "yes"; then
68          break
69        fi
70      done
71    fi
72
73    if test "$am_cv_func_iconv" != yes; then
74      am_save_CPPFLAGS="$CPPFLAGS"
75      am_save_LIBS="$LIBS"
76      CPPFLAGS="$LIBS $INCICONV"
77      LIBS="$LIBS $LIBICONV"
78      AC_TRY_LINK([#include <stdlib.h>
79#include <iconv.h>],
80        [iconv_t cd = iconv_open("","");
81         iconv(cd,NULL,NULL,NULL,NULL);
82         iconv_close(cd);],
83        am_cv_lib_iconv=yes
84        am_cv_func_iconv=yes)
85      CPPFLAGS="$am_save_CPPFLAGS"
86      LIBS="$am_save_LIBS"
87    fi
88  ])
89  if test "$am_cv_func_iconv" = yes; then
90    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
91  fi
92  if test "$am_cv_lib_iconv" = yes; then
93    AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
94    AC_MSG_CHECKING([how to link with libiconv])
95    AC_MSG_RESULT([$LIBICONV])
96  else
97    LIBICONV=
98    LTLIBICONV=
99  fi
100  AC_SUBST(LIBICONV)
101  AC_SUBST(LTLIBICONV)
102])
103
104AC_DEFUN([AM_ICONV],
105[
106  AM_ICONV_LINK
107  if test "$am_cv_func_iconv" = yes; then
108    AC_MSG_CHECKING([for iconv declaration])
109    AC_CACHE_VAL(am_cv_proto_iconv, [
110      AC_TRY_COMPILE([
111#include <stdlib.h>
112#include <iconv.h>
113extern
114#ifdef __cplusplus
115"C"
116#endif
117#if defined(__STDC__) || defined(__cplusplus)
118size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
119#else
120size_t iconv();
121#endif
122], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
123      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);"])
124    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
125    AC_MSG_RESULT([$]{ac_t:-
126         }[$]am_cv_proto_iconv)
127    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
128      [Define as const if the declaration of iconv() needs const.])
129  fi
130])
Note: See TracBrowser for help on using the repository browser.