xref: /Universal-ctags/m4/nl_langinfo.m4 (revision 820c1a8d46849a90376d8eb15b319ac05439f656)
1# nl_langinfo.m4 serial 8
2dnl Copyright (C) 2009-2021 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_NL_LANGINFO],
8[
9  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10  AC_REQUIRE([gl_LANGINFO_H])
11  AC_CHECK_FUNCS_ONCE([nl_langinfo])
12  AC_REQUIRE([AC_CANONICAL_HOST])
13  AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
14  AC_REQUIRE([gl_PTHREADLIB])
15  AC_CHECK_HEADERS_ONCE([threads.h])
16  if test $ac_cv_func_nl_langinfo = yes; then
17    # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken.
18    AC_CACHE_CHECK([whether YESEXPR works],
19      [gl_cv_func_nl_langinfo_yesexpr_works],
20      [AC_RUN_IFELSE(
21         [AC_LANG_PROGRAM([[#include <langinfo.h>
22]], [[return !*nl_langinfo(YESEXPR);
23]])],
24         [gl_cv_func_nl_langinfo_yesexpr_works=yes],
25         [gl_cv_func_nl_langinfo_yesexpr_works=no],
26         [
27         case "$host_os" in
28                   # Guess no on irix systems.
29           irix*)  gl_cv_func_nl_langinfo_yesexpr_works="guessing no";;
30                   # Guess yes elsewhere.
31           *)      gl_cv_func_nl_langinfo_yesexpr_works="guessing yes";;
32         esac
33         ])
34      ])
35    case $gl_cv_func_nl_langinfo_yesexpr_works in
36      *yes) FUNC_NL_LANGINFO_YESEXPR_WORKS=1 ;;
37      *)    FUNC_NL_LANGINFO_YESEXPR_WORKS=0 ;;
38    esac
39    AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS],
40      [$FUNC_NL_LANGINFO_YESEXPR_WORKS],
41      [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.])
42    # On Solaris 10 and Solaris 11.3, nl_langinfo is not multithread-safe.
43    case "$host_os" in
44      solaris*) NL_LANGINFO_MTSAFE=0 ;;
45      *)        NL_LANGINFO_MTSAFE=1 ;;
46    esac
47    AC_DEFINE_UNQUOTED([NL_LANGINFO_MTSAFE], [$NL_LANGINFO_MTSAFE],
48      [Define to 1 if nl_langinfo is multithread-safe.])
49    if test $HAVE_LANGINFO_CODESET = 1 \
50       && test $HAVE_LANGINFO_T_FMT_AMPM = 1 \
51       && test $HAVE_LANGINFO_ALTMON = 1 \
52       && test $HAVE_LANGINFO_ERA = 1 \
53       && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1 \
54       && test $NL_LANGINFO_MTSAFE = 1; then
55      :
56    else
57      REPLACE_NL_LANGINFO=1
58      AC_DEFINE([REPLACE_NL_LANGINFO], [1],
59        [Define if nl_langinfo exists but is overridden by gnulib.])
60    fi
61  else
62    HAVE_NL_LANGINFO=0
63  fi
64  if test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0; then
65    LIB_NL_LANGINFO="$LIB_SETLOCALE_NULL"
66  else
67    LIB_NL_LANGINFO=
68  fi
69  dnl LIB_NL_LANGINFO is expected to be empty everywhere.
70  AC_SUBST([LIB_NL_LANGINFO])
71])
72
73# Prerequisites of lib/nl_langinfo-lock.c.
74AC_DEFUN([gl_PREREQ_NL_LANGINFO_LOCK],
75[
76  gl_VISIBILITY
77])
78