Blame m4/locale_h.m4

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