]> git.cworth.org Git - tar/blob - m4/wchar.m4
Imported Upstream version 1.21
[tar] / m4 / wchar.m4
1 dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
2
3 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl Written by Eric Blake.
9
10 # wchar.m4 serial 6
11
12 AC_DEFUN([gl_WCHAR_H],
13 [
14   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
15   AC_CACHE_CHECK([whether <wchar.h> is standalone],
16     [gl_cv_header_wchar_h_standalone],
17     [AC_COMPILE_IFELSE([[#include <wchar.h>
18 wchar_t w;]],
19       [gl_cv_header_wchar_h_standalone=yes],
20       [gl_cv_header_wchar_h_standalone=no])])
21
22   AC_REQUIRE([gt_TYPE_WINT_T])
23   if test $gt_cv_c_wint_t = yes; then
24     HAVE_WINT_T=1
25   else
26     HAVE_WINT_T=0
27   fi
28   AC_SUBST([HAVE_WINT_T])
29
30   if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes; then
31     WCHAR_H=wchar.h
32   fi
33
34   dnl Prepare for creating substitute <wchar.h>.
35   dnl Do it always: WCHAR_H may be empty here but can be set later.
36   dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
37   dnl character support).
38   AC_CHECK_HEADERS_ONCE([wchar.h])
39   if test $ac_cv_header_wchar_h = yes; then
40     HAVE_WCHAR_H=1
41   else
42     HAVE_WCHAR_H=0
43   fi
44   AC_SUBST([HAVE_WCHAR_H])
45   gl_CHECK_NEXT_HEADERS([wchar.h])
46 ])
47
48 dnl Unconditionally enables the replacement of <wchar.h>.
49 AC_DEFUN([gl_REPLACE_WCHAR_H],
50 [
51   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
52   WCHAR_H=wchar.h
53 ])
54
55 AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
56 [
57   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
58   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
59   GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
60 ])
61
62 AC_DEFUN([gl_WCHAR_H_DEFAULTS],
63 [
64   GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
65   dnl Assume proper GNU behavior unless another module says otherwise.
66   HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
67   REPLACE_WCWIDTH=0;   AC_SUBST([REPLACE_WCWIDTH])
68   WCHAR_H='';          AC_SUBST([WCHAR_H])
69 ])