source: trunk/third/glib2/acinclude.m4 @ 20721

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