annotate m4/time_h.m4 @ 13133:72abbb959390

strptime: Fix C++ test error on mingw.
author Bruno Haible <bruno@clisp.org>
date Sat, 03 Apr 2010 20:23:47 +0200
parents eeb9ce788354
children 080377ada58c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8146
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 # Configure a more-standard replacement for <time.h>.
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2
12559
c2cbabec01dd update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents: 12421
diff changeset
3 # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
8146
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
5 # This file is free software; the Free Software Foundation
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
6 # gives unlimited permission to copy and/or distribute it,
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
7 # with or without modifications, as long as this notice is preserved.
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
8
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9 # Written by Paul Eggert and Jim Meyering.
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 AC_DEFUN([gl_HEADER_TIME_H],
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
12 [
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
13 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
14 dnl once only, before all statements that occur in other macros.
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
15 AC_REQUIRE([gl_HEADER_TIME_H_BODY])
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
16 ])
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
17
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
18 AC_DEFUN([gl_HEADER_TIME_H_BODY],
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19 [
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20 AC_REQUIRE([AC_C_RESTRICT])
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
21 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 8146
diff changeset
22 gl_CHECK_NEXT_HEADERS([time.h])
8146
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
23 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
24 ])
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
25
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
26 dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
27 dnl in time.h or sys/time.h.
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
28
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
29 AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
30 [
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
31 AC_CHECK_HEADERS_ONCE([sys/time.h])
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
32 AC_CACHE_CHECK([for struct timespec in <time.h>],
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
33 [gl_cv_sys_struct_timespec_in_time_h],
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
34 [AC_COMPILE_IFELSE(
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
35 [AC_LANG_PROGRAM(
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11742
diff changeset
36 [[#include <time.h>
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11742
diff changeset
37 ]],
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11742
diff changeset
38 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
8146
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
39 [gl_cv_sys_struct_timespec_in_time_h=yes],
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
40 [gl_cv_sys_struct_timespec_in_time_h=no])])
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
41
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
42 TIME_H_DEFINES_STRUCT_TIMESPEC=0
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
43 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
44 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
45 TIME_H_DEFINES_STRUCT_TIMESPEC=1
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
46 else
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
47 AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
48 [gl_cv_sys_struct_timespec_in_sys_time_h],
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
49 [AC_COMPILE_IFELSE(
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11742
diff changeset
50 [AC_LANG_PROGRAM(
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11742
diff changeset
51 [[#include <sys/time.h>
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11742
diff changeset
52 ]],
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11742
diff changeset
53 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11742
diff changeset
54 [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11742
diff changeset
55 [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
9179
b6825d8a63e8 * m4/time_h.m4 (gl_CHECK_TYPE_STRUCT_TIMESPEC): Fix misspelling
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
56 if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
8146
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
57 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
58 fi
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
59 fi
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
60 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
61 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
b31580167c2b New module 'time', so that apps can include <time.h> as per
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
62 ])
12948
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
63
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
64 AC_DEFUN([gl_TIME_MODULE_INDICATOR],
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
65 [
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
66 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
13127
a7fa4750421d time: Fix regression introduced on 2010-03-08.
Bruno Haible <bruno@clisp.org>
parents: 13071
diff changeset
67 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
13066
fc8c984b0733 Factorize common .m4 code.
Bruno Haible <bruno@clisp.org>
parents: 12992
diff changeset
68 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
12972
ad47f1c31ded Tests of module 'time' in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12948
diff changeset
69 dnl Define it also as a C macro, for the benefit of the unit tests.
13071
b2385e7b332e Distinguish two kinds of module indicators.
Bruno Haible <bruno@clisp.org>
parents: 13066
diff changeset
70 gl_MODULE_INDICATOR_FOR_TESTS([$1])
12948
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
71 ])
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
72
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
73 AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
74 [
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
75 GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME])
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
76 GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP])
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
77 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
78 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
12992
4ca54426154c Fix compilation error on mingw when module 'time_r' is not used.
Bruno Haible <bruno@clisp.org>
parents: 12972
diff changeset
79 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
13129
3a2049062a71 time_r: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 13127
diff changeset
80 dnl Assume proper GNU behavior unless another module says otherwise.
13132
eeb9ce788354 Oops, fix default value in the last commits.
Bruno Haible <bruno@clisp.org>
parents: 13131
diff changeset
81 HAVE_LOCALTIME_R=1; AC_SUBST([HAVE_LOCALTIME_R])
13133
72abbb959390 strptime: Fix C++ test error on mingw.
Bruno Haible <bruno@clisp.org>
parents: 13132
diff changeset
82 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
13132
eeb9ce788354 Oops, fix default value in the last commits.
Bruno Haible <bruno@clisp.org>
parents: 13131
diff changeset
83 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
12948
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
84 dnl If another module says to replace or to not replace, do that.
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
85 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
86 dnl this lets maintainers check for portability.
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
87 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
88 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
89 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
90 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
ea38eeab7d0f time: Avoid #define replacements in C++ mode.
Bruno Haible <bruno@clisp.org>
parents: 12559
diff changeset
91 ])