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 Prepare for creating substitute <wchar.h>.
32 dnl Do it always: WCHAR_H may be empty here but can be set later.
33 dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
34 dnl character support).
35 AC_CHECK_HEADERS_ONCE([wchar.h])
36 if test $ac_cv_header_wchar_h = yes; then
41 AC_SUBST([HAVE_WCHAR_H])
42 dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
43 gl_CHECK_NEXT_HEADERS([wchar.h])
46 dnl Check whether <wchar.h> is usable at all.
47 AC_DEFUN([gl_WCHAR_H_INLINE_OK],
49 dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
50 dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022>
51 dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
52 dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
53 dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
54 AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
55 [gl_cv_header_wchar_h_correct_inline],
56 [gl_cv_header_wchar_h_correct_inline=yes
58 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
60 extern int zero (void);
61 int main () { return zero(); }
63 if AC_TRY_EVAL([ac_compile]); then
64 mv conftest.$ac_objext conftest1.$ac_objext
66 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
68 int zero (void) { return 0; }
70 if AC_TRY_EVAL([ac_compile]); then
71 mv conftest.$ac_objext conftest2.$ac_objext
72 if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
75 gl_cv_header_wchar_h_correct_inline=no
79 rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
81 if test $gl_cv_header_wchar_h_correct_inline = no; then
82 AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
83 This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
84 C99 mode. You have four options:
85 - Add the flag -fgnu89-inline to CC and reconfigure, or
86 - Fix your include files, using parts of
87 <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
88 - Use a gcc version older than 4.3, or
89 - Don't use the flags -std=c99 or -std=gnu99.
90 Configuration aborted.])
94 dnl Unconditionally enables the replacement of <wchar.h>.
95 AC_DEFUN([gl_REPLACE_WCHAR_H],
97 dnl This is a no-op, because <wchar.h> is always overridden.
101 AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
103 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
104 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
105 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
108 AC_DEFUN([gl_WCHAR_H_DEFAULTS],
110 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
111 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
112 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
113 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
114 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
115 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
116 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
117 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
118 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
119 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
120 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
121 dnl Assume proper GNU behavior unless another module says otherwise.
122 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
123 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
124 HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC])
125 HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN])
126 HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS])
127 HAVE_MBSNRTOWCS=1; AC_SUBST([HAVE_MBSNRTOWCS])
128 HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB])
129 HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS])
130 HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS])
131 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
132 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
133 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
134 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
135 REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB])
136 REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT])
137 REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC])
138 REPLACE_MBRLEN=0; AC_SUBST([REPLACE_MBRLEN])
139 REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS])
140 REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS])
141 REPLACE_WCRTOMB=0; AC_SUBST([REPLACE_WCRTOMB])
142 REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
143 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
144 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])