Debian Codegraph @

m4/langinfo_h.m4

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