1 dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
3 dnl Copyright (C) 2007-2009 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.
8 dnl Written by Eric Blake.
12 AC_DEFUN([gl_WCHAR_H],
14 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
15 AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
16 AC_CACHE_CHECK([whether <wchar.h> is standalone],
17 [gl_cv_header_wchar_h_standalone],
18 [AC_COMPILE_IFELSE([[#include <wchar.h>
20 [gl_cv_header_wchar_h_standalone=yes],
21 [gl_cv_header_wchar_h_standalone=no])])
23 AC_REQUIRE([gt_TYPE_WINT_T])
24 if test $gt_cv_c_wint_t = yes; then
29 AC_SUBST([HAVE_WINT_T])
31 dnl If <stddef.h> is replaced, then <wchar.h> must also be replaced.
32 AC_REQUIRE([gl_STDDEF_H])
34 if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes || test -n "$STDDEF_H"; then
38 dnl Prepare for creating substitute <wchar.h>.
39 dnl Do it always: WCHAR_H may be empty here but can be set later.
40 dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
41 dnl character support).
42 AC_CHECK_HEADERS_ONCE([wchar.h])
43 if test $ac_cv_header_wchar_h = yes; then
48 AC_SUBST([HAVE_WCHAR_H])
49 dnl Execute this unconditionally, because WCHAR_H may be set by other
50 dnl modules, after this code is executed.
51 gl_CHECK_NEXT_HEADERS([wchar.h])
54 dnl Check whether <wchar.h> is usable at all.
55 AC_DEFUN([gl_WCHAR_H_INLINE_OK],
57 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
58 dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022>
59 dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
60 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
61 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
62 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
63 [gl_cv_header_wchar_h_correct_inline],
64 [gl_cv_header_wchar_h_correct_inline=yes
66 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
68 extern int zero (void);
69 int main () { return zero(); }
71 if AC_TRY_EVAL([ac_compile]); then
72 mv conftest.$ac_objext conftest1.$ac_objext
74 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
76 int zero (void) { return 0; }
78 if AC_TRY_EVAL([ac_compile]); then
79 mv conftest.$ac_objext conftest2.$ac_objext
80 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
83 gl_cv_header_wchar_h_correct_inline=no
87 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
89 if test $gl_cv_header_wchar_h_correct_inline = no; then
90 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
91 This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
92 C99 mode. You have four options:
93 - Add the flag -fgnu89-inline to CC and reconfigure, or
94 - Fix your include files, using parts of
95 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
96 - Use a gcc version older than 4.3, or
97 - Don't use the flags -std=c99 or -std=gnu99.
98 Configuration aborted.])
102 dnl Unconditionally enables the replacement of <wchar.h>.
103 AC_DEFUN([gl_REPLACE_WCHAR_H],
105 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
109 AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
111 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
112 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
113 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
116 AC_DEFUN([gl_WCHAR_H_DEFAULTS],
118 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
119 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
120 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
121 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
122 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
123 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
124 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
125 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
126 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
127 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
128 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
129 dnl Assume proper GNU behavior unless another module says otherwise.
130 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
131 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
132 HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC])
133 HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN])
134 HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS])
135 HAVE_MBSNRTOWCS=1; AC_SUBST([HAVE_MBSNRTOWCS])
136 HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB])
137 HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS])
138 HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS])
139 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
140 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
141 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
142 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
143 REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB])
144 REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT])
145 REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC])
146 REPLACE_MBRLEN=0; AC_SUBST([REPLACE_MBRLEN])
147 REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS])
148 REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS])
149 REPLACE_WCRTOMB=0; AC_SUBST([REPLACE_WCRTOMB])
150 REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
151 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
152 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
153 WCHAR_H=''; AC_SUBST([WCHAR_H])