Fix function name
[platform/upstream/glib.git] / acinclude.m4
1 dnl @synopsis AC_FUNC_VSNPRINTF_C99
2 dnl
3 dnl Check whether there is a vsnprintf() function with C99 semantics installed.
4 dnl
5 AC_DEFUN([AC_FUNC_VSNPRINTF_C99],
6 [AC_CACHE_CHECK(for C99 vsnprintf,
7   ac_cv_func_vsnprintf_c99,
8 [AC_TRY_RUN(
9 [#include <stdio.h>
10 #include <stdarg.h>
11
12 int
13 doit(char * s, ...)
14 {
15   char buffer[32];
16   va_list args;
17   int r;
18
19   va_start(args, s);
20   r = vsnprintf(buffer, 5, s, args);
21   va_end(args);
22
23   if (r != 7)
24     exit(1);
25
26   exit(0);
27 }
28
29 int
30 main(void)
31 {
32   doit("1234567");
33   exit(1);
34 }], ac_cv_func_vsnprintf_c99=yes, ac_cv_func_vsnprintf_c99=no, ac_cv_func_vsnprintf_c99=no)])
35 dnl Note that the default is to be pessimistic in the case of cross compilation.
36 dnl If you know that the target has a C99 vsnprintf(), you can get around this
37 dnl by setting ac_func_vsnprintf_c99 to yes, as described in the Autoconf manual.
38 if test $ac_cv_func_vsnprintf_c99 = yes; then
39   AC_DEFINE(HAVE_C99_VSNPRINTF, 1,
40             [Define if you have a version of the vsnprintf function
41              with semantics as specified by the ISO C99 standard.])
42 fi
43 ])# AC_FUNC_VSNPRINTF_C99
44
45
46 dnl @synopsis AC_FUNC_SNPRINTF_C99
47 dnl
48 dnl Check whether there is a snprintf() function with C99 semantics installed.
49 dnl
50 AC_DEFUN([AC_FUNC_SNPRINTF_C99],
51 [AC_CACHE_CHECK(for C99 snprintf,
52   ac_cv_func_snprintf_c99,
53 [AC_TRY_RUN(
54 [#include <stdio.h>
55 #include <stdarg.h>
56
57 int
58 doit()
59 {
60   char buffer[32];
61   va_list args;
62   int r;
63
64   r = snprintf(buffer, 5, "1234567");
65
66   if (r != 7)
67     exit(1);
68
69   r = snprintf(buffer, 0, "1234567");
70
71   if (r != 7)
72     exit(1);
73
74   r = snprintf(NULL, 0, "1234567");
75
76   if (r != 7)
77     exit(1);
78
79   exit(0);
80 }
81
82 int
83 main(void)
84 {
85   doit();
86   exit(1);
87 }], ac_cv_func_snprintf_c99=yes, ac_cv_func_snprintf_c99=no, ac_cv_func_snprintf_c99=no)])
88 dnl Note that the default is to be pessimistic in the case of cross compilation.
89 dnl If you know that the target has a C99 snprintf(), you can get around this
90 dnl by setting ac_func_snprintf_c99 to yes, as described in the Autoconf manual.
91 if test $ac_cv_func_snprintf_c99 = yes; then
92   AC_DEFINE(HAVE_C99_SNPRINTF, 1,
93             [Define if you have a version of the snprintf function
94              with semantics as specified by the ISO C99 standard.])
95 fi
96 ])# AC_FUNC_SNPRINTF_C99
97
98
99 dnl @synopsis AC_FUNC_PRINTF_UNIX98
100 dnl
101 dnl Check whether the printf() family supports Unix98 %n$ positional parameters 
102 dnl
103 AC_DEFUN([AC_FUNC_PRINTF_UNIX98],
104 [AC_CACHE_CHECK(whether printf supports positional parameters,
105   ac_cv_func_printf_unix98,
106 [AC_TRY_RUN(
107 [#include <stdio.h>
108
109 int
110 main (void)
111 {
112   char buffer[128];
113
114   sprintf (buffer, "%2\$d %3\$d %1\$d", 1, 2, 3);
115   if (strcmp ("2 3 1", buffer) == 0)
116     exit (0);
117   exit (1);
118 }], ac_cv_func_printf_unix98=yes, ac_cv_func_printf_unix98=no, ac_cv_func_printf_unix98=no)])
119 dnl Note that the default is to be pessimistic in the case of cross compilation.
120 dnl If you know that the target printf() supports positional parameters, you can get around 
121 dnl this by setting ac_func_printf_unix98 to yes, as described in the Autoconf manual.
122 if test $ac_cv_func_printf_unix98 = yes; then
123   AC_DEFINE(HAVE_UNIX98_PRINTF, 1,
124             [Define if your printf function family supports positional parameters
125              as specified by Unix98.])
126 fi
127 ])# AC_FUNC_PRINTF_UNIX98
128
129 # Checks the location of the XML Catalog
130 # Usage:
131 #   JH_PATH_XML_CATALOG([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
132 # Defines XMLCATALOG and XML_CATALOG_FILE substitutions
133 AC_DEFUN([JH_PATH_XML_CATALOG],
134 [
135   # check for the presence of the XML catalog
136   AC_ARG_WITH([xml-catalog],
137               AC_HELP_STRING([--with-xml-catalog=CATALOG],
138                              [path to xml catalog to use]),,
139               [with_xml_catalog=/etc/xml/catalog])
140   jh_found_xmlcatalog=true
141   XML_CATALOG_FILE="$with_xml_catalog"
142   AC_SUBST([XML_CATALOG_FILE])
143   AC_MSG_CHECKING([for XML catalog ($XML_CATALOG_FILE)])
144   if test -f "$XML_CATALOG_FILE"; then
145     AC_MSG_RESULT([found])
146   else
147     jh_found_xmlcatalog=false
148     AC_MSG_RESULT([not found])
149   fi
150
151   # check for the xmlcatalog program
152   AC_PATH_PROG(XMLCATALOG, xmlcatalog, no)
153   if test "x$XMLCATALOG" = xno; then
154     jh_found_xmlcatalog=false
155   fi
156
157   if $jh_found_xmlcatalog; then
158     ifelse([$1],,[:],[$1])
159   else
160     ifelse([$2],,[AC_MSG_ERROR([could not find XML catalog])],[$2])
161   fi
162 ])
163
164 # Checks if a particular URI appears in the XML catalog
165 # Usage:
166 #   JH_CHECK_XML_CATALOG(URI, [FRIENDLY-NAME], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
167 AC_DEFUN([JH_CHECK_XML_CATALOG],
168 [
169   AC_REQUIRE([JH_PATH_XML_CATALOG],[JH_PATH_XML_CATALOG(,[:])])dnl
170   AC_MSG_CHECKING([for ifelse([$2],,[$1],[$2]) in XML catalog])
171   if $jh_found_xmlcatalog && \
172      AC_RUN_LOG([$XMLCATALOG --noout "$XML_CATALOG_FILE" "$1" >&2]); then
173     AC_MSG_RESULT([found])
174     ifelse([$3],,,[$3
175 ])dnl
176   else
177     AC_MSG_RESULT([not found])
178     ifelse([$4],,
179        [AC_MSG_ERROR([could not find ifelse([$2],,[$1],[$2]) in XML catalog])],
180        [$4])
181   fi
182 ])
183
184
185 # signed.m4 serial 1 (gettext-0.10.40)
186 dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
187 dnl This file is free software, distributed under the terms of the GNU
188 dnl General Public License.  As a special exception to the GNU General
189 dnl Public License, this file may be distributed as part of a program
190 dnl that contains a configuration script generated by Autoconf, under
191 dnl the same distribution terms as the rest of that program.
192
193 dnl From Bruno Haible.
194
195 AC_DEFUN([bh_C_SIGNED],
196 [
197   AC_CACHE_CHECK([for signed], bh_cv_c_signed,
198    [AC_TRY_COMPILE(, [signed char x;], bh_cv_c_signed=yes, bh_cv_c_signed=no)])
199   if test $bh_cv_c_signed = no; then
200     AC_DEFINE(signed, ,
201               [Define to empty if the C compiler doesn't support this keyword.])
202   fi
203 ])
204
205
206 # longlong.m4 serial 4
207 dnl Copyright (C) 1999-2003 Free Software Foundation, Inc.
208 dnl This file is free software, distributed under the terms of the GNU
209 dnl General Public License.  As a special exception to the GNU General
210 dnl Public License, this file may be distributed as part of a program
211 dnl that contains a configuration script generated by Autoconf, under
212 dnl the same distribution terms as the rest of that program.
213
214 dnl From Paul Eggert.
215
216 # Define HAVE_LONG_LONG if 'long long' works.
217
218 AC_DEFUN([jm_AC_TYPE_LONG_LONG],
219 [
220   AC_CACHE_CHECK([for long long], ac_cv_type_long_long,
221   [AC_TRY_LINK([long long ll = 1LL; int i = 63;],
222     [long long llmax = (long long) -1;
223      return ll << i | ll >> i | llmax / ll | llmax % ll;],
224     ac_cv_type_long_long=yes,
225     ac_cv_type_long_long=no)])
226   if test $ac_cv_type_long_long = yes; then
227     AC_DEFINE(HAVE_LONG_LONG, 1,
228       [Define if you have the 'long long' type.])
229   fi
230 ])
231
232
233 # longdouble.m4 serial 1 (gettext-0.11.6)
234 dnl Copyright (C) 2002 Free Software Foundation, Inc.
235 dnl This file is free software, distributed under the terms of the GNU
236 dnl General Public License.  As a special exception to the GNU General
237 dnl Public License, this file may be distributed as part of a program
238 dnl that contains a configuration script generated by Autoconf, under
239 dnl the same distribution terms as the rest of that program.
240
241 dnl From Bruno Haible.
242 dnl Test whether the compiler supports the 'long double' type.
243 dnl Prerequisite: AC_PROG_CC
244
245 AC_DEFUN([gt_TYPE_LONGDOUBLE],
246 [
247   AC_CACHE_CHECK([for long double], gt_cv_c_long_double,
248     [if test "$GCC" = yes; then
249        gt_cv_c_long_double=yes
250      else
251        AC_TRY_COMPILE([
252          /* The Stardent Vistra knows sizeof(long double), but does not support it.  */
253          long double foo = 0.0;
254          /* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
255          int array [2*(sizeof(long double) >= sizeof(double)) - 1];
256          ], ,
257          gt_cv_c_long_double=yes, gt_cv_c_long_double=no)
258      fi])
259   if test $gt_cv_c_long_double = yes; then
260     AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the 'long double' type.])
261   fi
262 ])
263
264
265
266 # wchar_t.m4 serial 1 (gettext-0.11.6)
267 dnl Copyright (C) 2002 Free Software Foundation, Inc.
268 dnl This file is free software, distributed under the terms of the GNU
269 dnl General Public License.  As a special exception to the GNU General
270 dnl Public License, this file may be distributed as part of a program
271 dnl that contains a configuration script generated by Autoconf, under
272 dnl the same distribution terms as the rest of that program.
273
274 dnl From Bruno Haible.
275 dnl Test whether <stddef.h> has the 'wchar_t' type.
276 dnl Prerequisite: AC_PROG_CC
277
278 AC_DEFUN([gt_TYPE_WCHAR_T],
279 [
280   AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t,
281     [AC_TRY_COMPILE([#include <stddef.h>
282        wchar_t foo = (wchar_t)'\0';], ,
283        gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)])
284   if test $gt_cv_c_wchar_t = yes; then
285     AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.])
286   fi
287 ])
288
289
290 # wint_t.m4 serial 1
291 dnl Copyright (C) 2003 Free Software Foundation, Inc.
292 dnl This file is free software, distributed under the terms of the GNU
293 dnl General Public License.  As a special exception to the GNU General
294 dnl Public License, this file may be distributed as part of a program
295 dnl that contains a configuration script generated by Autoconf, under
296 dnl the same distribution terms as the rest of that program.
297
298 dnl From Bruno Haible.
299 dnl Test whether <wchar.h> has the 'wint_t' type.
300 dnl Prerequisite: AC_PROG_CC
301
302 AC_DEFUN([gt_TYPE_WINT_T],
303 [
304   AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t,
305     [AC_TRY_COMPILE([#include <wchar.h>
306        wint_t foo = (wchar_t)'\0';], ,
307        gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)])
308   if test $gt_cv_c_wint_t = yes; then
309     AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.])
310   fi
311 ])
312
313
314 # intmax_t.m4 serial 1
315 dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
316 dnl This file is free software, distributed under the terms of the GNU
317 dnl General Public License.  As a special exception to the GNU General
318 dnl Public License, this file may be distributed as part of a program
319 dnl that contains a configuration script generated by Autoconf, under
320 dnl the same distribution terms as the rest of that program.
321
322 dnl From Paul Eggert.
323
324 AC_PREREQ(2.13)
325
326 # Define intmax_t to 'long' or 'long long'
327 # if it is not already defined in <stdint.h> or <inttypes.h>.
328
329 AC_DEFUN([jm_AC_TYPE_INTMAX_T],
330 [
331   dnl For simplicity, we assume that a header file defines 'intmax_t' if and
332   dnl only if it defines 'uintmax_t'.
333   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
334   AC_REQUIRE([jm_AC_HEADER_STDINT_H])
335   if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then
336     AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
337     test $ac_cv_type_long_long = yes \
338       && ac_type='long long' \
339       || ac_type='long'
340     AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
341      [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
342   else
343     AC_DEFINE(HAVE_INTMAX_T, 1,
344       [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
345   fi
346 ])
347
348 dnl An alternative would be to explicitly test for 'intmax_t'.
349
350 AC_DEFUN([gt_AC_TYPE_INTMAX_T],
351 [
352   AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
353   AC_REQUIRE([jm_AC_HEADER_STDINT_H])
354   AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t,
355     [AC_TRY_COMPILE([
356 #include <stddef.h> 
357 #include <stdlib.h>
358 #if HAVE_STDINT_H_WITH_UINTMAX
359 #include <stdint.h>
360 #endif
361 #if HAVE_INTTYPES_H_WITH_UINTMAX
362 #include <inttypes.h>
363 #endif
364 ], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
365   if test $gt_cv_c_intmax_t = yes; then
366     AC_DEFINE(HAVE_INTMAX_T, 1,
367       [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
368   else
369     AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
370     test $ac_cv_type_long_long = yes \
371       && ac_type='long long' \
372       || ac_type='long'
373     AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
374      [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
375   fi
376 ])
377
378
379 # stdint_h.m4 serial 3 (gettext-0.11.6)
380 dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
381 dnl This file is free software, distributed under the terms of the GNU
382 dnl General Public License.  As a special exception to the GNU General
383 dnl Public License, this file may be distributed as part of a program
384 dnl that contains a configuration script generated by Autoconf, under
385 dnl the same distribution terms as the rest of that program.
386
387 dnl From Paul Eggert.
388
389 # Define HAVE_STDINT_H_WITH_UINTMAX if <stdint.h> exists,
390 # doesn't clash with <sys/types.h>, and declares uintmax_t.
391
392 AC_DEFUN([jm_AC_HEADER_STDINT_H],
393 [
394   AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h,
395   [AC_TRY_COMPILE(
396     [#include <sys/types.h>
397 #include <stdint.h>],
398     [uintmax_t i = (uintmax_t) -1;],
399     jm_ac_cv_header_stdint_h=yes,
400     jm_ac_cv_header_stdint_h=no)])
401   if test $jm_ac_cv_header_stdint_h = yes; then
402     AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1,
403       [Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
404        and declares uintmax_t. ])
405   fi
406 ])
407
408
409 # inttypes_h.m4 serial 5 (gettext-0.11.6)
410 dnl Copyright (C) 1997-2002 Free Software Foundation, Inc.
411 dnl This file is free software, distributed under the terms of the GNU
412 dnl General Public License.  As a special exception to the GNU General
413 dnl Public License, this file may be distributed as part of a program
414 dnl that contains a configuration script generated by Autoconf, under
415 dnl the same distribution terms as the rest of that program.
416
417 dnl From Paul Eggert.
418
419 # Define HAVE_INTTYPES_H_WITH_UINTMAX if <inttypes.h> exists,
420 # doesn't clash with <sys/types.h>, and declares uintmax_t.
421
422 AC_DEFUN([jm_AC_HEADER_INTTYPES_H],
423 [
424   AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h,
425   [AC_TRY_COMPILE(
426     [#include <sys/types.h>
427 #include <inttypes.h>],
428     [uintmax_t i = (uintmax_t) -1;],
429     jm_ac_cv_header_inttypes_h=yes,
430     jm_ac_cv_header_inttypes_h=no)])
431   if test $jm_ac_cv_header_inttypes_h = yes; then
432     AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1,
433       [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
434        and declares uintmax_t. ])
435   fi
436 ])
437
438