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