Debian Codegraph @

m4/langinfo_h.m4

raw
1 # langinfo_h.m4
2 # serial 13
3 dnl Copyright (C) 2009-2025 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_LANGINFO_H],
10 [
11 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
12
13 dnl Persuade glibc-2.0.6 <langinfo.h> to define CODESET.
14 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
15
16 dnl <langinfo.h> is always overridden, because of GNULIB_POSIXCHECK.
17 gl_CHECK_NEXT_HEADERS([langinfo.h])
18
19 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
20 HAVE_LANGINFO_CODESET=0
21 HAVE_LANGINFO_T_FMT_AMPM=0
22 HAVE_LANGINFO_ALTMON=0
23 HAVE_LANGINFO_ABALTMON=0
24 HAVE_LANGINFO_ERA=0
25 HAVE_LANGINFO_YESEXPR=0
26 AC_CHECK_HEADERS_ONCE([langinfo.h])
27 if test $ac_cv_header_langinfo_h = yes; then
28 HAVE_LANGINFO_H=1
29 dnl Determine what <langinfo.h> defines.
30 dnl CODESET is missing on OpenBSD 3.8.
31 dnl ERA etc. are missing on OpenBSD 6.7.
32 dnl T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3.
33 dnl ALTMON_* are missing on glibc 2.26 and many other systems.
34 dnl ABALTMON_* are missing on glibc 2.41 and many other systems.
35 AC_CACHE_CHECK([whether langinfo.h defines CODESET],
36 [gl_cv_header_langinfo_codeset],
37 [AC_COMPILE_IFELSE(
38 [AC_LANG_PROGRAM([[#include <langinfo.h>
39 int a = CODESET;
40 ]])],
41 [gl_cv_header_langinfo_codeset=yes],
42 [gl_cv_header_langinfo_codeset=no])
43 ])
44 if test $gl_cv_header_langinfo_codeset = yes; then
45 HAVE_LANGINFO_CODESET=1
46 fi
47 AC_CACHE_CHECK([whether langinfo.h defines T_FMT_AMPM],
48 [gl_cv_header_langinfo_t_fmt_ampm],
49 [AC_COMPILE_IFELSE(
50 [AC_LANG_PROGRAM([[#include <langinfo.h>
51 int a = T_FMT_AMPM;
52 ]])],
53 [gl_cv_header_langinfo_t_fmt_ampm=yes],
54 [gl_cv_header_langinfo_t_fmt_ampm=no])
55 ])
56 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
57 HAVE_LANGINFO_T_FMT_AMPM=1
58 fi
59 AC_CACHE_CHECK([whether langinfo.h defines ALTMON_1],
60 [gl_cv_header_langinfo_altmon],
61 [AC_COMPILE_IFELSE(
62 [AC_LANG_PROGRAM([[#include <langinfo.h>
63 int a = ALTMON_1;
64 ]])],
65 [gl_cv_header_langinfo_altmon=yes],
66 [gl_cv_header_langinfo_altmon=no])
67 ])
68 if test $gl_cv_header_langinfo_altmon = yes; then
69 HAVE_LANGINFO_ALTMON=1
70 fi
71 AC_CACHE_CHECK([whether langinfo.h defines ABALTMON_1],
72 [gl_cv_header_langinfo_abaltmon],
73 [AC_COMPILE_IFELSE(
74 [AC_LANG_PROGRAM([[#include <langinfo.h>
75 int a = ABALTMON_1;
76 ]])],
77 [gl_cv_header_langinfo_abaltmon=yes],
78 [gl_cv_header_langinfo_abaltmon=no])
79 ])
80 if test $gl_cv_header_langinfo_abaltmon = yes; then
81 HAVE_LANGINFO_ABALTMON=1
82 fi
83 AC_CACHE_CHECK([whether langinfo.h defines ERA],
84 [gl_cv_header_langinfo_era],
85 [AC_COMPILE_IFELSE(
86 [AC_LANG_PROGRAM([[#include <langinfo.h>
87 int a = ERA;
88 ]])],
89 [gl_cv_header_langinfo_era=yes],
90 [gl_cv_header_langinfo_era=no])
91 ])
92 if test $gl_cv_header_langinfo_era = yes; then
93 HAVE_LANGINFO_ERA=1
94 fi
95 AC_CACHE_CHECK([whether langinfo.h defines YESEXPR],
96 [gl_cv_header_langinfo_yesexpr],
97 [AC_COMPILE_IFELSE(
98 [AC_LANG_PROGRAM([[#include <langinfo.h>
99 int a = YESEXPR;
100 ]])],
101 [gl_cv_header_langinfo_yesexpr=yes],
102 [gl_cv_header_langinfo_yesexpr=no])
103 ])
104 if test $gl_cv_header_langinfo_yesexpr = yes; then
105 HAVE_LANGINFO_YESEXPR=1
106 fi
107 else
108 HAVE_LANGINFO_H=0
109 fi
110 AC_SUBST([HAVE_LANGINFO_H])
111 AC_SUBST([HAVE_LANGINFO_CODESET])
112 AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM])
113 AC_SUBST([HAVE_LANGINFO_ALTMON])
114 AC_SUBST([HAVE_LANGINFO_ABALTMON])
115 AC_SUBST([HAVE_LANGINFO_ERA])
116 AC_SUBST([HAVE_LANGINFO_YESEXPR])
117
118 dnl Check for declarations of anything we want to poison if the
119 dnl corresponding gnulib module is not in use.
120 gl_WARN_ON_USE_PREPARE([[#include <langinfo.h>
121 ]], [nl_langinfo])
122 ])
123
124 # gl_LANGINFO_MODULE_INDICATOR([modulename])
125 # sets the shell variable that indicates the presence of the given module
126 # to a C preprocessor expression that will evaluate to 1.
127 # This macro invocation must not occur in macros that are AC_REQUIREd.
128 AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
129 [
130 dnl Ensure to expand the default settings once only.
131 gl_LANGINFO_H_REQUIRE_DEFAULTS
132 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
133 dnl Define it also as a C macro, for the benefit of the unit tests.
134 gl_MODULE_INDICATOR_FOR_TESTS([$1])
135 ])
136
137 # Initializes the default values for AC_SUBSTed shell variables.
138 # This macro must not be AC_REQUIREd. It must only be invoked, and only
139 # outside of macros or in macros that are not AC_REQUIREd.
140 AC_DEFUN([gl_LANGINFO_H_REQUIRE_DEFAULTS],
141 [
142 m4_defun(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS], [
143 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NL_LANGINFO])
144 ])
145 m4_require(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS])
146 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
147 ])
148
149 AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
150 [
151 dnl Assume proper GNU behavior unless another module says otherwise.
152 HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO])
153 REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
154 ])