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