acinclude.m4 revision 103373
1dnl cloned from autoconf 2.13 acspecific.m4
2AC_DEFUN([AC_C_LONG_LONG],
3[AC_CACHE_CHECK(for long long, ac_cv_c_long_long,
4[if test "$GCC" = yes; then
5  ac_cv_c_long_long=yes
6else
7AC_TRY_RUN([int main() {
8long long foo = 0;
9exit(sizeof(long long) < sizeof(long)); }],
10ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
11fi])
12if test $ac_cv_c_long_long = yes; then
13  AC_DEFINE(HAVE_LONG_LONG)
14fi
15])
16
17dnl from autoconf 2.13 acspecific.m4, with changes to check for daylight
18
19AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT],
20[AC_REQUIRE([AC_STRUCT_TM])dnl
21AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
22[AC_TRY_COMPILE([#include <sys/types.h>
23#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
24  ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
25if test "$ac_cv_struct_tm_zone" = yes; then
26  AC_DEFINE(HAVE_TM_ZONE,1,[HAVE_TM_ZONE])
27fi
28AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
29[AC_TRY_LINK(
30changequote(<<, >>)dnl
31<<#include <time.h>
32#ifndef tzname /* For SGI.  */
33extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
34#endif>>,
35changequote([, ])dnl
36[atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
37  if test $ac_cv_var_tzname = yes; then
38    AC_DEFINE(HAVE_TZNAME,1,[HAVE_TZNAME])
39  fi
40
41AC_CACHE_CHECK([for tm_isdst in struct tm], ac_cv_struct_tm_isdst,
42[AC_TRY_COMPILE([#include <sys/types.h>
43#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_isdst;],
44  ac_cv_struct_tm_isdst=yes, ac_cv_struct_tm_isdst=no)])
45if test "$ac_cv_struct_tm_isdst" = yes; then
46  AC_DEFINE(HAVE_TM_ISDST)
47fi
48AC_CACHE_CHECK(for daylight, ac_cv_var_daylight,
49[AC_TRY_LINK(
50changequote(<<, >>)dnl
51<<#include <time.h>
52#ifndef daylight /* In case IRIX #defines this, too  */
53extern int daylight;
54#endif>>,
55changequote([, ])dnl
56[atoi(daylight);], ac_cv_var_daylight=yes, ac_cv_var_daylight=no)])
57  if test $ac_cv_var_daylight = yes; then
58    AC_DEFINE(HAVE_DAYLIGHT)
59  fi
60])
61
62dnl from autoconf 2.13 acgeneral.m4, with patch:
63dnl Date: Fri, 15 Jan 1999 05:52:41 -0800
64dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com>
65dnl From: eggert@twinsun.com (Paul Eggert)
66dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars
67dnl Newsgroups: gnu.utils.bug
68dnl
69dnl now include <stdint.h> if available
70
71dnl AC_CHECK_TYPE2_STDC(TYPE, DEFAULT)
72AC_DEFUN([AC_CHECK_TYPE2_STDC],
73[AC_REQUIRE([AC_HEADER_STDC])dnl
74AC_REQUIRE([AC_HEADER_STDINT])dnl
75AC_MSG_CHECKING(for $1)
76AC_CACHE_VAL(ac_cv_type_$1,
77[AC_EGREP_CPP(dnl
78[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
79[#if HAVE_STDINT_H
80#include <stdint.h>
81#endif
82#include <sys/types.h>
83#if STDC_HEADERS
84#include <stdlib.h>
85#include <stddef.h>
86#endif], eval "ac_cv_type_$1=yes", eval "ac_cv_type_$1=no")])dnl
87if eval "test \"`echo '$ac_cv_type_'$1`\" = yes"; then
88  AC_MSG_RESULT(yes)
89else
90  AC_MSG_RESULT(no)
91  AC_DEFINE_UNQUOTED($1, $2)
92fi
93])
94
95dnl from autoconf 2.13 acgeneral.m4, with additional third argument
96dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE [, INCLUDES]])
97AC_DEFUN([AC_CHECK_SIZEOF_INCLUDES],
98[dnl The name to #define.
99define([AC_TYPE_NAME], translit(sizeof_$1, [[[a-z *]]], [[[A-Z_P]]]))dnl
100dnl The cache variable name.
101define([AC_CV_NAME], translit(ac_cv_sizeof_$1, [[[ *]]], [[[_p]]]))dnl
102AC_MSG_CHECKING(size of $1)
103AC_CACHE_VAL(AC_CV_NAME,
104[AC_TRY_RUN([$3
105#include <stdio.h>
106main()
107{
108  FILE *f=fopen("conftestval", "w");
109  if (!f) exit(1);
110  fprintf(f, "%d\n", sizeof($1));
111  exit(0);
112}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
113AC_MSG_RESULT($AC_CV_NAME)
114AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
115undefine([AC_TYPE_NAME])dnl
116undefine([AC_CV_NAME])dnl
117])
118
119dnl AC_CHECK_SIZEOF_STDC_HEADERS(TYPE [, CROSS_SIZE])
120AC_DEFUN([AC_CHECK_SIZEOF_STDC_HEADERS],
121[AC_REQUIRE([AC_HEADER_STDC])dnl
122AC_REQUIRE([AC_HEADER_STDINT])dnl
123AC_CHECK_SIZEOF_INCLUDES($1, $2,
124[#if HAVE_STDINT_H
125#include <stdint.h>
126#endif
127#include <sys/types.h>
128#ifdef STDC_HEADERS
129#include <stdlib.h>
130#endif
131])
132])
133
134
135dnl AC_CHECK_TYPE_STDC(TYPE, DEFAULT)
136AC_DEFUN([AC_CHECK_TYPE_STDC],
137[AC_REQUIRE([AC_HEADER_STDC])dnl
138AC_REQUIRE([AC_HEADER_STDINT])dnl
139AC_MSG_CHECKING(for $1)
140AC_CACHE_VAL(ac_cv_type_$1,
141[AC_EGREP_CPP(dnl
142[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
143[#if HAVE_STDINT_H
144#include <stdint.h>
145#endif
146#include <sys/types.h>
147#if STDC_HEADERS
148#include <stdlib.h>
149#include <stddef.h>
150#endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
151AC_MSG_RESULT($ac_cv_type_$1)
152if test $ac_cv_type_$1 = no; then
153  AC_DEFINE($1, $2)
154fi
155])
156
157dnl AC_HEADER_STDINT
158AC_DEFUN([AC_HEADER_STDINT], [AC_CHECK_HEADERS(stdint.h)])
159
160#serial 19
161
162dnl By default, many hosts won't let programs access large files;
163dnl one must use special compiler options to get large-file access to work.
164dnl For more details about this brain damage please see:
165dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
166
167dnl Written by Paul Eggert <eggert@twinsun.com>.
168
169dnl Internal subroutine of AC_SYS_LARGEFILE.
170dnl AC_SYS_LARGEFILE_TEST_INCLUDES
171AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES],
172  [[#include <sys/types.h>
173    /* Check that off_t can represent 2**63 - 1 correctly.
174       We can't simply "#define LARGE_OFF_T 9223372036854775807",
175       since some C++ compilers masquerading as C compilers
176       incorrectly reject 9223372036854775807.  */
177#   define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
178    int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
179			&& LARGE_OFF_T % 2147483647 == 1)
180		       ? 1 : -1];
181  ]])
182
183dnl Internal subroutine of AC_SYS_LARGEFILE.
184dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLU=
185DES, FUNCTION-BODY)
186AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE],
187  [AC_CACHE_CHECK([for $1 value needed for large files], $3,
188     [$3=no
189      AC_TRY_COMPILE([$5],
190	[$6],
191	,
192	[AC_TRY_COMPILE([#define $1 $2]
193[$5]
194	   ,
195	   [$6],
196	   [$3=$2])])])
197   if test "[$]$3" != no; then
198     AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
199   fi])
200
201AC_DEFUN([AC_SYS_LARGEFILE],
202  [AC_REQUIRE([AC_PROG_CC])
203   AC_ARG_ENABLE(largefile,
204     [  --disable-largefile     omit support for large files])
205   if test "$enable_largefile" != no; then
206
207     AC_CACHE_CHECK([for special C compiler options needed for large files=
208],
209       ac_cv_sys_largefile_CC,
210       [ac_cv_sys_largefile_CC=no
211        if test "$GCC" != yes; then
212	  # IRIX 6.2 and later do not support large files by default,
213	  # so use the C compiler's -n32 option if that helps.
214	  AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
215	    [ac_save_CC="$CC"
216	     CC="$CC -n32"
217	     AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
218	       ac_cv_sys_largefile_CC=' -n32')
219	     CC="$ac_save_CC"])
220        fi])
221     if test "$ac_cv_sys_largefile_CC" != no; then
222       CC="$CC$ac_cv_sys_largefile_CC"
223     fi
224
225     AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
226       ac_cv_sys_file_offset_bits,
227       [Number of bits in a file offset, on hosts where this is settable.],
228       AC_SYS_LARGEFILE_TEST_INCLUDES)
229     AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
230       ac_cv_sys_large_files,
231       [Define for large files, on AIX-style hosts.],
232       AC_SYS_LARGEFILE_TEST_INCLUDES)
233   fi
234  ])
235
236AC_DEFUN([AC_FUNC_FSEEKO],
237  [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
238     ac_cv_sys_largefile_source,
239     [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
240     [#include <stdio.h>], [return !fseeko;])
241   # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
242   # in glibc 2.1.3, but that breaks too many other things.
243   # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
244
245   AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
246     [ac_cv_func_fseeko=no
247      AC_TRY_LINK([#include <stdio.h>],
248        [return fseeko && fseeko (stdin, 0, 0);],
249	[ac_cv_func_fseeko=yes])])
250   if test $ac_cv_func_fseeko != no; then
251     AC_DEFINE(HAVE_FSEEKO, 1,
252       [Define if fseeko (and presumably ftello) exists and is declared.])
253   fi])
254
255