langinfo_h.m4 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. # langinfo_h.m4 serial 7
  2. dnl Copyright (C) 2009-2013 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_ERA=0
  17. HAVE_LANGINFO_YESEXPR=0
  18. AC_CHECK_HEADERS_ONCE([langinfo.h])
  19. if test $ac_cv_header_langinfo_h = yes; then
  20. HAVE_LANGINFO_H=1
  21. dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing
  22. dnl on OpenBSD 3.8. T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3.
  23. AC_CACHE_CHECK([whether langinfo.h defines CODESET],
  24. [gl_cv_header_langinfo_codeset],
  25. [AC_COMPILE_IFELSE(
  26. [AC_LANG_PROGRAM([[#include <langinfo.h>
  27. int a = CODESET;
  28. ]])],
  29. [gl_cv_header_langinfo_codeset=yes],
  30. [gl_cv_header_langinfo_codeset=no])
  31. ])
  32. if test $gl_cv_header_langinfo_codeset = yes; then
  33. HAVE_LANGINFO_CODESET=1
  34. fi
  35. AC_CACHE_CHECK([whether langinfo.h defines T_FMT_AMPM],
  36. [gl_cv_header_langinfo_t_fmt_ampm],
  37. [AC_COMPILE_IFELSE(
  38. [AC_LANG_PROGRAM([[#include <langinfo.h>
  39. int a = T_FMT_AMPM;
  40. ]])],
  41. [gl_cv_header_langinfo_t_fmt_ampm=yes],
  42. [gl_cv_header_langinfo_t_fmt_ampm=no])
  43. ])
  44. if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
  45. HAVE_LANGINFO_T_FMT_AMPM=1
  46. fi
  47. AC_CACHE_CHECK([whether langinfo.h defines ERA],
  48. [gl_cv_header_langinfo_era],
  49. [AC_COMPILE_IFELSE(
  50. [AC_LANG_PROGRAM([[#include <langinfo.h>
  51. int a = ERA;
  52. ]])],
  53. [gl_cv_header_langinfo_era=yes],
  54. [gl_cv_header_langinfo_era=no])
  55. ])
  56. if test $gl_cv_header_langinfo_era = yes; then
  57. HAVE_LANGINFO_ERA=1
  58. fi
  59. AC_CACHE_CHECK([whether langinfo.h defines YESEXPR],
  60. [gl_cv_header_langinfo_yesexpr],
  61. [AC_COMPILE_IFELSE(
  62. [AC_LANG_PROGRAM([[#include <langinfo.h>
  63. int a = YESEXPR;
  64. ]])],
  65. [gl_cv_header_langinfo_yesexpr=yes],
  66. [gl_cv_header_langinfo_yesexpr=no])
  67. ])
  68. if test $gl_cv_header_langinfo_yesexpr = yes; then
  69. HAVE_LANGINFO_YESEXPR=1
  70. fi
  71. else
  72. HAVE_LANGINFO_H=0
  73. fi
  74. AC_SUBST([HAVE_LANGINFO_H])
  75. AC_SUBST([HAVE_LANGINFO_CODESET])
  76. AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM])
  77. AC_SUBST([HAVE_LANGINFO_ERA])
  78. AC_SUBST([HAVE_LANGINFO_YESEXPR])
  79. dnl Check for declarations of anything we want to poison if the
  80. dnl corresponding gnulib module is not in use.
  81. gl_WARN_ON_USE_PREPARE([[#include <langinfo.h>
  82. ]], [nl_langinfo])
  83. ])
  84. AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
  85. [
  86. dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  87. AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
  88. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  89. dnl Define it also as a C macro, for the benefit of the unit tests.
  90. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  91. ])
  92. AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
  93. [
  94. GNULIB_NL_LANGINFO=0; AC_SUBST([GNULIB_NL_LANGINFO])
  95. dnl Assume proper GNU behavior unless another module says otherwise.
  96. HAVE_NL_LANGINFO=1; AC_SUBST([HAVE_NL_LANGINFO])
  97. REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
  98. ])