Blame m4/locale_h.m4

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