locale_h.m4 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. # locale_h.m4 serial 28
  2. dnl Copyright (C) 2007, 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_LOCALE_H],
  7. [
  8. dnl Ensure to expand the default settings once only, before all statements
  9. dnl 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. # gl_LOCALE_MODULE_INDICATOR([modulename])
  120. # sets the shell variable that indicates the presence of the given module
  121. # to a C preprocessor expression that will evaluate to 1.
  122. # This macro invocation must not occur in macros that are AC_REQUIREd.
  123. AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
  124. [
  125. dnl Ensure to expand the default settings once only.
  126. gl_LOCALE_H_REQUIRE_DEFAULTS
  127. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  128. dnl Define it also as a C macro, for the benefit of the unit tests.
  129. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  130. ])
  131. # Initializes the default values for AC_SUBSTed shell variables.
  132. # This macro must not be AC_REQUIREd. It must only be invoked, and only
  133. # outside of macros or in macros that are not AC_REQUIREd.
  134. AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS],
  135. [
  136. m4_defun(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS], [
  137. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALECONV])
  138. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE])
  139. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL])
  140. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE])
  141. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME])
  142. ])
  143. m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS])
  144. AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
  145. ])
  146. AC_DEFUN([gl_LOCALE_H_DEFAULTS],
  147. [
  148. dnl Assume proper GNU behavior unless another module says otherwise.
  149. HAVE_NEWLOCALE=1; AC_SUBST([HAVE_NEWLOCALE])
  150. HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
  151. HAVE_FREELOCALE=1; AC_SUBST([HAVE_FREELOCALE])
  152. REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
  153. REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
  154. REPLACE_NEWLOCALE=0; AC_SUBST([REPLACE_NEWLOCALE])
  155. REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
  156. REPLACE_FREELOCALE=0; AC_SUBST([REPLACE_FREELOCALE])
  157. REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
  158. LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS])
  159. ])