4 dnl FIXME: this should migrate into libit.
6 AC_DEFUN(AM_FUNC_MKTIME,
7 [AC_REQUIRE([AC_HEADER_TIME])dnl
8 AC_CHECK_HEADERS(sys/time.h)
9 AC_CACHE_CHECK([for working mktime], am_cv_func_working_mktime,
11 changequote(<<, >>)dnl
12 <</* Test program from Paul Eggert (eggert@twinsun.com)
13 and Tony Leneis (tony@plaza.ds.adp.com). */
14 #if TIME_WITH_SYS_TIME
15 # include <sys/time.h>
19 # include <sys/time.h>
25 static time_t time_t_max;
27 /* Values we'll use to set the TZ environment variable. */
28 static const char *const tz_strings[] = {
29 NULL, "GMT0", "JST-9", "EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
31 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
37 if (mktime (localtime (&now)) != now)
39 now = time_t_max - now;
40 if (mktime (localtime (&now)) != now)
50 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
53 delta = time_t_max / 997; /* a suitable prime number */
54 for (i = 0; i < N_STRINGS; i++)
57 putenv (tz_strings[i]);
59 for (t = 0; t <= time_t_max - delta; t += delta)
61 mktime_test ((time_t) 60 * 60);
62 mktime_test ((time_t) 60 * 60 * 24);
68 am_cv_func_working_mktime=yes, am_cv_func_working_mktime=no,
69 dnl When crosscompiling, assume mktime is missing or broken.
70 am_cv_func_working_mktime=no)
72 if test $am_cv_func_working_mktime = no; then
73 LIBOBJS="$LIBOBJS mktime.o"