2 dnl FIXME: when this goes back into automake, reset this to a small number
5 dnl FIXME: this should migrate into libit.
7 dnl FIXME: when this goes back into automake, remove all jm_ prefixes
9 AC_DEFUN(jm_AM_FUNC_MKTIME,
10 [AC_REQUIRE([AC_HEADER_TIME])dnl
11 AC_CHECK_HEADERS(sys/time.h)
12 AC_CACHE_CHECK([for working mktime], jm_am_cv_func_working_mktime,
14 changequote(<<, >>)dnl
15 <</* Test program from Paul Eggert (eggert@twinsun.com)
16 and Tony Leneis (tony@plaza.ds.adp.com). */
17 #if TIME_WITH_SYS_TIME
18 # include <sys/time.h>
22 # include <sys/time.h>
28 static time_t time_t_max;
30 /* Values we'll use to set the TZ environment variable. */
31 static const char *const tz_strings[] = {
32 NULL, "GMT0", "JST-9", "EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
34 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
40 if (mktime (localtime (&now)) != now)
42 now = time_t_max - now;
43 if (mktime (localtime (&now)) != now)
50 /* Based on code from Ariel Faigon. */
60 if (tm.tm_mon != 2 || tm.tm_mday != 31)
70 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
73 delta = time_t_max / 997; /* a suitable prime number */
74 for (i = 0; i < N_STRINGS; i++)
77 putenv (tz_strings[i]);
79 for (t = 0; t <= time_t_max - delta; t += delta)
81 mktime_test ((time_t) 60 * 60);
82 mktime_test ((time_t) 60 * 60 * 24);
89 jm_am_cv_func_working_mktime=yes, jm_am_cv_func_working_mktime=no,
90 dnl When crosscompiling, assume mktime is missing or broken.
91 jm_am_cv_func_working_mktime=no)
93 if test $jm_am_cv_func_working_mktime = no; then
94 LIBOBJS="$LIBOBJS mktime.o"