Blame m4/locale_h.m4

Packit 33f14e
# locale_h.m4 serial 19
Packit 33f14e
dnl Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
Packit 33f14e
dnl This file is free software; the Free Software Foundation
Packit 33f14e
dnl gives unlimited permission to copy and/or distribute it,
Packit 33f14e
dnl with or without modifications, as long as this notice is preserved.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_LOCALE_H],
Packit 33f14e
[
Packit 33f14e
  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
Packit 33f14e
  dnl once only, before all statements that occur in other macros.
Packit 33f14e
  AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
Packit 33f14e
Packit 33f14e
  dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_*
Packit 33f14e
  dnl members of 'struct lconv'.
Packit 33f14e
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
Packit 33f14e
Packit 33f14e
  dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
Packit 33f14e
  AC_REQUIRE([gl_STDDEF_H])
Packit 33f14e
Packit 33f14e
  dnl Solaris 11 2011-11 defines the int_p_*, int_n_* members of 'struct lconv'
Packit 33f14e
  dnl only if _LCONV_C99 is defined.
Packit 33f14e
  AC_REQUIRE([AC_CANONICAL_HOST])
Packit 33f14e
  case "$host_os" in
Packit 33f14e
    solaris*)
Packit 33f14e
      AC_DEFINE([_LCONV_C99], [1], [Define to 1 on Solaris.])
Packit 33f14e
      ;;
Packit 33f14e
  esac
Packit 33f14e
Packit 33f14e
  AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
Packit 33f14e
    [gl_cv_header_locale_h_posix2001],
Packit 33f14e
    [AC_COMPILE_IFELSE(
Packit 33f14e
       [AC_LANG_PROGRAM(
Packit 33f14e
          [[#include <locale.h>
Packit 33f14e
            int x = LC_MESSAGES;
Packit 33f14e
            int y = sizeof (((struct lconv *) 0)->decimal_point);]],
Packit 33f14e
          [[]])],
Packit 33f14e
       [gl_cv_header_locale_h_posix2001=yes],
Packit 33f14e
       [gl_cv_header_locale_h_posix2001=no])])
Packit 33f14e
Packit 33f14e
  dnl Check for <xlocale.h>.
Packit 33f14e
  AC_CHECK_HEADERS_ONCE([xlocale.h])
Packit 33f14e
  if test $ac_cv_header_xlocale_h = yes; then
Packit 33f14e
    HAVE_XLOCALE_H=1
Packit 33f14e
    dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
Packit 33f14e
    dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
Packit 33f14e
    dnl itself, we assume that <xlocale.h> will do so.
Packit 33f14e
    AC_CACHE_CHECK([whether locale.h defines locale_t],
Packit 33f14e
      [gl_cv_header_locale_has_locale_t],
Packit 33f14e
      [AC_COMPILE_IFELSE(
Packit 33f14e
         [AC_LANG_PROGRAM(
Packit 33f14e
            [[#include <locale.h>
Packit 33f14e
              locale_t x;]],
Packit 33f14e
            [[]])],
Packit 33f14e
         [gl_cv_header_locale_has_locale_t=yes],
Packit 33f14e
         [gl_cv_header_locale_has_locale_t=no])
Packit 33f14e
      ])
Packit 33f14e
    if test $gl_cv_header_locale_has_locale_t = yes; then
Packit 33f14e
      gl_cv_header_locale_h_needs_xlocale_h=no
Packit 33f14e
    else
Packit 33f14e
      gl_cv_header_locale_h_needs_xlocale_h=yes
Packit 33f14e
    fi
Packit 33f14e
  else
Packit 33f14e
    HAVE_XLOCALE_H=0
Packit 33f14e
    gl_cv_header_locale_h_needs_xlocale_h=no
Packit 33f14e
  fi
Packit 33f14e
  AC_SUBST([HAVE_XLOCALE_H])
Packit 33f14e
Packit 33f14e
  dnl Check whether 'struct lconv' is complete.
Packit 33f14e
  dnl Bionic libc's 'struct lconv' is just a dummy.
Packit 33f14e
  dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
Packit 33f14e
  dnl mingw, MSVC 9, it lacks the int_p_* and int_n_* members.
Packit 33f14e
  AC_CACHE_CHECK([whether struct lconv is properly defined],
Packit 33f14e
    [gl_cv_sys_struct_lconv_ok],
Packit 33f14e
    [AC_COMPILE_IFELSE(
Packit 33f14e
       [AC_LANG_PROGRAM(
Packit 33f14e
          [[#include <locale.h>
Packit 33f14e
            struct lconv l;
Packit 33f14e
            int x = sizeof (l.decimal_point);
Packit 33f14e
            int y = sizeof (l.int_p_cs_precedes);]],
Packit 33f14e
          [[]])],
Packit 33f14e
       [gl_cv_sys_struct_lconv_ok=yes],
Packit 33f14e
       [gl_cv_sys_struct_lconv_ok=no])
Packit 33f14e
    ])
Packit 33f14e
  if test $gl_cv_sys_struct_lconv_ok = no; then
Packit 33f14e
    REPLACE_STRUCT_LCONV=1
Packit 33f14e
  fi
Packit 33f14e
Packit 33f14e
  dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
Packit 33f14e
  gl_NEXT_HEADERS([locale.h])
Packit 33f14e
Packit 33f14e
  dnl Check for declarations of anything we want to poison if the
Packit 33f14e
  dnl corresponding gnulib module is not in use.
Packit 33f14e
  gl_WARN_ON_USE_PREPARE([[#include <locale.h>
Packit 33f14e
/* Some systems provide declarations in a non-standard header.  */
Packit 33f14e
#if HAVE_XLOCALE_H
Packit 33f14e
# include <xlocale.h>
Packit 33f14e
#endif
Packit 33f14e
    ]],
Packit 33f14e
    [setlocale duplocale])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
Packit 33f14e
[
Packit 33f14e
  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
Packit 33f14e
  AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
Packit 33f14e
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
Packit 33f14e
  dnl Define it also as a C macro, for the benefit of the unit tests.
Packit 33f14e
  gl_MODULE_INDICATOR_FOR_TESTS([$1])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_LOCALE_H_DEFAULTS],
Packit 33f14e
[
Packit 33f14e
  GNULIB_LOCALECONV=0; AC_SUBST([GNULIB_LOCALECONV])
Packit 33f14e
  GNULIB_SETLOCALE=0;  AC_SUBST([GNULIB_SETLOCALE])
Packit 33f14e
  GNULIB_DUPLOCALE=0;  AC_SUBST([GNULIB_DUPLOCALE])
Packit 33f14e
  dnl Assume proper GNU behavior unless another module says otherwise.
Packit 33f14e
  HAVE_DUPLOCALE=1;       AC_SUBST([HAVE_DUPLOCALE])
Packit 33f14e
  REPLACE_LOCALECONV=0;   AC_SUBST([REPLACE_LOCALECONV])
Packit 33f14e
  REPLACE_SETLOCALE=0;    AC_SUBST([REPLACE_SETLOCALE])
Packit 33f14e
  REPLACE_DUPLOCALE=0;    AC_SUBST([REPLACE_DUPLOCALE])
Packit 33f14e
  REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
Packit 33f14e
])