langinfo_h.m4 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # langinfo_h.m4 serial 9
  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. AC_DEFUN([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. AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
  102. [
  103. dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  104. AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
  105. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  106. dnl Define it also as a C macro, for the benefit of the unit tests.
  107. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  108. ])
  109. AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
  110. [
  111. GNULIB_NL_LANGINFO=0; AC_SUBST([GNULIB_NL_LANGINFO])
  112. dnl Assume proper GNU behavior unless another module says otherwise.
  113. HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO])
  114. REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
  115. ])