*** empty log message ***
[bpt/emacs.git] / aclocal.m4
CommitLineData
8e82f0c2 1dnl The following are from prerelease autoconf 2.14a. When 2.14 is
4487f86d 2dnl released, we should be able to zap them and just use AC_PREREQ(2.14).
8e82f0c2 3
6a465756 4ifelse(_AC_VERSION_COMPARE(AC_ACVERSION, [2.14]), -1,
8e82f0c2
DL
5
6# AC_PROG_CC_STDC
7# ---------------
8# If the C compiler in not in ANSI C mode by default, try to add an
9# option to output variable @code{CC} to make it so. This macro tries
10# various options that select ANSI C on some system or another. It
11# considers the compiler to be in ANSI C mode if it handles function
12# prototypes correctly.
13AC_DEFUN(AC_PROG_CC_STDC,
14[AC_REQUIRE([AC_PROG_CC])dnl
15AC_BEFORE([$0], [AC_C_INLINE])dnl
16AC_BEFORE([$0], [AC_C_CONST])dnl
17dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
18dnl a magic option to avoid problems with ANSI preprocessor commands
19dnl like #elif.
20dnl FIXME: can't do this because then AC_AIX won't work due to a
21dnl circular dependency.
22dnl AC_BEFORE([$0], [AC_PROG_CPP])
23AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
24AC_CACHE_VAL(ac_cv_prog_cc_stdc,
25[ac_cv_prog_cc_stdc=no
26ac_save_CC="$CC"
27# Don't try gcc -ansi; that turns off useful extensions and
28# breaks some systems' header files.
29# AIX -qlanglvl=ansi
30# Ultrix and OSF/1 -std1
31# HP-UX 10.20 and later -Ae
32# HP-UX older versions -Aa -D_HPUX_SOURCE
33# SVR4 -Xc -D__EXTENSIONS__
34for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
35do
36 CC="$ac_save_CC $ac_arg"
37 AC_TRY_COMPILE(
38[#include <stdarg.h>
39#include <stdio.h>
40#include <sys/types.h>
41#include <sys/stat.h>
42/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
43struct buf { int x; };
44FILE * (*rcsopen) (struct buf *, struct stat *, int);
45static char *e (p, i)
46 char **p;
47 int i;
48{
49 return p[i];
50}
51static char *f (char * (*g) (char **, int), char **p, ...)
52{
53 char *s;
54 va_list v;
55 va_start (v,p);
56 s = g (p, va_arg (v,int));
57 va_end (v);
58 return s;
59}
60int test (int i, double x);
61struct s1 {int (*f) (int a);};
62struct s2 {int (*f) (double a);};
63int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
64int argc;
65char **argv;],
66[return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];],
67[ac_cv_prog_cc_stdc="$ac_arg"; break])
68done
69CC="$ac_save_CC"
70])
71case "x$ac_cv_prog_cc_stdc" in
72 x|xno)
73 AC_MSG_RESULT([none needed]) ;;
74 *)
75 AC_MSG_RESULT($ac_cv_prog_cc_stdc)
76 CC="$CC $ac_cv_prog_cc_stdc" ;;
77esac
78])# AC_PROG_CC_STDC
79
4487f86d
DL
80# AC_FUNC_MKTIME
81# --------------
82AC_DEFUN(AC_FUNC_MKTIME,
83[AC_REQUIRE([AC_HEADER_TIME])dnl
84AC_CHECK_HEADERS(sys/time.h unistd.h)
85AC_CHECK_FUNCS(alarm)
86AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
87[AC_TRY_RUN(
88[/* Test program from Paul Eggert (eggert@twinsun.com)
89 and Tony Leneis (tony@plaza.ds.adp.com). */
90#if TIME_WITH_SYS_TIME
91# include <sys/time.h>
92# include <time.h>
93#else
94# if HAVE_SYS_TIME_H
95# include <sys/time.h>
96# else
97# include <time.h>
98# endif
99#endif
100
101#if HAVE_UNISTD_H
102# include <unistd.h>
103#endif
104
105#if !HAVE_ALARM
106# define alarm(X) /* empty */
107#endif
108
109/* Work around redefinition to rpl_putenv by other config tests. */
110#undef putenv
111
112static time_t time_t_max;
113
114/* Values we'll use to set the TZ environment variable. */
115static const char *const tz_strings[] = {
116 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
117 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
118};
119#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
120
121/* Fail if mktime fails to convert a date in the spring-forward gap.
122 Based on a problem report from Andreas Jaeger. */
123static void
124spring_forward_gap ()
125{
126 /* glibc (up to about 1998-10-07) failed this test) */
127 struct tm tm;
128
129 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
130 instead of "TZ=America/Vancouver" in order to detect the bug even
131 on systems that don't support the Olson extension, or don't have the
132 full zoneinfo tables installed. */
133 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
134
135 tm.tm_year = 98;
136 tm.tm_mon = 3;
137 tm.tm_mday = 5;
138 tm.tm_hour = 2;
139 tm.tm_min = 0;
140 tm.tm_sec = 0;
141 tm.tm_isdst = -1;
142 if (mktime (&tm) == (time_t)-1)
143 exit (1);
144}
145
146static void
147mktime_test (now)
148 time_t now;
149{
150 struct tm *lt;
151 if ((lt = localtime (&now)) && mktime (lt) != now)
152 exit (1);
153 now = time_t_max - now;
154 if ((lt = localtime (&now)) && mktime (lt) != now)
155 exit (1);
156}
157
158static void
159irix_6_4_bug ()
160{
161 /* Based on code from Ariel Faigon. */
162 struct tm tm;
163 tm.tm_year = 96;
164 tm.tm_mon = 3;
165 tm.tm_mday = 0;
166 tm.tm_hour = 0;
167 tm.tm_min = 0;
168 tm.tm_sec = 0;
169 tm.tm_isdst = -1;
170 mktime (&tm);
171 if (tm.tm_mon != 2 || tm.tm_mday != 31)
172 exit (1);
173}
174
175static void
176bigtime_test (j)
177 int j;
178{
179 struct tm tm;
180 time_t now;
181 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
182 now = mktime (&tm);
183 if (now != (time_t) -1)
184 {
185 struct tm *lt = localtime (&now);
186 if (! (lt
187 && lt->tm_year == tm.tm_year
188 && lt->tm_mon == tm.tm_mon
189 && lt->tm_mday == tm.tm_mday
190 && lt->tm_hour == tm.tm_hour
191 && lt->tm_min == tm.tm_min
192 && lt->tm_sec == tm.tm_sec
193 && lt->tm_yday == tm.tm_yday
194 && lt->tm_wday == tm.tm_wday
195 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
196 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
197 exit (1);
198 }
199}
200
201int
202main ()
203{
204 time_t t, delta;
205 int i, j;
206
207 /* This test makes some buggy mktime implementations loop.
208 Give up after 60 seconds; a mktime slower than that
209 isn't worth using anyway. */
210 alarm (60);
211
212 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
213 continue;
214 time_t_max--;
215 delta = time_t_max / 997; /* a suitable prime number */
216 for (i = 0; i < N_STRINGS; i++)
217 {
218 if (tz_strings[i])
219 putenv (tz_strings[i]);
220
221 for (t = 0; t <= time_t_max - delta; t += delta)
222 mktime_test (t);
223 mktime_test ((time_t) 60 * 60);
224 mktime_test ((time_t) 60 * 60 * 24);
225
226 for (j = 1; 0 < j; j *= 2)
227 bigtime_test (j);
228 bigtime_test (j - 1);
229 }
230 irix_6_4_bug ();
231 spring_forward_gap ();
232 exit (0);
233}],
234ac_cv_func_working_mktime=yes, ac_cv_func_working_mktime=no,
235ac_cv_func_working_mktime=no)])
236if test $ac_cv_func_working_mktime = no; then
237 LIBOBJS="$LIBOBJS mktime.${ac_objext}"
238fi
0b8f263e 239AC_SUBST(LIBOBJS)dnl
4487f86d
DL
240])# AC_FUNC_MKTIME
241
8e82f0c2
DL
242# AC_C_VOLATILE
243# -------------
244# Note that, unlike const, #defining volatile to be the empty string can
245# actually turn a correct program into an incorrect one, since removing
246# uses of volatile actually grants the compiler permission to perform
247# optimizations that could break the user's code. So, do not #define
248# volatile away unless it is really necessary to allow the user's code
249# to compile cleanly. Benign compiler failures should be tolerated.
250AC_DEFUN(AC_C_VOLATILE,
251[AC_REQUIRE([AC_PROG_CC_STDC])dnl
252AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
253[AC_TRY_COMPILE(,[
254volatile int x;
255int * volatile y;],
256ac_cv_c_volatile=yes, ac_cv_c_volatile=no)])
257if test $ac_cv_c_volatile = no; then
258 AC_DEFINE(volatile,,
259 [Define to empty if the keyword `volatile' does not work.
260 Warning: valid code using `volatile' can become incorrect
261 without. Disable with care.])
262fi
263])
264
265# AC_C_PROTOTYPES
266# ---------------
267# Check if the C compiler supports prototypes, included if it needs
268# options.
269AC_DEFUN(AC_C_PROTOTYPES,
270[AC_REQUIRE([AC_PROG_CC_STDC])dnl
271AC_REQUIRE([AC_PROG_CPP])dnl
272AC_MSG_CHECKING([for function prototypes])
273if test "$ac_cv_prog_cc_stdc" != no; then
274 AC_MSG_RESULT(yes)
275 AC_DEFINE(PROTOTYPES, 1,
276 [Define if the compiler supports function prototypes.])
277else
278 AC_MSG_RESULT(no)
279fi
280])# AC_C_PROTOTYPES
7101aecf 281
6a465756
DL
282dnl The following is a bit different from the prerelease autoconf at
283dnl this time since that requires extra definitions.
edcc1067 284
7101aecf
DL
285dnl By default, many hosts won't let programs access large files;
286dnl one must use special compiler options to get large-file access to work.
287dnl For more details about this brain damage please see:
288dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
289
290dnl Written by Paul Eggert <eggert@twinsun.com>.
291
292dnl Internal subroutine of AC_SYS_LARGEFILE.
293dnl AC_SYS_LARGEFILE_TEST_INCLUDES
294AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES,
295 [[#include <sys/types.h>
296 int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1];
297 ]])
298
299dnl Internal subroutine of AC_SYS_LARGEFILE.
300dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
301AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
302 [AC_CACHE_CHECK([for $1 value needed for large files], $3,
303 [$3=no
304 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES
305$5
306 ,
307 [$6],
308 ,
309 [AC_TRY_COMPILE([#define $1 $2]
310AC_SYS_LARGEFILE_TEST_INCLUDES
311$5
312 ,
313 [$6],
314 [$3=$2])])])
315 if test "[$]$3" != no; then
316 AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
317 fi])
318
319AC_DEFUN(AC_SYS_LARGEFILE,
320 [AC_ARG_ENABLE(largefile,
321 [ --disable-largefile omit support for large files])
322 if test "$enable_largefile" != no; then
323
324 AC_CACHE_CHECK([for special C compiler options needed for large files],
325 ac_cv_sys_largefile_CC,
326 [ac_cv_sys_largefile_CC=no
327 if test "$GCC" != yes; then
328 # IRIX 6.2 and later do not support large files by default,
329 # so use the C compiler's -n32 option if that helps.
330 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
331 [ac_save_CC="$CC"
332 CC="$CC -n32"
333 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
334 ac_cv_sys_largefile_CC=' -n32')
335 CC="$ac_save_CC"])
336 fi])
337 if test "$ac_cv_sys_largefile_CC" != no; then
338 CC="$CC$ac_cv_sys_largefile_CC"
339 fi
340
341 AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
342 ac_cv_sys_file_offset_bits,
343 [Number of bits in a file offset, on hosts where this is settable.])
344 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
345 ac_cv_sys_largefile_source,
346 [Define to make ftello visible on some hosts (e.g. HP-UX 10.20).],
347 [#include <stdio.h>], [return !ftello;])
348 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
349 ac_cv_sys_large_files,
350 [Define for large files, on AIX-style hosts.])
351 AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500,
352 ac_cv_sys_xopen_source,
353 [Define to make ftello visible on some hosts (e.g. glibc 2.1.3).],
354 [#include <stdio.h>], [return !ftello;])
355 fi
356 ])
6a465756
DL
357
358) dnl ifelse