1 # langinfo_h.m4 serial 9
2 dnl Copyright (C) 2009-2020 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([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 AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
109 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
110 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
111 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
112 dnl Define it also as a C macro, for the benefit of the unit tests.
113 gl_MODULE_INDICATOR_FOR_TESTS([$1])
116 AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
118 GNULIB_NL_LANGINFO=0; AC_SUBST([GNULIB_NL_LANGINFO])
119 dnl Assume proper GNU behavior unless another module says otherwise.
120 HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO])
121 REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])