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