locale_h.m4 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # locale_h.m4 serial 19
  2. dnl Copyright (C) 2007, 2009-2017 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. dnl Solaris 11 2011-11 defines the int_p_*, int_n_* members of 'struct lconv'
  17. dnl only if _LCONV_C99 is defined.
  18. AC_REQUIRE([AC_CANONICAL_HOST])
  19. case "$host_os" in
  20. solaris*)
  21. AC_DEFINE([_LCONV_C99], [1], [Define to 1 on Solaris.])
  22. ;;
  23. esac
  24. AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
  25. [gl_cv_header_locale_h_posix2001],
  26. [AC_COMPILE_IFELSE(
  27. [AC_LANG_PROGRAM(
  28. [[#include <locale.h>
  29. int x = LC_MESSAGES;
  30. int y = sizeof (((struct lconv *) 0)->decimal_point);]],
  31. [[]])],
  32. [gl_cv_header_locale_h_posix2001=yes],
  33. [gl_cv_header_locale_h_posix2001=no])])
  34. dnl Check for <xlocale.h>.
  35. AC_CHECK_HEADERS_ONCE([xlocale.h])
  36. if test $ac_cv_header_xlocale_h = yes; then
  37. HAVE_XLOCALE_H=1
  38. dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
  39. dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
  40. dnl itself, we assume that <xlocale.h> will do so.
  41. AC_CACHE_CHECK([whether locale.h defines locale_t],
  42. [gl_cv_header_locale_has_locale_t],
  43. [AC_COMPILE_IFELSE(
  44. [AC_LANG_PROGRAM(
  45. [[#include <locale.h>
  46. locale_t x;]],
  47. [[]])],
  48. [gl_cv_header_locale_has_locale_t=yes],
  49. [gl_cv_header_locale_has_locale_t=no])
  50. ])
  51. if test $gl_cv_header_locale_has_locale_t = yes; then
  52. gl_cv_header_locale_h_needs_xlocale_h=no
  53. else
  54. gl_cv_header_locale_h_needs_xlocale_h=yes
  55. fi
  56. else
  57. HAVE_XLOCALE_H=0
  58. gl_cv_header_locale_h_needs_xlocale_h=no
  59. fi
  60. AC_SUBST([HAVE_XLOCALE_H])
  61. dnl Check whether 'struct lconv' is complete.
  62. dnl Bionic libc's 'struct lconv' is just a dummy.
  63. dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
  64. dnl mingw, MSVC 9, it lacks the int_p_* and int_n_* members.
  65. AC_CACHE_CHECK([whether struct lconv is properly defined],
  66. [gl_cv_sys_struct_lconv_ok],
  67. [AC_COMPILE_IFELSE(
  68. [AC_LANG_PROGRAM(
  69. [[#include <locale.h>
  70. struct lconv l;
  71. int x = sizeof (l.decimal_point);
  72. int y = sizeof (l.int_p_cs_precedes);]],
  73. [[]])],
  74. [gl_cv_sys_struct_lconv_ok=yes],
  75. [gl_cv_sys_struct_lconv_ok=no])
  76. ])
  77. if test $gl_cv_sys_struct_lconv_ok = no; then
  78. REPLACE_STRUCT_LCONV=1
  79. fi
  80. dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
  81. gl_NEXT_HEADERS([locale.h])
  82. dnl Check for declarations of anything we want to poison if the
  83. dnl corresponding gnulib module is not in use.
  84. gl_WARN_ON_USE_PREPARE([[#include <locale.h>
  85. /* Some systems provide declarations in a non-standard header. */
  86. #if HAVE_XLOCALE_H
  87. # include <xlocale.h>
  88. #endif
  89. ]],
  90. [setlocale duplocale])
  91. ])
  92. AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
  93. [
  94. dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  95. AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
  96. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  97. dnl Define it also as a C macro, for the benefit of the unit tests.
  98. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  99. ])
  100. AC_DEFUN([gl_LOCALE_H_DEFAULTS],
  101. [
  102. GNULIB_LOCALECONV=0; AC_SUBST([GNULIB_LOCALECONV])
  103. GNULIB_SETLOCALE=0; AC_SUBST([GNULIB_SETLOCALE])
  104. GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE])
  105. dnl Assume proper GNU behavior unless another module says otherwise.
  106. HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
  107. REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
  108. REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
  109. REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
  110. REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
  111. ])