c4d3f4fa07187d7898b2adb76a79cdc1917be8ea
[debian/amanda] / config / gnulib / vasnprintf.m4
1 # vasnprintf.m4 serial 24
2 dnl Copyright (C) 2002-2004, 2006-2008 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_REQUIRE([gl_EOVERFLOW])
10   AC_CHECK_FUNCS_ONCE([vasnprintf])
11   if test $ac_cv_func_vasnprintf = no; then
12     gl_REPLACE_VASNPRINTF
13   fi
14 ])
15
16 AC_DEFUN([gl_REPLACE_VASNPRINTF],
17 [
18   AC_CHECK_FUNCS_ONCE([vasnprintf])
19   AC_LIBOBJ([vasnprintf])
20   AC_LIBOBJ([printf-args])
21   AC_LIBOBJ([printf-parse])
22   AC_LIBOBJ([asnprintf])
23   if test $ac_cv_func_vasnprintf = yes; then
24     AC_DEFINE([REPLACE_VASNPRINTF], 1,
25       [Define if vasnprintf exists but is overridden by gnulib.])
26   fi
27   gl_PREREQ_PRINTF_ARGS
28   gl_PREREQ_PRINTF_PARSE
29   gl_PREREQ_VASNPRINTF
30   gl_PREREQ_ASNPRINTF
31 ])
32
33 # Prequisites of lib/printf-args.h, lib/printf-args.c.
34 AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
35 [
36   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
37   AC_REQUIRE([gt_TYPE_WCHAR_T])
38   AC_REQUIRE([gt_TYPE_WINT_T])
39 ])
40
41 # Prequisites of lib/printf-parse.h, lib/printf-parse.c.
42 AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
43 [
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([gl_PREREQ_VASNPRINTF],
57 [
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 wcslen)
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 ])
67
68 # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
69 # arguments.
70 AC_DEFUN([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
71 [
72   AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
73   case "$gl_cv_func_printf_long_double" in
74     *yes)
75       ;;
76     *)
77       AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1,
78         [Define if the vasnprintf implementation needs special code for
79          'long double' arguments.])
80       ;;
81   esac
82 ])
83
84 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
85 # arguments.
86 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
87 [
88   AC_REQUIRE([gl_PRINTF_INFINITE])
89   case "$gl_cv_func_printf_infinite" in
90     *yes)
91       ;;
92     *)
93       AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], 1,
94         [Define if the vasnprintf implementation needs special code for
95          infinite 'double' arguments.])
96       ;;
97   esac
98 ])
99
100 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
101 # arguments.
102 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
103 [
104   AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
105   dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
106   dnl NEED_PRINTF_LONG_DOUBLE is already set.
107   AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
108   case "$gl_cv_func_printf_long_double" in
109     *yes)
110       case "$gl_cv_func_printf_infinite_long_double" in
111         *yes)
112           ;;
113         *)
114           AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], 1,
115             [Define if the vasnprintf implementation needs special code for
116              infinite 'long double' arguments.])
117           ;;
118       esac
119       ;;
120   esac
121 ])
122
123 # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
124 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
125 [
126   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
127   case "$gl_cv_func_printf_directive_a" in
128     *yes)
129       ;;
130     *)
131       AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
132         [Define if the vasnprintf implementation needs special code for
133          the 'a' and 'A' directives.])
134       AC_CHECK_FUNCS([nl_langinfo])
135       ;;
136   esac
137 ])
138
139 # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
140 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
141 [
142   AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
143   case "$gl_cv_func_printf_directive_f" in
144     *yes)
145       ;;
146     *)
147       AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], 1,
148         [Define if the vasnprintf implementation needs special code for
149          the 'F' directive.])
150       ;;
151   esac
152 ])
153
154 # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
155 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
156 [
157   AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
158   case "$gl_cv_func_printf_flag_grouping" in
159     *yes)
160       ;;
161     *)
162       AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], 1,
163         [Define if the vasnprintf implementation needs special code for the
164          ' flag.])
165       ;;
166   esac
167 ])
168
169 # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
170 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
171 [
172   AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
173   case "$gl_cv_func_printf_flag_leftadjust" in
174     *yes)
175       ;;
176     *)
177       AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], 1,
178         [Define if the vasnprintf implementation needs special code for the
179          '-' flag.])
180       ;;
181   esac
182 ])
183
184 # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
185 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
186 [
187   AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
188   case "$gl_cv_func_printf_flag_zero" in
189     *yes)
190       ;;
191     *)
192       AC_DEFINE([NEED_PRINTF_FLAG_ZERO], 1,
193         [Define if the vasnprintf implementation needs special code for the
194          0 flag.])
195       ;;
196   esac
197 ])
198
199 # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
200 AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
201 [
202   AC_REQUIRE([gl_PRINTF_PRECISION])
203   case "$gl_cv_func_printf_precision" in
204     *yes)
205       ;;
206     *)
207       AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], 1,
208         [Define if the vasnprintf implementation needs special code for
209          supporting large precisions without arbitrary bounds.])
210       AC_DEFINE([NEED_PRINTF_DOUBLE], 1,
211         [Define if the vasnprintf implementation needs special code for
212          'double' arguments.])
213       AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1,
214         [Define if the vasnprintf implementation needs special code for
215          'long double' arguments.])
216       ;;
217   esac
218 ])
219
220 # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
221 # conditions.
222 AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
223 [
224   AC_REQUIRE([gl_PRINTF_ENOMEM])
225   case "$gl_cv_func_printf_enomem" in
226     *yes)
227       ;;
228     *)
229       AC_DEFINE([NEED_PRINTF_ENOMEM], 1,
230         [Define if the vasnprintf implementation needs special code for
231          surviving out-of-memory conditions.])
232       AC_DEFINE([NEED_PRINTF_DOUBLE], 1,
233         [Define if the vasnprintf implementation needs special code for
234          'double' arguments.])
235       AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1,
236         [Define if the vasnprintf implementation needs special code for
237          'long double' arguments.])
238       ;;
239   esac
240 ])
241
242 # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
243 AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
244 [
245   AC_REQUIRE([gl_PREREQ_VASNPRINTF])
246   gl_PREREQ_VASNPRINTF_LONG_DOUBLE
247   gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
248   gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
249   gl_PREREQ_VASNPRINTF_DIRECTIVE_A
250   gl_PREREQ_VASNPRINTF_DIRECTIVE_F
251   gl_PREREQ_VASNPRINTF_FLAG_GROUPING
252   gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
253   gl_PREREQ_VASNPRINTF_FLAG_ZERO
254   gl_PREREQ_VASNPRINTF_PRECISION
255   gl_PREREQ_VASNPRINTF_ENOMEM
256 ])
257
258 # Prerequisites of lib/asnprintf.c.
259 AC_DEFUN([gl_PREREQ_ASNPRINTF],
260 [
261 ])