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