Use Gnulib's `nproc'.
[bpt/guile.git] / m4 / vasnprintf.m4
1 # vasnprintf.m4 serial 32
2 dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_VASNPRINTF],
8 [
9 AC_CHECK_FUNCS_ONCE([vasnprintf])
10 if test $ac_cv_func_vasnprintf = no; then
11 gl_REPLACE_VASNPRINTF
12 fi
13 ])
14
15 AC_DEFUN([gl_REPLACE_VASNPRINTF],
16 [
17 AC_CHECK_FUNCS_ONCE([vasnprintf])
18 AC_LIBOBJ([vasnprintf])
19 AC_LIBOBJ([printf-args])
20 AC_LIBOBJ([printf-parse])
21 AC_LIBOBJ([asnprintf])
22 if test $ac_cv_func_vasnprintf = yes; then
23 AC_DEFINE([REPLACE_VASNPRINTF], [1],
24 [Define if vasnprintf exists but is overridden by gnulib.])
25 fi
26 gl_PREREQ_PRINTF_ARGS
27 gl_PREREQ_PRINTF_PARSE
28 gl_PREREQ_VASNPRINTF
29 gl_PREREQ_ASNPRINTF
30 ])
31
32 # Prequisites of lib/printf-args.h, lib/printf-args.c.
33 AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
34 [
35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
36 AC_REQUIRE([gt_TYPE_WCHAR_T])
37 AC_REQUIRE([gt_TYPE_WINT_T])
38 ])
39
40 # Prequisites of lib/printf-parse.h, lib/printf-parse.c.
41 AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
42 [
43 AC_REQUIRE([gl_FEATURES_H])
44 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
45 AC_REQUIRE([gt_TYPE_WCHAR_T])
46 AC_REQUIRE([gt_TYPE_WINT_T])
47 AC_REQUIRE([AC_TYPE_SIZE_T])
48 AC_CHECK_TYPE([ptrdiff_t], ,
49 [AC_DEFINE([ptrdiff_t], [long],
50 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
51 ])
52 AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
53 ])
54
55 # Prerequisites of lib/vasnprintf.c.
56 AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
57 [
58 AC_REQUIRE([AC_C_INLINE])
59 AC_REQUIRE([AC_FUNC_ALLOCA])
60 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
61 AC_REQUIRE([gt_TYPE_WCHAR_T])
62 AC_REQUIRE([gt_TYPE_WINT_T])
63 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
64 dnl Use the _snprintf function only if it is declared (because on NetBSD it
65 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
66 AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>])
67 dnl We can avoid a lot of code by assuming that snprintf's return value
68 dnl conforms to ISO C99. So check that.
69 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
70 case "$gl_cv_func_snprintf_retval_c99" in
71 *yes)
72 AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
73 [Define if the return value of the snprintf function is the number of
74 of bytes (excluding the terminating NUL) that would have been produced
75 if the buffer had been large enough.])
76 ;;
77 esac
78 ])
79
80 # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
81 # arguments.
82 AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
83 [
84 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
85 case "$gl_cv_func_printf_long_double" in
86 *yes)
87 ;;
88 *)
89 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
90 [Define if the vasnprintf implementation needs special code for
91 'long double' arguments.])
92 ;;
93 esac
94 ])
95
96 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
97 # arguments.
98 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
99 [
100 AC_REQUIRE([gl_PRINTF_INFINITE])
101 case "$gl_cv_func_printf_infinite" in
102 *yes)
103 ;;
104 *)
105 AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
106 [Define if the vasnprintf implementation needs special code for
107 infinite 'double' arguments.])
108 ;;
109 esac
110 ])
111
112 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
113 # arguments.
114 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
115 [
116 AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
117 dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
118 dnl NEED_PRINTF_LONG_DOUBLE is already set.
119 AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
120 case "$gl_cv_func_printf_long_double" in
121 *yes)
122 case "$gl_cv_func_printf_infinite_long_double" in
123 *yes)
124 ;;
125 *)
126 AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
127 [Define if the vasnprintf implementation needs special code for
128 infinite 'long double' arguments.])
129 ;;
130 esac
131 ;;
132 esac
133 ])
134
135 # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
136 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
137 [
138 AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
139 case "$gl_cv_func_printf_directive_a" in
140 *yes)
141 ;;
142 *)
143 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
144 [Define if the vasnprintf implementation needs special code for
145 the 'a' and 'A' directives.])
146 AC_CHECK_FUNCS([nl_langinfo])
147 ;;
148 esac
149 ])
150
151 # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
152 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
153 [
154 AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
155 case "$gl_cv_func_printf_directive_f" in
156 *yes)
157 ;;
158 *)
159 AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
160 [Define if the vasnprintf implementation needs special code for
161 the 'F' directive.])
162 ;;
163 esac
164 ])
165
166 # Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
167 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
168 [
169 AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
170 case "$gl_cv_func_printf_directive_ls" in
171 *yes)
172 ;;
173 *)
174 AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
175 [Define if the vasnprintf implementation needs special code for
176 the 'ls' directive.])
177 ;;
178 esac
179 ])
180
181 # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
182 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
183 [
184 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
185 case "$gl_cv_func_printf_flag_grouping" in
186 *yes)
187 ;;
188 *)
189 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
190 [Define if the vasnprintf implementation needs special code for the
191 ' flag.])
192 ;;
193 esac
194 ])
195
196 # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
197 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
198 [
199 AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
200 case "$gl_cv_func_printf_flag_leftadjust" in
201 *yes)
202 ;;
203 *)
204 AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
205 [Define if the vasnprintf implementation needs special code for the
206 '-' flag.])
207 ;;
208 esac
209 ])
210
211 # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
212 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
213 [
214 AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
215 case "$gl_cv_func_printf_flag_zero" in
216 *yes)
217 ;;
218 *)
219 AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
220 [Define if the vasnprintf implementation needs special code for the
221 0 flag.])
222 ;;
223 esac
224 ])
225
226 # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
227 AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
228 [
229 AC_REQUIRE([gl_PRINTF_PRECISION])
230 case "$gl_cv_func_printf_precision" in
231 *yes)
232 ;;
233 *)
234 AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
235 [Define if the vasnprintf implementation needs special code for
236 supporting large precisions without arbitrary bounds.])
237 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
238 [Define if the vasnprintf implementation needs special code for
239 'double' arguments.])
240 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
241 [Define if the vasnprintf implementation needs special code for
242 'long double' arguments.])
243 ;;
244 esac
245 ])
246
247 # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
248 # conditions.
249 AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
250 [
251 AC_REQUIRE([gl_PRINTF_ENOMEM])
252 case "$gl_cv_func_printf_enomem" in
253 *yes)
254 ;;
255 *)
256 AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
257 [Define if the vasnprintf implementation needs special code for
258 surviving out-of-memory conditions.])
259 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
260 [Define if the vasnprintf implementation needs special code for
261 'double' arguments.])
262 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
263 [Define if the vasnprintf implementation needs special code for
264 'long double' arguments.])
265 ;;
266 esac
267 ])
268
269 # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
270 AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
271 [
272 AC_REQUIRE([gl_PREREQ_VASNPRINTF])
273 gl_PREREQ_VASNPRINTF_LONG_DOUBLE
274 gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
275 gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
276 gl_PREREQ_VASNPRINTF_DIRECTIVE_A
277 gl_PREREQ_VASNPRINTF_DIRECTIVE_F
278 gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
279 gl_PREREQ_VASNPRINTF_FLAG_GROUPING
280 gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
281 gl_PREREQ_VASNPRINTF_FLAG_ZERO
282 gl_PREREQ_VASNPRINTF_PRECISION
283 gl_PREREQ_VASNPRINTF_ENOMEM
284 ])
285
286 # Prerequisites of lib/asnprintf.c.
287 AC_DEFUN([gl_PREREQ_ASNPRINTF],
288 [
289 ])