Debian Codegraph @

m4/locale_h.m4

raw
1 # locale_h.m4
2 # serial 39
3 dnl Copyright (C) 2007, 2009-2026 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 AC_DEFUN_ONCE([gl_LOCALE_H],
10 [
11 dnl Ensure to expand the default settings once only, before all statements
12 dnl that occur in other macros.
13 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
14
15 dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_*
16 dnl members of 'struct lconv'.
17 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
18
19 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
20 AC_REQUIRE([gl_STDDEF_H])
21
22 AC_REQUIRE([gl_LOCALE_T])
23 dnl On native Windows, there is a type '_locale_t' that can be used to
24 dnl define locale_t.
25 AC_CACHE_CHECK([whether locale.h defines _locale_t],
26 [gl_cv_header_locale_has_windows_locale_t],
27 [AC_COMPILE_IFELSE(
28 [AC_LANG_PROGRAM(
29 [[#include <locale.h>
30 _locale_t x;]],
31 [[]])],
32 [gl_cv_header_locale_has_windows_locale_t=yes],
33 [gl_cv_header_locale_has_windows_locale_t=no])
34 ])
35 if test $gl_cv_header_locale_has_windows_locale_t = yes; then
36 HAVE_WINDOWS_LOCALE_T=1
37 AC_DEFINE([HAVE_WINDOWS_LOCALE_T], [1],
38 [Define to 1 if <locale.h> defines the _locale_t type.])
39 else
40 HAVE_WINDOWS_LOCALE_T=0
41 fi
42 AC_SUBST([HAVE_WINDOWS_LOCALE_T])
43
44 dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv'
45 dnl only if _LCONV_C99 is defined.
46 AC_REQUIRE([AC_CANONICAL_HOST])
47 case "$host_os" in
48 solaris*)
49 AC_DEFINE([_LCONV_C99], [1], [Define to 1 on Solaris.])
50 ;;
51 esac
52
53 AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
54 [gl_cv_header_locale_h_posix2001],
55 [AC_COMPILE_IFELSE(
56 [AC_LANG_PROGRAM(
57 [[#include <locale.h>
58 int x = LC_MESSAGES;
59 int y = sizeof (((struct lconv *) 0)->decimal_point);]],
60 [[]])],
61 [gl_cv_header_locale_h_posix2001=yes],
62 [gl_cv_header_locale_h_posix2001=no])])
63
64 dnl Check whether 'struct lconv' is complete.
65 dnl Bionic libc's 'struct lconv' is just a dummy.
66 dnl On OpenBSD 4.9, HP-UX 11, Solaris 9, Cygwin 1.5.x, mingw, MSVC 9,
67 dnl it lacks the int_p_* and int_n_* members.
68 AC_CACHE_CHECK([whether struct lconv is properly defined],
69 [gl_cv_sys_struct_lconv_ok],
70 [AC_COMPILE_IFELSE(
71 [AC_LANG_PROGRAM(
72 [[#include <locale.h>
73 struct lconv l;
74 int x = sizeof (l.decimal_point);
75 int y = sizeof (l.int_p_cs_precedes);]],
76 [[]])],
77 [gl_cv_sys_struct_lconv_ok=yes],
78 [gl_cv_sys_struct_lconv_ok=no])
79 ])
80 if test $gl_cv_sys_struct_lconv_ok = no; then
81 dnl On native Windows with MSVC, merely define these member names as macros.
82 dnl This avoids trouble in C++ mode.
83 case "$host_os" in
84 windows*-msvc*)
85 ;;
86 mingw* | windows*)
87 AC_EGREP_CPP([Special], [
88 #ifdef _MSC_VER
89 Special
90 #endif
91 ],
92 [],
93 [REPLACE_STRUCT_LCONV=1])
94 ;;
95 *) REPLACE_STRUCT_LCONV=1 ;;
96 esac
97 fi
98
99 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
100 gl_NEXT_HEADERS([locale.h])
101
102 dnl Check for declarations of anything we want to poison if the
103 dnl corresponding gnulib module is not in use.
104 gl_WARN_ON_USE_PREPARE([[#include <locale.h>
105 /* Some systems provide declarations in a non-standard header. */
106 #if HAVE_XLOCALE_H
107 # include <xlocale.h>
108 #endif
109 ]],
110 [setlocale newlocale duplocale freelocale getlocalename_l])
111 ])
112
113 dnl Checks to determine whether the system has the locale_t type,
114 dnl and how to obtain it.
115 AC_DEFUN([gl_LOCALE_T],
116 [
117 dnl Persuade glibc and Solaris <locale.h> to define locale_t.
118 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
119
120 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
121 dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
122 dnl itself, we assume that <xlocale.h> will do so.
123 AC_CACHE_CHECK([whether locale.h defines locale_t],
124 [gl_cv_header_locale_has_locale_t],
125 [AC_COMPILE_IFELSE(
126 [AC_LANG_PROGRAM(
127 [[#include <locale.h>
128 locale_t x;]],
129 [[]])],
130 [gl_cv_header_locale_has_locale_t=yes],
131 [gl_cv_header_locale_has_locale_t=no])
132 ])
133
134 dnl Check for <xlocale.h>.
135 AC_CHECK_HEADERS_ONCE([xlocale.h])
136 if test $ac_cv_header_xlocale_h = yes; then
137 HAVE_XLOCALE_H=1
138 if test $gl_cv_header_locale_has_locale_t = yes; then
139 gl_cv_header_locale_h_needs_xlocale_h=no
140 else
141 gl_cv_header_locale_h_needs_xlocale_h=yes
142 fi
143 HAVE_LOCALE_T=1
144 else
145 HAVE_XLOCALE_H=0
146 gl_cv_header_locale_h_needs_xlocale_h=no
147 if test $gl_cv_header_locale_has_locale_t = yes; then
148 HAVE_LOCALE_T=1
149 else
150 HAVE_LOCALE_T=0
151 fi
152 fi
153 AC_SUBST([HAVE_XLOCALE_H])
154 AC_SUBST([HAVE_LOCALE_T])
155 ])
156
157 # gl_LOCALE_MODULE_INDICATOR([modulename])
158 # sets the shell variable that indicates the presence of the given module
159 # to a C preprocessor expression that will evaluate to 1.
160 # This macro invocation must not occur in macros that are AC_REQUIREd.
161 AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
162 [
163 dnl Ensure to expand the default settings once only.
164 gl_LOCALE_H_REQUIRE_DEFAULTS
165 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
166 dnl Define it also as a C macro, for the benefit of the unit tests.
167 gl_MODULE_INDICATOR_FOR_TESTS([$1])
168 ])
169
170 # Initializes the default values for AC_SUBSTed shell variables.
171 # This macro must not be AC_REQUIREd. It must only be invoked, and only
172 # outside of macros or in macros that are not AC_REQUIREd.
173 AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS],
174 [
175 m4_defun(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS], [
176 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALECONV])
177 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE])
178 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL])
179 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NEWLOCALE])
180 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE])
181 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREELOCALE])
182 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOCALENAME_L])
183 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOCALENAME_L_UNSAFE])
184 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME_UNSAFE])
185 ])
186 m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS])
187 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
188 ])
189
190 AC_DEFUN([gl_LOCALE_H_DEFAULTS],
191 [
192 dnl Assume proper GNU behavior unless another module says otherwise.
193 HAVE_NEWLOCALE=1; AC_SUBST([HAVE_NEWLOCALE])
194 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
195 HAVE_FREELOCALE=1; AC_SUBST([HAVE_FREELOCALE])
196 HAVE_GETLOCALENAME_L=1; AC_SUBST([HAVE_GETLOCALENAME_L])
197 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
198 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
199 REPLACE_NEWLOCALE=0; AC_SUBST([REPLACE_NEWLOCALE])
200 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
201 REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE])
202 REPLACE_GETLOCALENAME_L=0; AC_SUBST([REPLACE_GETLOCALENAME_L])
203 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
204 LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS])
205 ])