newcomment and the change of binding for M-;
[emacs.git] / aclocal.m4
blob1c013640effa982461d3968f54a29b2af2d516f1
1 dnl The following are from prerelease autoconf 2.14a.  When 2.14 is
2 dnl released, we should be able to zap them and just use AC_PREREQ(2.14).
5 # AC_PROG_CC_STDC
6 # ---------------
7 # If the C compiler in not in ANSI C mode by default, try to add an
8 # option to output variable @code{CC} to make it so.  This macro tries
9 # various options that select ANSI C on some system or another.  It
10 # considers the compiler to be in ANSI C mode if it handles function
11 # prototypes correctly.
12 AC_DEFUN(AC_PROG_CC_STDC,
13 [AC_REQUIRE([AC_PROG_CC])dnl
14 AC_BEFORE([$0], [AC_C_INLINE])dnl
15 AC_BEFORE([$0], [AC_C_CONST])dnl
16 dnl Force this before AC_PROG_CPP.  Some cpp's, eg on HPUX, require
17 dnl a magic option to avoid problems with ANSI preprocessor commands
18 dnl like #elif.
19 dnl FIXME: can't do this because then AC_AIX won't work due to a
20 dnl circular dependency.
21 dnl AC_BEFORE([$0], [AC_PROG_CPP])
22 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
23 AC_CACHE_VAL(ac_cv_prog_cc_stdc,
24 [ac_cv_prog_cc_stdc=no
25 ac_save_CC="$CC"
26 # Don't try gcc -ansi; that turns off useful extensions and
27 # breaks some systems' header files.
28 # AIX                   -qlanglvl=ansi
29 # Ultrix and OSF/1      -std1
30 # HP-UX 10.20 and later -Ae
31 # HP-UX older versions  -Aa -D_HPUX_SOURCE
32 # SVR4                  -Xc -D__EXTENSIONS__
33 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
35   CC="$ac_save_CC $ac_arg"
36   AC_TRY_COMPILE(
37 [#include <stdarg.h>
38 #include <stdio.h>
39 #include <sys/types.h>
40 #include <sys/stat.h>
41 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
42 struct buf { int x; };
43 FILE * (*rcsopen) (struct buf *, struct stat *, int);
44 static char *e (p, i)
45      char **p;
46      int i;
48   return p[i];
50 static char *f (char * (*g) (char **, int), char **p, ...)
52   char *s;
53   va_list v;
54   va_start (v,p);
55   s = g (p, va_arg (v,int));
56   va_end (v);
57   return s;
59 int test (int i, double x);
60 struct s1 {int (*f) (int a);};
61 struct s2 {int (*f) (double a);};
62 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
63 int argc;
64 char **argv;],
65 [return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];],
66 [ac_cv_prog_cc_stdc="$ac_arg"; break])
67 done
68 CC="$ac_save_CC"
70 case "x$ac_cv_prog_cc_stdc" in
71   x|xno)
72     AC_MSG_RESULT([none needed]) ;;
73   *)
74     AC_MSG_RESULT($ac_cv_prog_cc_stdc)
75     CC="$CC $ac_cv_prog_cc_stdc" ;;
76 esac
77 ])# AC_PROG_CC_STDC
79 # AC_FUNC_MKTIME
80 # --------------
81 AC_DEFUN(AC_FUNC_MKTIME,
82 [AC_REQUIRE([AC_HEADER_TIME])dnl
83 AC_CHECK_HEADERS(sys/time.h unistd.h)
84 AC_CHECK_FUNCS(alarm)
85 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
86 [AC_TRY_RUN(
87 [/* Test program from Paul Eggert (eggert@twinsun.com)
88    and Tony Leneis (tony@plaza.ds.adp.com).  */
89 #if TIME_WITH_SYS_TIME
90 # include <sys/time.h>
91 # include <time.h>
92 #else
93 # if HAVE_SYS_TIME_H
94 #  include <sys/time.h>
95 # else
96 #  include <time.h>
97 # endif
98 #endif
100 #if HAVE_UNISTD_H
101 # include <unistd.h>
102 #endif
104 #if !HAVE_ALARM
105 # define alarm(X) /* empty */
106 #endif
108 /* Work around redefinition to rpl_putenv by other config tests.  */
109 #undef putenv
111 static time_t time_t_max;
113 /* Values we'll use to set the TZ environment variable.  */
114 static const char *const tz_strings[] = {
115   (const char *) 0, "TZ=GMT0", "TZ=JST-9",
116   "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
118 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
120 /* Fail if mktime fails to convert a date in the spring-forward gap.
121    Based on a problem report from Andreas Jaeger.  */
122 static void
123 spring_forward_gap ()
125   /* glibc (up to about 1998-10-07) failed this test) */
126   struct tm tm;
128   /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
129      instead of "TZ=America/Vancouver" in order to detect the bug even
130      on systems that don't support the Olson extension, or don't have the
131      full zoneinfo tables installed.  */
132   putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
134   tm.tm_year = 98;
135   tm.tm_mon = 3;
136   tm.tm_mday = 5;
137   tm.tm_hour = 2;
138   tm.tm_min = 0;
139   tm.tm_sec = 0;
140   tm.tm_isdst = -1;
141   if (mktime (&tm) == (time_t)-1)
142     exit (1);
145 static void
146 mktime_test (now)
147      time_t now;
149   struct tm *lt;
150   if ((lt = localtime (&now)) && mktime (lt) != now)
151     exit (1);
152   now = time_t_max - now;
153   if ((lt = localtime (&now)) && mktime (lt) != now)
154     exit (1);
157 static void
158 irix_6_4_bug ()
160   /* Based on code from Ariel Faigon.  */
161   struct tm tm;
162   tm.tm_year = 96;
163   tm.tm_mon = 3;
164   tm.tm_mday = 0;
165   tm.tm_hour = 0;
166   tm.tm_min = 0;
167   tm.tm_sec = 0;
168   tm.tm_isdst = -1;
169   mktime (&tm);
170   if (tm.tm_mon != 2 || tm.tm_mday != 31)
171     exit (1);
174 static void
175 bigtime_test (j)
176      int j;
178   struct tm tm;
179   time_t now;
180   tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
181   now = mktime (&tm);
182   if (now != (time_t) -1)
183     {
184       struct tm *lt = localtime (&now);
185       if (! (lt
186              && lt->tm_year == tm.tm_year
187              && lt->tm_mon == tm.tm_mon
188              && lt->tm_mday == tm.tm_mday
189              && lt->tm_hour == tm.tm_hour
190              && lt->tm_min == tm.tm_min
191              && lt->tm_sec == tm.tm_sec
192              && lt->tm_yday == tm.tm_yday
193              && lt->tm_wday == tm.tm_wday
194              && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
195                   == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
196         exit (1);
197     }
201 main ()
203   time_t t, delta;
204   int i, j;
206   /* This test makes some buggy mktime implementations loop.
207      Give up after 60 seconds; a mktime slower than that
208      isn't worth using anyway.  */
209   alarm (60);
211   for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
212     continue;
213   time_t_max--;
214   delta = time_t_max / 997; /* a suitable prime number */
215   for (i = 0; i < N_STRINGS; i++)
216     {
217       if (tz_strings[i])
218         putenv (tz_strings[i]);
220       for (t = 0; t <= time_t_max - delta; t += delta)
221         mktime_test (t);
222       mktime_test ((time_t) 60 * 60);
223       mktime_test ((time_t) 60 * 60 * 24);
225       for (j = 1; 0 < j; j *= 2)
226         bigtime_test (j);
227       bigtime_test (j - 1);
228     }
229   irix_6_4_bug ();
230   spring_forward_gap ();
231   exit (0);
233 ac_cv_func_working_mktime=yes, ac_cv_func_working_mktime=no,
234 ac_cv_func_working_mktime=no)])
235 if test $ac_cv_func_working_mktime = no; then
236   LIBOBJS="$LIBOBJS mktime.${ac_objext}"
238 AC_SUBST(LIBOBJS)dnl
239 ])# AC_FUNC_MKTIME
241 # AC_C_VOLATILE
242 # -------------
243 # Note that, unlike const, #defining volatile to be the empty string can
244 # actually turn a correct program into an incorrect one, since removing
245 # uses of volatile actually grants the compiler permission to perform
246 # optimizations that could break the user's code.  So, do not #define
247 # volatile away unless it is really necessary to allow the user's code
248 # to compile cleanly.  Benign compiler failures should be tolerated.
249 AC_DEFUN(AC_C_VOLATILE,
250 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
251 AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
252 [AC_TRY_COMPILE(,[
253 volatile int x;
254 int * volatile y;],
255 ac_cv_c_volatile=yes, ac_cv_c_volatile=no)])
256 if test $ac_cv_c_volatile = no; then
257   AC_DEFINE(volatile,,
258             [Define to empty if the keyword `volatile' does not work.
259              Warning: valid code using `volatile' can become incorrect
260              without.  Disable with care.])
264 # AC_C_PROTOTYPES
265 # ---------------
266 # Check if the C compiler supports prototypes, included if it needs
267 # options.
268 AC_DEFUN(AC_C_PROTOTYPES,
269 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
270 AC_REQUIRE([AC_PROG_CPP])dnl
271 AC_MSG_CHECKING([for function prototypes])
272 if test "$ac_cv_prog_cc_stdc" != no; then
273   AC_MSG_RESULT(yes)
274   AC_DEFINE(PROTOTYPES, 1,
275             [Define if the compiler supports function prototypes.])
276 else
277   AC_MSG_RESULT(no)
279 ])# AC_C_PROTOTYPES