Home | History | Annotate | Line # | Download | only in m4
      1  1.1.1.2  christos # locale_h.m4 serial 28
      2  1.1.1.2  christos dnl Copyright (C) 2007, 2009-2022 Free Software Foundation, Inc.
      3      1.1  christos dnl This file is free software; the Free Software Foundation
      4      1.1  christos dnl gives unlimited permission to copy and/or distribute it,
      5      1.1  christos dnl with or without modifications, as long as this notice is preserved.
      6      1.1  christos 
      7  1.1.1.2  christos AC_DEFUN_ONCE([gl_LOCALE_H],
      8      1.1  christos [
      9  1.1.1.2  christos   dnl Ensure to expand the default settings once only, before all statements
     10  1.1.1.2  christos   dnl that occur in other macros.
     11      1.1  christos   AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
     12      1.1  christos 
     13      1.1  christos   dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_*
     14      1.1  christos   dnl members of 'struct lconv'.
     15      1.1  christos   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
     16      1.1  christos 
     17      1.1  christos   dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
     18      1.1  christos   AC_REQUIRE([gl_STDDEF_H])
     19      1.1  christos 
     20      1.1  christos   AC_REQUIRE([gl_LOCALE_T])
     21      1.1  christos 
     22      1.1  christos   dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv'
     23      1.1  christos   dnl only if _LCONV_C99 is defined.
     24      1.1  christos   AC_REQUIRE([AC_CANONICAL_HOST])
     25      1.1  christos   case "$host_os" in
     26      1.1  christos     solaris*)
     27      1.1  christos       AC_DEFINE([_LCONV_C99], [1], [Define to 1 on Solaris.])
     28      1.1  christos       ;;
     29      1.1  christos   esac
     30      1.1  christos 
     31      1.1  christos   AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
     32      1.1  christos     [gl_cv_header_locale_h_posix2001],
     33      1.1  christos     [AC_COMPILE_IFELSE(
     34      1.1  christos        [AC_LANG_PROGRAM(
     35      1.1  christos           [[#include <locale.h>
     36      1.1  christos             int x = LC_MESSAGES;
     37      1.1  christos             int y = sizeof (((struct lconv *) 0)->decimal_point);]],
     38      1.1  christos           [[]])],
     39      1.1  christos        [gl_cv_header_locale_h_posix2001=yes],
     40      1.1  christos        [gl_cv_header_locale_h_posix2001=no])])
     41      1.1  christos 
     42      1.1  christos   dnl Check whether 'struct lconv' is complete.
     43      1.1  christos   dnl Bionic libc's 'struct lconv' is just a dummy.
     44      1.1  christos   dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
     45      1.1  christos   dnl mingw, MSVC 9, it lacks the int_p_* and int_n_* members.
     46      1.1  christos   AC_CACHE_CHECK([whether struct lconv is properly defined],
     47      1.1  christos     [gl_cv_sys_struct_lconv_ok],
     48      1.1  christos     [AC_COMPILE_IFELSE(
     49      1.1  christos        [AC_LANG_PROGRAM(
     50      1.1  christos           [[#include <locale.h>
     51      1.1  christos             struct lconv l;
     52      1.1  christos             int x = sizeof (l.decimal_point);
     53      1.1  christos             int y = sizeof (l.int_p_cs_precedes);]],
     54      1.1  christos           [[]])],
     55      1.1  christos        [gl_cv_sys_struct_lconv_ok=yes],
     56      1.1  christos        [gl_cv_sys_struct_lconv_ok=no])
     57      1.1  christos     ])
     58      1.1  christos   if test $gl_cv_sys_struct_lconv_ok = no; then
     59      1.1  christos     dnl On native Windows with MSVC, merely define these member names as macros.
     60      1.1  christos     dnl This avoids trouble in C++ mode.
     61      1.1  christos     case "$host_os" in
     62      1.1  christos       mingw*)
     63      1.1  christos         AC_EGREP_CPP([Special], [
     64      1.1  christos #ifdef _MSC_VER
     65      1.1  christos  Special
     66      1.1  christos #endif
     67      1.1  christos           ],
     68      1.1  christos           [],
     69      1.1  christos           [REPLACE_STRUCT_LCONV=1])
     70      1.1  christos         ;;
     71      1.1  christos       *) REPLACE_STRUCT_LCONV=1 ;;
     72      1.1  christos     esac
     73      1.1  christos   fi
     74      1.1  christos 
     75      1.1  christos   dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
     76      1.1  christos   gl_NEXT_HEADERS([locale.h])
     77      1.1  christos 
     78      1.1  christos   dnl Check for declarations of anything we want to poison if the
     79      1.1  christos   dnl corresponding gnulib module is not in use.
     80      1.1  christos   gl_WARN_ON_USE_PREPARE([[#include <locale.h>
     81      1.1  christos /* Some systems provide declarations in a non-standard header.  */
     82      1.1  christos #if HAVE_XLOCALE_H
     83      1.1  christos # include <xlocale.h>
     84      1.1  christos #endif
     85      1.1  christos     ]],
     86      1.1  christos     [setlocale newlocale duplocale freelocale])
     87      1.1  christos ])
     88      1.1  christos 
     89      1.1  christos dnl Checks to determine whether the system has the locale_t type,
     90      1.1  christos dnl and how to obtain it.
     91      1.1  christos AC_DEFUN([gl_LOCALE_T],
     92      1.1  christos [
     93      1.1  christos   dnl Persuade glibc and Solaris <locale.h> to define locale_t.
     94      1.1  christos   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
     95      1.1  christos 
     96      1.1  christos   dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
     97      1.1  christos   dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
     98      1.1  christos   dnl itself, we assume that <xlocale.h> will do so.
     99      1.1  christos   AC_CACHE_CHECK([whether locale.h defines locale_t],
    100      1.1  christos     [gl_cv_header_locale_has_locale_t],
    101      1.1  christos     [AC_COMPILE_IFELSE(
    102      1.1  christos        [AC_LANG_PROGRAM(
    103      1.1  christos           [[#include <locale.h>
    104      1.1  christos             locale_t x;]],
    105      1.1  christos           [[]])],
    106      1.1  christos        [gl_cv_header_locale_has_locale_t=yes],
    107      1.1  christos        [gl_cv_header_locale_has_locale_t=no])
    108      1.1  christos     ])
    109      1.1  christos 
    110      1.1  christos   dnl Check for <xlocale.h>.
    111      1.1  christos   AC_CHECK_HEADERS_ONCE([xlocale.h])
    112      1.1  christos   if test $ac_cv_header_xlocale_h = yes; then
    113      1.1  christos     HAVE_XLOCALE_H=1
    114      1.1  christos     if test $gl_cv_header_locale_has_locale_t = yes; then
    115      1.1  christos       gl_cv_header_locale_h_needs_xlocale_h=no
    116      1.1  christos     else
    117      1.1  christos       gl_cv_header_locale_h_needs_xlocale_h=yes
    118      1.1  christos     fi
    119      1.1  christos     HAVE_LOCALE_T=1
    120      1.1  christos   else
    121      1.1  christos     HAVE_XLOCALE_H=0
    122      1.1  christos     gl_cv_header_locale_h_needs_xlocale_h=no
    123      1.1  christos     if test $gl_cv_header_locale_has_locale_t = yes; then
    124      1.1  christos       HAVE_LOCALE_T=1
    125      1.1  christos     else
    126      1.1  christos       HAVE_LOCALE_T=0
    127      1.1  christos     fi
    128      1.1  christos   fi
    129      1.1  christos   AC_SUBST([HAVE_XLOCALE_H])
    130      1.1  christos ])
    131      1.1  christos 
    132  1.1.1.2  christos # gl_LOCALE_MODULE_INDICATOR([modulename])
    133  1.1.1.2  christos # sets the shell variable that indicates the presence of the given module
    134  1.1.1.2  christos # to a C preprocessor expression that will evaluate to 1.
    135  1.1.1.2  christos # This macro invocation must not occur in macros that are AC_REQUIREd.
    136      1.1  christos AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
    137      1.1  christos [
    138  1.1.1.2  christos   dnl Ensure to expand the default settings once only.
    139  1.1.1.2  christos   gl_LOCALE_H_REQUIRE_DEFAULTS
    140      1.1  christos   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
    141      1.1  christos   dnl Define it also as a C macro, for the benefit of the unit tests.
    142      1.1  christos   gl_MODULE_INDICATOR_FOR_TESTS([$1])
    143      1.1  christos ])
    144      1.1  christos 
    145  1.1.1.2  christos # Initializes the default values for AC_SUBSTed shell variables.
    146  1.1.1.2  christos # This macro must not be AC_REQUIREd.  It must only be invoked, and only
    147  1.1.1.2  christos # outside of macros or in macros that are not AC_REQUIREd.
    148  1.1.1.2  christos AC_DEFUN([gl_LOCALE_H_REQUIRE_DEFAULTS],
    149  1.1.1.2  christos [
    150  1.1.1.2  christos   m4_defun(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS], [
    151  1.1.1.2  christos     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALECONV])
    152  1.1.1.2  christos     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE])
    153  1.1.1.2  christos     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETLOCALE_NULL])
    154  1.1.1.2  christos     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUPLOCALE])
    155  1.1.1.2  christos     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALENAME])
    156  1.1.1.2  christos   ])
    157  1.1.1.2  christos   m4_require(GL_MODULE_INDICATOR_PREFIX[_LOCALE_H_MODULE_INDICATOR_DEFAULTS])
    158  1.1.1.2  christos   AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
    159  1.1.1.2  christos ])
    160  1.1.1.2  christos 
    161      1.1  christos AC_DEFUN([gl_LOCALE_H_DEFAULTS],
    162      1.1  christos [
    163      1.1  christos   dnl Assume proper GNU behavior unless another module says otherwise.
    164      1.1  christos   HAVE_NEWLOCALE=1;       AC_SUBST([HAVE_NEWLOCALE])
    165      1.1  christos   HAVE_DUPLOCALE=1;       AC_SUBST([HAVE_DUPLOCALE])
    166      1.1  christos   HAVE_FREELOCALE=1;      AC_SUBST([HAVE_FREELOCALE])
    167      1.1  christos   REPLACE_LOCALECONV=0;   AC_SUBST([REPLACE_LOCALECONV])
    168      1.1  christos   REPLACE_SETLOCALE=0;    AC_SUBST([REPLACE_SETLOCALE])
    169      1.1  christos   REPLACE_NEWLOCALE=0;    AC_SUBST([REPLACE_NEWLOCALE])
    170      1.1  christos   REPLACE_DUPLOCALE=0;    AC_SUBST([REPLACE_DUPLOCALE])
    171      1.1  christos   REPLACE_FREELOCALE=0;   AC_SUBST([REPLACE_FREELOCALE])
    172      1.1  christos   REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
    173  1.1.1.2  christos   LOCALENAME_ENHANCE_LOCALE_FUNCS=0; AC_SUBST([LOCALENAME_ENHANCE_LOCALE_FUNCS])
    174      1.1  christos ])
    175