421
|
1 dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
|
|
2
|
|
3 dnl Copyright (C) 2007-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 30
|
|
11
|
|
12 AC_DEFUN([gl_WCHAR_H],
|
|
13 [
|
|
14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
|
15 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
|
|
16 dnl Prepare for creating substitute <wchar.h>.
|
|
17 dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
|
|
18 dnl character support).
|
|
19 dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
|
|
20 AC_CHECK_HEADERS_ONCE([wchar.h])
|
|
21 gl_CHECK_NEXT_HEADERS([wchar.h])
|
|
22 if test $ac_cv_header_wchar_h = yes; then
|
|
23 HAVE_WCHAR_H=1
|
|
24 else
|
|
25 HAVE_WCHAR_H=0
|
|
26 fi
|
|
27 AC_SUBST([HAVE_WCHAR_H])
|
|
28
|
|
29 AC_REQUIRE([gt_TYPE_WINT_T])
|
|
30 if test $gt_cv_c_wint_t = yes; then
|
|
31 HAVE_WINT_T=1
|
|
32 else
|
|
33 HAVE_WINT_T=0
|
|
34 fi
|
|
35 AC_SUBST([HAVE_WINT_T])
|
|
36 ])
|
|
37
|
|
38 dnl Check whether <wchar.h> is usable at all.
|
|
39 AC_DEFUN([gl_WCHAR_H_INLINE_OK],
|
|
40 [
|
|
41 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
|
|
42 dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022>
|
|
43 dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
|
|
44 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
|
|
45 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
|
|
46 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
|
|
47 [gl_cv_header_wchar_h_correct_inline],
|
|
48 [gl_cv_header_wchar_h_correct_inline=yes
|
|
49 AC_LANG_CONFTEST([
|
|
50 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
|
|
51 #include <wchar.h>
|
|
52 extern int zero (void);
|
|
53 int main () { return zero(); }
|
|
54 ]])])
|
|
55 if AC_TRY_EVAL([ac_compile]); then
|
|
56 mv conftest.$ac_objext conftest1.$ac_objext
|
|
57 AC_LANG_CONFTEST([
|
|
58 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
|
|
59 #include <wchar.h>
|
|
60 int zero (void) { return 0; }
|
|
61 ]])])
|
|
62 if AC_TRY_EVAL([ac_compile]); then
|
|
63 mv conftest.$ac_objext conftest2.$ac_objext
|
|
64 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
|
|
65 :
|
|
66 else
|
|
67 gl_cv_header_wchar_h_correct_inline=no
|
|
68 fi
|
|
69 fi
|
|
70 fi
|
|
71 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
|
|
72 ])
|
|
73 if test $gl_cv_header_wchar_h_correct_inline = no; then
|
|
74 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
|
|
75 This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
|
|
76 C99 mode. You have four options:
|
|
77 - Add the flag -fgnu89-inline to CC and reconfigure, or
|
|
78 - Fix your include files, using parts of
|
|
79 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
|
|
80 - Use a gcc version older than 4.3, or
|
|
81 - Don't use the flags -std=c99 or -std=gnu99.
|
|
82 Configuration aborted.])
|
|
83 fi
|
|
84 ])
|
|
85
|
|
86 dnl Unconditionally enables the replacement of <wchar.h>.
|
|
87 AC_DEFUN([gl_REPLACE_WCHAR_H],
|
|
88 [
|
|
89 dnl This is a no-op, because <wchar.h> is always overridden.
|
|
90 :
|
|
91 ])
|
|
92
|
|
93 AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
|
|
94 [
|
|
95 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
|
|
96 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
|
|
97 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
|
|
98 ])
|
|
99
|
|
100 AC_DEFUN([gl_WCHAR_H_DEFAULTS],
|
|
101 [
|
|
102 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
|
|
103 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
|
|
104 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
|
|
105 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
|
|
106 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
|
|
107 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
|
|
108 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
|
|
109 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
|
|
110 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
|
|
111 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
|
|
112 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
|
|
113 dnl Assume proper GNU behavior unless another module says otherwise.
|
|
114 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
|
|
115 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
|
|
116 HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC])
|
|
117 HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN])
|
|
118 HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS])
|
|
119 HAVE_MBSNRTOWCS=1; AC_SUBST([HAVE_MBSNRTOWCS])
|
|
120 HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB])
|
|
121 HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS])
|
|
122 HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS])
|
|
123 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
|
|
124 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
|
|
125 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
|
|
126 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
|
|
127 REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB])
|
|
128 REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT])
|
|
129 REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC])
|
|
130 REPLACE_MBRLEN=0; AC_SUBST([REPLACE_MBRLEN])
|
|
131 REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS])
|
|
132 REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS])
|
|
133 REPLACE_WCRTOMB=0; AC_SUBST([REPLACE_WCRTOMB])
|
|
134 REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
|
|
135 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
|
|
136 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
|
|
137 ])
|