]> git.cworth.org Git - tar/blob - m4/langinfo_h.m4
5e4922afd46984995881e908bb41e1697fa78a46
[tar] / m4 / langinfo_h.m4
1 # langinfo_h.m4 serial 4
2 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_LANGINFO_H],
8 [
9   AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10
11   dnl Persuade glibc-2.0.6 <langinfo.h> to define CODESET.
12   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
13
14   gl_CHECK_NEXT_HEADERS([langinfo.h])
15
16   dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
17   HAVE_LANGINFO_CODESET=0
18   HAVE_LANGINFO_ERA=0
19   AC_CHECK_HEADERS_ONCE([langinfo.h])
20   if test $ac_cv_header_langinfo_h = yes; then
21     HAVE_LANGINFO_H=1
22     dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing
23     dnl on OpenBSD 3.8.
24     AC_CACHE_CHECK([whether langinfo.h defines CODESET],
25       [gl_cv_header_langinfo_codeset],
26       [AC_COMPILE_IFELSE(
27          [AC_LANG_PROGRAM([[#include <langinfo.h>
28 int a = CODESET;
29 ]])],
30          [gl_cv_header_langinfo_codeset=yes],
31          [gl_cv_header_langinfo_codeset=no])
32       ])
33     if test $gl_cv_header_langinfo_codeset = yes; then
34       HAVE_LANGINFO_CODESET=1
35     fi
36     AC_CACHE_CHECK([whether langinfo.h defines ERA],
37       [gl_cv_header_langinfo_era],
38       [AC_COMPILE_IFELSE(
39          [AC_LANG_PROGRAM([[#include <langinfo.h>
40 int a = ERA;
41 ]])],
42          [gl_cv_header_langinfo_era=yes],
43          [gl_cv_header_langinfo_era=no])
44       ])
45     if test $gl_cv_header_langinfo_era = yes; then
46       HAVE_LANGINFO_ERA=1
47     fi
48   else
49     HAVE_LANGINFO_H=0
50   fi
51   AC_SUBST([HAVE_LANGINFO_H])
52   AC_SUBST([HAVE_LANGINFO_CODESET])
53   AC_SUBST([HAVE_LANGINFO_ERA])
54
55   dnl Check for declarations of anything we want to poison if the
56   dnl corresponding gnulib module is not in use.
57   gl_WARN_ON_USE_PREPARE([[#include <langinfo.h>
58     ]], [nl_langinfo])
59 ])
60
61 AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
62 [
63   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
64   AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
65   GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
66   dnl Define it also as a C macro, for the benefit of the unit tests.
67   gl_MODULE_INDICATOR([$1])
68 ])
69
70 AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
71 [
72   GNULIB_NL_LANGINFO=0;  AC_SUBST([GNULIB_NL_LANGINFO])
73   dnl Assume proper GNU behavior unless another module says otherwise.
74   HAVE_NL_LANGINFO=1;    AC_SUBST([HAVE_NL_LANGINFO])
75   REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
76 ])