Blame m4/locale_h.m4

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