Blame m4/locale_h.m4

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