1# iconv_h.m4 serial 12
2dnl Copyright (C) 2007-2021 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_ICONV_H],
8[
9  AC_REQUIRE([gl_ICONV_H_DEFAULTS])
10
11  dnl Execute this unconditionally, because ICONV_H may be set by other
12  dnl modules, after this code is executed.
13  gl_CHECK_NEXT_HEADERS([iconv.h])
14
15  dnl Check for declarations of anything we want to poison if the
16  dnl corresponding gnulib module is not in use, and which is not
17  dnl guaranteed by C89.
18  gl_WARN_ON_USE_PREPARE([[#include <iconv.h>
19    ]], [iconv iconv_open])
20
21  AC_REQUIRE([AC_C_RESTRICT])
22])
23
24dnl Unconditionally enables the replacement of <iconv.h>.
25AC_DEFUN([gl_REPLACE_ICONV_H],
26[
27  AC_REQUIRE([gl_ICONV_H_DEFAULTS])
28  ICONV_H='iconv.h'
29  AM_CONDITIONAL([GL_GENERATE_ICONV_H], [test -n "$ICONV_H"])
30])
31
32AC_DEFUN([gl_ICONV_MODULE_INDICATOR],
33[
34  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
35  AC_REQUIRE([gl_ICONV_H_DEFAULTS])
36  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
37])
38
39AC_DEFUN([gl_ICONV_H_DEFAULTS],
40[
41  m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])])
42  GNULIB_ICONV=0;       AC_SUBST([GNULIB_ICONV])
43  dnl Assume proper GNU behavior unless another module says otherwise.
44  ICONV_CONST=;         AC_SUBST([ICONV_CONST])
45  REPLACE_ICONV=0;      AC_SUBST([REPLACE_ICONV])
46  REPLACE_ICONV_OPEN=0; AC_SUBST([REPLACE_ICONV_OPEN])
47  REPLACE_ICONV_UTF=0;  AC_SUBST([REPLACE_ICONV_UTF])
48  ICONV_H='';           AC_SUBST([ICONV_H])
49  m4_ifdef([gl_POSIXCHECK],
50    [ICONV_H='iconv.h'],
51    [if m4_ifdef([gl_ANSI_CXX], [test "$CXX" != no], [false]); then
52       dnl Override <fnmatch.h> always, to support the C++ GNULIB_NAMESPACE.
53       ICONV_H='iconv.h'
54     fi
55    ])
56  AM_CONDITIONAL([GL_GENERATE_ICONV_H], [test -n "$ICONV_H"])
57])
58