aboutsummaryrefslogtreecommitdiff
path: root/m4/iconv.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/iconv.m4')
-rw-r--r--m4/iconv.m4112
1 files changed, 62 insertions, 50 deletions
diff --git a/m4/iconv.m4 b/m4/iconv.m4
index aa159c53..d0e61de2 100644
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -1,11 +1,18 @@
1# iconv.m4 serial 19 (gettext-0.18.2) 1# iconv.m4 serial 24
2dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2007-2014, 2016-2021 Free Software Foundation,
3dnl Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
6 7
7dnl From Bruno Haible. 8dnl From Bruno Haible.
8 9
10AC_PREREQ([2.64])
11
12dnl Note: AM_ICONV is documented in the GNU gettext manual
13dnl <https://www.gnu.org/software/gettext/manual/html_node/AM_005fICONV.html>.
14dnl Don't make changes that are incompatible with that documentation!
15
9AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], 16AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
10[ 17[
11 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. 18 dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
@@ -85,8 +92,9 @@ AC_DEFUN([AM_ICONV_LINK],
85#endif 92#endif
86 ]], 93 ]],
87 [[int result = 0; 94 [[int result = 0;
88 /* Test against AIX 5.1 bug: Failures are not distinguishable from successful 95 /* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from
89 returns. */ 96 successful returns. This is even documented in
97 <https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html> */
90 { 98 {
91 iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); 99 iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
92 if (cd_utf8_to_88591 != (iconv_t)(-1)) 100 if (cd_utf8_to_88591 != (iconv_t)(-1))
@@ -167,15 +175,27 @@ AC_DEFUN([AM_ICONV_LINK],
167#endif 175#endif
168 /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is 176 /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
169 provided. */ 177 provided. */
170 if (/* Try standardized names. */ 178 {
171 iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) 179 /* Try standardized names. */
172 /* Try IRIX, OSF/1 names. */ 180 iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");
173 && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) 181 /* Try IRIX, OSF/1 names. */
174 /* Try AIX names. */ 182 iconv_t cd2 = iconv_open ("UTF-8", "eucJP");
175 && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) 183 /* Try AIX names. */
176 /* Try HP-UX names. */ 184 iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");
177 && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) 185 /* Try HP-UX names. */
178 result |= 16; 186 iconv_t cd4 = iconv_open ("utf8", "eucJP");
187 if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)
188 && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))
189 result |= 16;
190 if (cd1 != (iconv_t)(-1))
191 iconv_close (cd1);
192 if (cd2 != (iconv_t)(-1))
193 iconv_close (cd2);
194 if (cd3 != (iconv_t)(-1))
195 iconv_close (cd3);
196 if (cd4 != (iconv_t)(-1))
197 iconv_close (cd4);
198 }
179 return result; 199 return result;
180]])], 200]])],
181 [am_cv_func_iconv_works=yes], , 201 [am_cv_func_iconv_works=yes], ,
@@ -212,8 +232,7 @@ AC_DEFUN([AM_ICONV_LINK],
212 AC_SUBST([LTLIBICONV]) 232 AC_SUBST([LTLIBICONV])
213]) 233])
214 234
215dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to 235dnl Define AM_ICONV using AC_DEFUN_ONCE, in order to avoid warnings like
216dnl avoid warnings like
217dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". 236dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
218dnl This is tricky because of the way 'aclocal' is implemented: 237dnl This is tricky because of the way 'aclocal' is implemented:
219dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. 238dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
@@ -221,51 +240,44 @@ dnl Otherwise aclocal's initial scan pass would miss the macro definition.
221dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. 240dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
222dnl Otherwise aclocal would emit many "Use of uninitialized value $1" 241dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
223dnl warnings. 242dnl warnings.
224m4_define([gl_iconv_AC_DEFUN], 243AC_DEFUN_ONCE([AM_ICONV],
225 m4_version_prereq([2.64],
226 [[AC_DEFUN_ONCE(
227 [$1], [$2])]],
228 [m4_ifdef([gl_00GNULIB],
229 [[AC_DEFUN_ONCE(
230 [$1], [$2])]],
231 [[AC_DEFUN(
232 [$1], [$2])]])]))
233gl_iconv_AC_DEFUN([AM_ICONV],
234[ 244[
235 AM_ICONV_LINK 245 AM_ICONV_LINK
236 if test "$am_cv_func_iconv" = yes; then 246 if test "$am_cv_func_iconv" = yes; then
237 AC_MSG_CHECKING([for iconv declaration]) 247 AC_CACHE_CHECK([whether iconv is compatible with its POSIX signature],
238 AC_CACHE_VAL([am_cv_proto_iconv], [ 248 [gl_cv_iconv_nonconst],
239 AC_COMPILE_IFELSE( 249 [AC_COMPILE_IFELSE(
240 [AC_LANG_PROGRAM( 250 [AC_LANG_PROGRAM(
241 [[ 251 [[
242#include <stdlib.h> 252#include <stdlib.h>
243#include <iconv.h> 253#include <iconv.h>
244extern 254extern
245#ifdef __cplusplus 255#ifdef __cplusplus
246"C" 256"C"
247#endif 257#endif
248#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
249size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); 258size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
250#else 259 ]],
251size_t iconv(); 260 [[]])],
252#endif 261 [gl_cv_iconv_nonconst=yes],
253 ]], 262 [gl_cv_iconv_nonconst=no])
254 [[]])],
255 [am_cv_proto_iconv_arg1=""],
256 [am_cv_proto_iconv_arg1="const"])
257 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);"])
258 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
259 AC_MSG_RESULT([
260 $am_cv_proto_iconv])
261 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
262 [Define as const if the declaration of iconv() needs const.])
263 dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
264 m4_ifdef([gl_ICONV_H_DEFAULTS],
265 [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
266 if test -n "$am_cv_proto_iconv_arg1"; then
267 ICONV_CONST="const"
268 fi
269 ]) 263 ])
264 else
265 dnl When compiling GNU libiconv on a system that does not have iconv yet,
266 dnl pick the POSIX compliant declaration without 'const'.
267 gl_cv_iconv_nonconst=yes
270 fi 268 fi
269 if test $gl_cv_iconv_nonconst = yes; then
270 iconv_arg1=""
271 else
272 iconv_arg1="const"
273 fi
274 AC_DEFINE_UNQUOTED([ICONV_CONST], [$iconv_arg1],
275 [Define as const if the declaration of iconv() needs const.])
276 dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
277 m4_ifdef([gl_ICONV_H_DEFAULTS],
278 [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
279 if test $gl_cv_iconv_nonconst != yes; then
280 ICONV_CONST="const"
281 fi
282 ])
271]) 283])