Make setthetime() static per the prototype.
[dragonfly.git] / contrib / file / acinclude.m4
1 dnl cloned from autoconf 2.13 acspecific.m4
2 AC_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
6 else
7 AC_TRY_RUN([int main() {
8 long long foo = 0;
9 exit(sizeof(long long) < sizeof(long)); }],
10 ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
11 fi])
12 if test $ac_cv_c_long_long = yes; then
13   AC_DEFINE(HAVE_LONG_LONG)
14 fi
15 ])
16
17 dnl from autoconf 2.13 acspecific.m4, with changes to check for daylight
18
19 AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT],
20 [AC_REQUIRE([AC_STRUCT_TM])dnl
21 AC_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)])
25 if test "$ac_cv_struct_tm_zone" = yes; then
26   AC_DEFINE(HAVE_TM_ZONE,1,[HAVE_TM_ZONE])
27 fi
28 AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
29 [AC_TRY_LINK(
30 changequote(<<, >>)dnl
31 <<#include <time.h>
32 #ifndef tzname /* For SGI.  */
33 extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
34 #endif>>,
35 changequote([, ])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
41 AC_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)])
45 if test "$ac_cv_struct_tm_isdst" = yes; then
46   AC_DEFINE(HAVE_TM_ISDST)
47 fi
48 AC_CACHE_CHECK(for daylight, ac_cv_var_daylight,
49 [AC_TRY_LINK(
50 changequote(<<, >>)dnl
51 <<#include <time.h>
52 #ifndef daylight /* In case IRIX #defines this, too  */
53 extern int daylight;
54 #endif>>,
55 changequote([, ])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
62 dnl from autoconf 2.13 acgeneral.m4, with patch:
63 dnl Date: Fri, 15 Jan 1999 05:52:41 -0800
64 dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com>
65 dnl From: eggert@twinsun.com (Paul Eggert)
66 dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars
67 dnl Newsgroups: gnu.utils.bug
68 dnl
69 dnl now include <stdint.h> if available
70
71 dnl AC_CHECK_TYPE2_STDC(TYPE, DEFAULT)
72 AC_DEFUN([AC_CHECK_TYPE2_STDC],
73 [AC_REQUIRE([AC_HEADER_STDC])dnl
74 AC_REQUIRE([AC_HEADER_STDINT])dnl
75 AC_MSG_CHECKING(for $1)
76 AC_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
87 if eval "test \"`echo '$ac_cv_type_'$1`\" = yes"; then
88   AC_MSG_RESULT(yes)
89 else
90   AC_MSG_RESULT(no)
91   AC_DEFINE_UNQUOTED($1, $2)
92 fi
93 ])
94
95 dnl from autoconf 2.13 acgeneral.m4, with additional third argument
96 dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE [, INCLUDES]])
97 AC_DEFUN([AC_CHECK_SIZEOF_INCLUDES],
98 [dnl The name to #define.
99 define([AC_TYPE_NAME], translit(sizeof_$1, [[[a-z *]]], [[[A-Z_P]]]))dnl
100 dnl The cache variable name.
101 define([AC_CV_NAME], translit(ac_cv_sizeof_$1, [[[ *]]], [[[_p]]]))dnl
102 AC_MSG_CHECKING(size of $1)
103 AC_CACHE_VAL(AC_CV_NAME,
104 [AC_TRY_RUN([$3
105 #include <stdio.h>
106 main()
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
113 AC_MSG_RESULT($AC_CV_NAME)
114 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
115 undefine([AC_TYPE_NAME])dnl
116 undefine([AC_CV_NAME])dnl
117 ])
118
119 dnl AC_CHECK_SIZEOF_STDC_HEADERS(TYPE [, CROSS_SIZE])
120 AC_DEFUN([AC_CHECK_SIZEOF_STDC_HEADERS],
121 [AC_REQUIRE([AC_HEADER_STDC])dnl
122 AC_REQUIRE([AC_HEADER_STDINT])dnl
123 AC_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
135 dnl AC_CHECK_TYPE_STDC(TYPE, DEFAULT)
136 AC_DEFUN([AC_CHECK_TYPE_STDC],
137 [AC_REQUIRE([AC_HEADER_STDC])dnl
138 AC_REQUIRE([AC_HEADER_STDINT])dnl
139 AC_MSG_CHECKING(for $1)
140 AC_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
151 AC_MSG_RESULT($ac_cv_type_$1)
152 if test $ac_cv_type_$1 = no; then
153   AC_DEFINE($1, $2)
154 fi
155 ])
156
157 dnl AC_HEADER_STDINT
158 AC_DEFUN([AC_HEADER_STDINT], [AC_CHECK_HEADERS(stdint.h)])
159
160 #serial 19
161
162 dnl By default, many hosts won't let programs access large files;
163 dnl one must use special compiler options to get large-file access to work.
164 dnl For more details about this brain damage please see:
165 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
166
167 dnl Written by Paul Eggert <eggert@twinsun.com>.
168
169 dnl Internal subroutine of AC_SYS_LARGEFILE.
170 dnl AC_SYS_LARGEFILE_TEST_INCLUDES
171 AC_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
183 dnl Internal subroutine of AC_SYS_LARGEFILE.
184 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLU=
185 DES, FUNCTION-BODY)
186 AC_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
201 AC_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
236 AC_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