Commit | Line | Data |
---|---|---|
f19dd04a DD |
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, distributed under the terms of the GNU | |
4 | dnl General Public License. As a special exception to the GNU General | |
5 | dnl Public License, this file may be distributed as part of a program | |
6 | dnl that contains a configuration script generated by Autoconf, under | |
7 | dnl the same distribution terms as the rest of that program. | |
8 | ||
9 | dnl From Bruno Haible. | |
cfe101c6 | 10 | dnl with modifications to support building with in-tree libiconv |
f19dd04a DD |
11 | |
12 | AC_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 | ||
23 | AC_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 | ||
f19dd04a DD |
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 | |
cfe101c6 YS |
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" | |
f19dd04a DD |
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) | |
cfe101c6 YS |
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 | ||
f19dd04a | 73 | if test "$am_cv_func_iconv" != yes; then |
cfe101c6 | 74 | am_save_CPPFLAGS="$CPPFLAGS" |
f19dd04a | 75 | am_save_LIBS="$LIBS" |
5d762de0 | 76 | CPPFLAGS="$CPPFLAGS $INCICONV" |
f19dd04a DD |
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) | |
cfe101c6 | 85 | CPPFLAGS="$am_save_CPPFLAGS" |
f19dd04a DD |
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 | |
cfe101c6 | 93 | AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) |
f19dd04a DD |
94 | AC_MSG_CHECKING([how to link with libiconv]) |
95 | AC_MSG_RESULT([$LIBICONV]) | |
96 | else | |
f19dd04a DD |
97 | LIBICONV= |
98 | LTLIBICONV= | |
99 | fi | |
100 | AC_SUBST(LIBICONV) | |
101 | AC_SUBST(LTLIBICONV) | |
102 | ]) | |
103 | ||
104 | AC_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> | |
113 | extern | |
114 | #ifdef __cplusplus | |
115 | "C" | |
116 | #endif | |
117 | #if defined(__STDC__) || defined(__cplusplus) | |
118 | size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); | |
119 | #else | |
120 | size_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 | ]) |