]> sjero.net Git - wget/blob - m4/wchar.m4
d0aae6e1c2706173c4e0b57bc454bf1751d57531
[wget] / m4 / wchar.m4
1 dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
2
3 dnl Copyright (C) 2007, 2008, 2009, 2010 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 25
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   dnl If <stddef.h> is replaced, then <wchar.h> must also be replaced.
31   AC_REQUIRE([gl_STDDEF_H])
32
33   if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes || test -n "$STDDEF_H"; then
34     WCHAR_H=wchar.h
35   fi
36
37   dnl Prepare for creating substitute <wchar.h>.
38   dnl Do it always: WCHAR_H may be empty here but can be set later.
39   dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
40   dnl character support).
41   AC_CHECK_HEADERS_ONCE([wchar.h])
42   if test $ac_cv_header_wchar_h = yes; then
43     HAVE_WCHAR_H=1
44   else
45     HAVE_WCHAR_H=0
46   fi
47   AC_SUBST([HAVE_WCHAR_H])
48   gl_CHECK_NEXT_HEADERS([wchar.h])
49 ])
50
51 dnl Unconditionally enables the replacement of <wchar.h>.
52 AC_DEFUN([gl_REPLACE_WCHAR_H],
53 [
54   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
55   WCHAR_H=wchar.h
56 ])
57
58 AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
59 [
60   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
61   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
62   GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
63 ])
64
65 AC_DEFUN([gl_WCHAR_H_DEFAULTS],
66 [
67   GNULIB_BTOWC=0;      AC_SUBST([GNULIB_BTOWC])
68   GNULIB_WCTOB=0;      AC_SUBST([GNULIB_WCTOB])
69   GNULIB_MBSINIT=0;    AC_SUBST([GNULIB_MBSINIT])
70   GNULIB_MBRTOWC=0;    AC_SUBST([GNULIB_MBRTOWC])
71   GNULIB_MBRLEN=0;     AC_SUBST([GNULIB_MBRLEN])
72   GNULIB_MBSRTOWCS=0;  AC_SUBST([GNULIB_MBSRTOWCS])
73   GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
74   GNULIB_WCRTOMB=0;    AC_SUBST([GNULIB_WCRTOMB])
75   GNULIB_WCSRTOMBS=0;  AC_SUBST([GNULIB_WCSRTOMBS])
76   GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
77   GNULIB_WCWIDTH=0;    AC_SUBST([GNULIB_WCWIDTH])
78   dnl Assume proper GNU behavior unless another module says otherwise.
79   HAVE_BTOWC=1;         AC_SUBST([HAVE_BTOWC])
80   HAVE_MBSINIT=1;       AC_SUBST([HAVE_MBSINIT])
81   HAVE_MBRTOWC=1;       AC_SUBST([HAVE_MBRTOWC])
82   HAVE_MBRLEN=1;        AC_SUBST([HAVE_MBRLEN])
83   HAVE_MBSRTOWCS=1;     AC_SUBST([HAVE_MBSRTOWCS])
84   HAVE_MBSNRTOWCS=1;    AC_SUBST([HAVE_MBSNRTOWCS])
85   HAVE_WCRTOMB=1;       AC_SUBST([HAVE_WCRTOMB])
86   HAVE_WCSRTOMBS=1;     AC_SUBST([HAVE_WCSRTOMBS])
87   HAVE_WCSNRTOMBS=1;    AC_SUBST([HAVE_WCSNRTOMBS])
88   HAVE_DECL_WCTOB=1;    AC_SUBST([HAVE_DECL_WCTOB])
89   HAVE_DECL_WCWIDTH=1;  AC_SUBST([HAVE_DECL_WCWIDTH])
90   REPLACE_MBSTATE_T=0;  AC_SUBST([REPLACE_MBSTATE_T])
91   REPLACE_BTOWC=0;      AC_SUBST([REPLACE_BTOWC])
92   REPLACE_WCTOB=0;      AC_SUBST([REPLACE_WCTOB])
93   REPLACE_MBSINIT=0;    AC_SUBST([REPLACE_MBSINIT])
94   REPLACE_MBRTOWC=0;    AC_SUBST([REPLACE_MBRTOWC])
95   REPLACE_MBRLEN=0;     AC_SUBST([REPLACE_MBRLEN])
96   REPLACE_MBSRTOWCS=0;  AC_SUBST([REPLACE_MBSRTOWCS])
97   REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS])
98   REPLACE_WCRTOMB=0;    AC_SUBST([REPLACE_WCRTOMB])
99   REPLACE_WCSRTOMBS=0;  AC_SUBST([REPLACE_WCSRTOMBS])
100   REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
101   REPLACE_WCWIDTH=0;    AC_SUBST([REPLACE_WCWIDTH])
102   WCHAR_H='';           AC_SUBST([WCHAR_H])
103 ])