langinfo_h.m4 4.7 KB

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