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.
7 AC_DEFUN_ONCE([gl_LANGINFO_H],
9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
11 dnl Persuade glibc-2.0.6 <langinfo.h> to define CODESET.
12 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
14 dnl <langinfo.h> is always overridden, because of GNULIB_POSIXCHECK.
15 gl_CHECK_NEXT_HEADERS([langinfo.h])
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
22 HAVE_LANGINFO_YESEXPR=0
23 AC_CHECK_HEADERS_ONCE([langinfo.h])
24 if test $ac_cv_header_langinfo_h = yes; then
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],
34 [AC_LANG_PROGRAM([[#include <langinfo.h>
37 [gl_cv_header_langinfo_codeset=yes],
38 [gl_cv_header_langinfo_codeset=no])
40 if test $gl_cv_header_langinfo_codeset = yes; then
41 HAVE_LANGINFO_CODESET=1
43 AC_CACHE_CHECK([whether langinfo.h defines T_FMT_AMPM],
44 [gl_cv_header_langinfo_t_fmt_ampm],
46 [AC_LANG_PROGRAM([[#include <langinfo.h>
49 [gl_cv_header_langinfo_t_fmt_ampm=yes],
50 [gl_cv_header_langinfo_t_fmt_ampm=no])
52 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
53 HAVE_LANGINFO_T_FMT_AMPM=1
55 AC_CACHE_CHECK([whether langinfo.h defines ALTMON_1],
56 [gl_cv_header_langinfo_altmon],
58 [AC_LANG_PROGRAM([[#include <langinfo.h>
61 [gl_cv_header_langinfo_altmon=yes],
62 [gl_cv_header_langinfo_altmon=no])
64 if test $gl_cv_header_langinfo_altmon = yes; then
65 HAVE_LANGINFO_ALTMON=1
67 AC_CACHE_CHECK([whether langinfo.h defines ERA],
68 [gl_cv_header_langinfo_era],
70 [AC_LANG_PROGRAM([[#include <langinfo.h>
73 [gl_cv_header_langinfo_era=yes],
74 [gl_cv_header_langinfo_era=no])
76 if test $gl_cv_header_langinfo_era = yes; then
79 AC_CACHE_CHECK([whether langinfo.h defines YESEXPR],
80 [gl_cv_header_langinfo_yesexpr],
82 [AC_LANG_PROGRAM([[#include <langinfo.h>
85 [gl_cv_header_langinfo_yesexpr=yes],
86 [gl_cv_header_langinfo_yesexpr=no])
88 if test $gl_cv_header_langinfo_yesexpr = yes; then
89 HAVE_LANGINFO_YESEXPR=1
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])
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>
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],
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])
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],
125 m4_defun(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS], [
126 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NL_LANGINFO])
128 m4_require(GL_MODULE_INDICATOR_PREFIX[_LANGINFO_H_MODULE_INDICATOR_DEFAULTS])
129 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
132 AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
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])