Commit | Line | Data |
---|---|---|
8690e634 JK |
1 | dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues. |
2 | ||
5df4cba6 | 3 | dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. |
8690e634 JK |
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 | ||
c0c3707f | 10 | # wchar_h.m4 serial 44 |
8690e634 JK |
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 | gl_CHECK_NEXT_HEADERS([wchar.h]) | |
21 | if test $ac_cv_header_wchar_h = yes; then | |
22 | HAVE_WCHAR_H=1 | |
23 | else | |
24 | HAVE_WCHAR_H=0 | |
25 | fi | |
26 | AC_SUBST([HAVE_WCHAR_H]) | |
27 | ||
28 | AC_REQUIRE([gl_FEATURES_H]) | |
29 | ||
30 | AC_REQUIRE([gt_TYPE_WINT_T]) | |
31 | if test $gt_cv_c_wint_t = yes; then | |
32 | HAVE_WINT_T=1 | |
33 | else | |
34 | HAVE_WINT_T=0 | |
35 | fi | |
36 | AC_SUBST([HAVE_WINT_T]) | |
37 | ||
c0c3707f CB |
38 | AC_REQUIRE([gl_TYPE_WINT_T_PREREQ]) |
39 | ||
8690e634 JK |
40 | dnl Check for declarations of anything we want to poison if the |
41 | dnl corresponding gnulib module is not in use. | |
42 | gl_WARN_ON_USE_PREPARE([[ | |
43 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | |
44 | <wchar.h>. | |
45 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | |
46 | included before <wchar.h>. */ | |
47 | #if !(defined __GLIBC__ && !defined __UCLIBC__) | |
48 | # include <stddef.h> | |
49 | # include <stdio.h> | |
50 | # include <time.h> | |
51 | #endif | |
52 | #include <wchar.h> | |
53 | ]], | |
54 | [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb | |
55 | wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset | |
56 | wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp | |
57 | wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr | |
c0c3707f | 58 | wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth wcsftime |
8690e634 JK |
59 | ]) |
60 | ]) | |
61 | ||
62 | dnl Check whether <wchar.h> is usable at all. | |
63 | AC_DEFUN([gl_WCHAR_H_INLINE_OK], | |
64 | [ | |
65 | dnl Test whether <wchar.h> suffers due to the transition from '__inline' to | |
c0c3707f CB |
66 | dnl 'gnu_inline'. See <https://sourceware.org/bugzilla/show_bug.cgi?id=4022> |
67 | dnl and <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary, | |
8690e634 JK |
68 | dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and |
69 | dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>. | |
70 | AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly], | |
71 | [gl_cv_header_wchar_h_correct_inline], | |
72 | [gl_cv_header_wchar_h_correct_inline=yes | |
73 | AC_LANG_CONFTEST([ | |
74 | AC_LANG_SOURCE([[#define wcstod renamed_wcstod | |
75 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | |
76 | <wchar.h>. | |
77 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | |
78 | included before <wchar.h>. */ | |
79 | #include <stddef.h> | |
80 | #include <stdio.h> | |
81 | #include <time.h> | |
82 | #include <wchar.h> | |
83 | extern int zero (void); | |
84 | int main () { return zero(); } | |
85 | ]])]) | |
49e4877c PA |
86 | dnl Do not rename the object file from conftest.$ac_objext to |
87 | dnl conftest1.$ac_objext, as this will cause the link to fail on | |
88 | dnl z/OS when using the XPLINK object format (due to duplicate | |
89 | dnl CSECT names). Instead, temporarily redefine $ac_compile so | |
90 | dnl that the object file has the latter name from the start. | |
91 | save_ac_compile="$ac_compile" | |
92 | ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest1/` | |
c0c3707f CB |
93 | if echo '#include "conftest.c"' >conftest1.c && |
94 | AC_TRY_EVAL([ac_compile]); then | |
8690e634 JK |
95 | AC_LANG_CONFTEST([ |
96 | AC_LANG_SOURCE([[#define wcstod renamed_wcstod | |
97 | /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | |
98 | <wchar.h>. | |
99 | BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | |
100 | included before <wchar.h>. */ | |
101 | #include <stddef.h> | |
102 | #include <stdio.h> | |
103 | #include <time.h> | |
104 | #include <wchar.h> | |
105 | int zero (void) { return 0; } | |
106 | ]])]) | |
49e4877c PA |
107 | dnl See note above about renaming object files. |
108 | ac_compile=`echo "$save_ac_compile" | sed s/conftest/conftest2/` | |
c0c3707f CB |
109 | if echo '#include "conftest.c"' >conftest2.c && |
110 | AC_TRY_EVAL([ac_compile]); then | |
8690e634 JK |
111 | if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then |
112 | : | |
113 | else | |
114 | gl_cv_header_wchar_h_correct_inline=no | |
115 | fi | |
116 | fi | |
117 | fi | |
49e4877c | 118 | ac_compile="$save_ac_compile" |
c0c3707f | 119 | rm -f conftest[12].c conftest[12].$ac_objext conftest$ac_exeext |
8690e634 JK |
120 | ]) |
121 | if test $gl_cv_header_wchar_h_correct_inline = no; then | |
122 | AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS). | |
123 | This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in | |
124 | C99 mode. You have four options: | |
125 | - Add the flag -fgnu89-inline to CC and reconfigure, or | |
126 | - Fix your include files, using parts of | |
c0c3707f | 127 | <https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or |
8690e634 JK |
128 | - Use a gcc version older than 4.3, or |
129 | - Don't use the flags -std=c99 or -std=gnu99. | |
130 | Configuration aborted.]) | |
131 | fi | |
132 | ]) | |
133 | ||
134 | AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], | |
135 | [ | |
136 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | |
137 | AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) | |
138 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) | |
139 | dnl Define it also as a C macro, for the benefit of the unit tests. | |
140 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) | |
141 | ]) | |
142 | ||
143 | AC_DEFUN([gl_WCHAR_H_DEFAULTS], | |
144 | [ | |
145 | GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC]) | |
146 | GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB]) | |
147 | GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT]) | |
148 | GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC]) | |
149 | GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN]) | |
150 | GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS]) | |
151 | GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS]) | |
152 | GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB]) | |
153 | GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS]) | |
154 | GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS]) | |
155 | GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH]) | |
156 | GNULIB_WMEMCHR=0; AC_SUBST([GNULIB_WMEMCHR]) | |
157 | GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP]) | |
158 | GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY]) | |
159 | GNULIB_WMEMMOVE=0; AC_SUBST([GNULIB_WMEMMOVE]) | |
160 | GNULIB_WMEMSET=0; AC_SUBST([GNULIB_WMEMSET]) | |
161 | GNULIB_WCSLEN=0; AC_SUBST([GNULIB_WCSLEN]) | |
162 | GNULIB_WCSNLEN=0; AC_SUBST([GNULIB_WCSNLEN]) | |
163 | GNULIB_WCSCPY=0; AC_SUBST([GNULIB_WCSCPY]) | |
164 | GNULIB_WCPCPY=0; AC_SUBST([GNULIB_WCPCPY]) | |
165 | GNULIB_WCSNCPY=0; AC_SUBST([GNULIB_WCSNCPY]) | |
166 | GNULIB_WCPNCPY=0; AC_SUBST([GNULIB_WCPNCPY]) | |
167 | GNULIB_WCSCAT=0; AC_SUBST([GNULIB_WCSCAT]) | |
168 | GNULIB_WCSNCAT=0; AC_SUBST([GNULIB_WCSNCAT]) | |
169 | GNULIB_WCSCMP=0; AC_SUBST([GNULIB_WCSCMP]) | |
170 | GNULIB_WCSNCMP=0; AC_SUBST([GNULIB_WCSNCMP]) | |
171 | GNULIB_WCSCASECMP=0; AC_SUBST([GNULIB_WCSCASECMP]) | |
172 | GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP]) | |
173 | GNULIB_WCSCOLL=0; AC_SUBST([GNULIB_WCSCOLL]) | |
174 | GNULIB_WCSXFRM=0; AC_SUBST([GNULIB_WCSXFRM]) | |
175 | GNULIB_WCSDUP=0; AC_SUBST([GNULIB_WCSDUP]) | |
176 | GNULIB_WCSCHR=0; AC_SUBST([GNULIB_WCSCHR]) | |
177 | GNULIB_WCSRCHR=0; AC_SUBST([GNULIB_WCSRCHR]) | |
178 | GNULIB_WCSCSPN=0; AC_SUBST([GNULIB_WCSCSPN]) | |
179 | GNULIB_WCSSPN=0; AC_SUBST([GNULIB_WCSSPN]) | |
180 | GNULIB_WCSPBRK=0; AC_SUBST([GNULIB_WCSPBRK]) | |
181 | GNULIB_WCSSTR=0; AC_SUBST([GNULIB_WCSSTR]) | |
182 | GNULIB_WCSTOK=0; AC_SUBST([GNULIB_WCSTOK]) | |
183 | GNULIB_WCSWIDTH=0; AC_SUBST([GNULIB_WCSWIDTH]) | |
c0c3707f | 184 | GNULIB_WCSFTIME=0; AC_SUBST([GNULIB_WCSFTIME]) |
8690e634 JK |
185 | dnl Assume proper GNU behavior unless another module says otherwise. |
186 | HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) | |
187 | HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) | |
188 | HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC]) | |
189 | HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN]) | |
190 | HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS]) | |
191 | HAVE_MBSNRTOWCS=1; AC_SUBST([HAVE_MBSNRTOWCS]) | |
192 | HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB]) | |
193 | HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS]) | |
194 | HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS]) | |
195 | HAVE_WMEMCHR=1; AC_SUBST([HAVE_WMEMCHR]) | |
196 | HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP]) | |
197 | HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY]) | |
198 | HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE]) | |
199 | HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET]) | |
200 | HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN]) | |
201 | HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN]) | |
202 | HAVE_WCSCPY=1; AC_SUBST([HAVE_WCSCPY]) | |
203 | HAVE_WCPCPY=1; AC_SUBST([HAVE_WCPCPY]) | |
204 | HAVE_WCSNCPY=1; AC_SUBST([HAVE_WCSNCPY]) | |
205 | HAVE_WCPNCPY=1; AC_SUBST([HAVE_WCPNCPY]) | |
206 | HAVE_WCSCAT=1; AC_SUBST([HAVE_WCSCAT]) | |
207 | HAVE_WCSNCAT=1; AC_SUBST([HAVE_WCSNCAT]) | |
208 | HAVE_WCSCMP=1; AC_SUBST([HAVE_WCSCMP]) | |
209 | HAVE_WCSNCMP=1; AC_SUBST([HAVE_WCSNCMP]) | |
210 | HAVE_WCSCASECMP=1; AC_SUBST([HAVE_WCSCASECMP]) | |
211 | HAVE_WCSNCASECMP=1; AC_SUBST([HAVE_WCSNCASECMP]) | |
212 | HAVE_WCSCOLL=1; AC_SUBST([HAVE_WCSCOLL]) | |
213 | HAVE_WCSXFRM=1; AC_SUBST([HAVE_WCSXFRM]) | |
214 | HAVE_WCSDUP=1; AC_SUBST([HAVE_WCSDUP]) | |
215 | HAVE_WCSCHR=1; AC_SUBST([HAVE_WCSCHR]) | |
216 | HAVE_WCSRCHR=1; AC_SUBST([HAVE_WCSRCHR]) | |
217 | HAVE_WCSCSPN=1; AC_SUBST([HAVE_WCSCSPN]) | |
218 | HAVE_WCSSPN=1; AC_SUBST([HAVE_WCSSPN]) | |
219 | HAVE_WCSPBRK=1; AC_SUBST([HAVE_WCSPBRK]) | |
220 | HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR]) | |
221 | HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK]) | |
222 | HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH]) | |
c0c3707f | 223 | HAVE_WCSFTIME=1; AC_SUBST([HAVE_WCSFTIME]) |
8690e634 JK |
224 | HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB]) |
225 | HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) | |
226 | REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T]) | |
227 | REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC]) | |
228 | REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB]) | |
229 | REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT]) | |
230 | REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC]) | |
231 | REPLACE_MBRLEN=0; AC_SUBST([REPLACE_MBRLEN]) | |
232 | REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS]) | |
233 | REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS]) | |
234 | REPLACE_WCRTOMB=0; AC_SUBST([REPLACE_WCRTOMB]) | |
235 | REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS]) | |
236 | REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS]) | |
237 | REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) | |
238 | REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH]) | |
c0c3707f CB |
239 | REPLACE_WCSFTIME=0; AC_SUBST([REPLACE_WCSFTIME]) |
240 | REPLACE_WCSTOK=0; AC_SUBST([REPLACE_WCSTOK]) | |
8690e634 | 241 | ]) |