locale_h.m4 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # locale_h.m4 serial 24
  2. dnl Copyright (C) 2007, 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_LOCALE_H],
  7. [
  8. dnl Use AC_REQUIRE here, so that the default behavior below is expanded
  9. dnl once only, before all statements that occur in other macros.
  10. AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
  11. dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_*
  12. dnl members of 'struct lconv'.
  13. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  14. dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
  15. AC_REQUIRE([gl_STDDEF_H])
  16. AC_REQUIRE([gl_LOCALE_T])
  17. dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv'
  18. dnl only if _LCONV_C99 is defined.
  19. AC_REQUIRE([AC_CANONICAL_HOST])
  20. case "$host_os" in
  21. solaris*)
  22. AC_DEFINE([_LCONV_C99], [1], [Define to 1 on Solaris.])
  23. ;;
  24. esac
  25. AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
  26. [gl_cv_header_locale_h_posix2001],
  27. [AC_COMPILE_IFELSE(
  28. [AC_LANG_PROGRAM(
  29. [[#include <locale.h>
  30. int x = LC_MESSAGES;
  31. int y = sizeof (((struct lconv *) 0)->decimal_point);]],
  32. [[]])],
  33. [gl_cv_header_locale_h_posix2001=yes],
  34. [gl_cv_header_locale_h_posix2001=no])])
  35. dnl Check whether 'struct lconv' is complete.
  36. dnl Bionic libc's 'struct lconv' is just a dummy.
  37. dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
  38. dnl mingw, MSVC 9, it lacks the int_p_* and int_n_* members.
  39. AC_CACHE_CHECK([whether struct lconv is properly defined],
  40. [gl_cv_sys_struct_lconv_ok],
  41. [AC_COMPILE_IFELSE(
  42. [AC_LANG_PROGRAM(
  43. [[#include <locale.h>
  44. struct lconv l;
  45. int x = sizeof (l.decimal_point);
  46. int y = sizeof (l.int_p_cs_precedes);]],
  47. [[]])],
  48. [gl_cv_sys_struct_lconv_ok=yes],
  49. [gl_cv_sys_struct_lconv_ok=no])
  50. ])
  51. if test $gl_cv_sys_struct_lconv_ok = no; then
  52. dnl On native Windows with MSVC, merely define these member names as macros.
  53. dnl This avoids trouble in C++ mode.
  54. case "$host_os" in
  55. mingw*)
  56. AC_EGREP_CPP([Special], [
  57. #ifdef _MSC_VER
  58. Special
  59. #endif
  60. ],
  61. [],
  62. [REPLACE_STRUCT_LCONV=1])
  63. ;;
  64. *) REPLACE_STRUCT_LCONV=1 ;;
  65. esac
  66. fi
  67. dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
  68. gl_NEXT_HEADERS([locale.h])
  69. dnl Check for declarations of anything we want to poison if the
  70. dnl corresponding gnulib module is not in use.
  71. gl_WARN_ON_USE_PREPARE([[#include <locale.h>
  72. /* Some systems provide declarations in a non-standard header. */
  73. #if HAVE_XLOCALE_H
  74. # include <xlocale.h>
  75. #endif
  76. ]],
  77. [setlocale newlocale duplocale freelocale])
  78. ])
  79. dnl Checks to determine whether the system has the locale_t type,
  80. dnl and how to obtain it.
  81. AC_DEFUN([gl_LOCALE_T],
  82. [
  83. dnl Persuade glibc and Solaris <locale.h> to define locale_t.
  84. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  85. dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
  86. dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
  87. dnl itself, we assume that <xlocale.h> will do so.
  88. AC_CACHE_CHECK([whether locale.h defines locale_t],
  89. [gl_cv_header_locale_has_locale_t],
  90. [AC_COMPILE_IFELSE(
  91. [AC_LANG_PROGRAM(
  92. [[#include <locale.h>
  93. locale_t x;]],
  94. [[]])],
  95. [gl_cv_header_locale_has_locale_t=yes],
  96. [gl_cv_header_locale_has_locale_t=no])
  97. ])
  98. dnl Check for <xlocale.h>.
  99. AC_CHECK_HEADERS_ONCE([xlocale.h])
  100. if test $ac_cv_header_xlocale_h = yes; then
  101. HAVE_XLOCALE_H=1
  102. if test $gl_cv_header_locale_has_locale_t = yes; then
  103. gl_cv_header_locale_h_needs_xlocale_h=no
  104. else
  105. gl_cv_header_locale_h_needs_xlocale_h=yes
  106. fi
  107. HAVE_LOCALE_T=1
  108. else
  109. HAVE_XLOCALE_H=0
  110. gl_cv_header_locale_h_needs_xlocale_h=no
  111. if test $gl_cv_header_locale_has_locale_t = yes; then
  112. HAVE_LOCALE_T=1
  113. else
  114. HAVE_LOCALE_T=0
  115. fi
  116. fi
  117. AC_SUBST([HAVE_XLOCALE_H])
  118. ])
  119. AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
  120. [
  121. dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  122. AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
  123. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  124. dnl Define it also as a C macro, for the benefit of the unit tests.
  125. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  126. ])
  127. AC_DEFUN([gl_LOCALE_H_DEFAULTS],
  128. [
  129. GNULIB_LOCALECONV=0; AC_SUBST([GNULIB_LOCALECONV])
  130. GNULIB_SETLOCALE=0; AC_SUBST([GNULIB_SETLOCALE])
  131. GNULIB_SETLOCALE_NULL=0; AC_SUBST([GNULIB_SETLOCALE_NULL])
  132. GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE])
  133. GNULIB_LOCALENAME=0; AC_SUBST([GNULIB_LOCALENAME])
  134. dnl Assume proper GNU behavior unless another module says otherwise.
  135. HAVE_NEWLOCALE=1; AC_SUBST([HAVE_NEWLOCALE])
  136. HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
  137. HAVE_FREELOCALE=1; AC_SUBST([HAVE_FREELOCALE])
  138. REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
  139. REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
  140. REPLACE_NEWLOCALE=0; AC_SUBST([REPLACE_NEWLOCALE])
  141. REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
  142. REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE])
  143. REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
  144. ])