Merge branch 'master' into wip-manual-2
[bpt/guile.git] / m4 / time_h.m4
CommitLineData
e65fc94b
LC
1# Configure a more-standard replacement for <time.h>.
2
61cd9dc9 3# Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
e65fc94b
LC
4
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9# Written by Paul Eggert and Jim Meyering.
10
11AC_DEFUN([gl_HEADER_TIME_H],
12[
13 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
14 dnl once only, before all statements that occur in other macros.
15 AC_REQUIRE([gl_HEADER_TIME_H_BODY])
16])
17
18AC_DEFUN([gl_HEADER_TIME_H_BODY],
19[
20 AC_REQUIRE([AC_C_RESTRICT])
21 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
22 gl_CHECK_NEXT_HEADERS([time.h])
23 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
24])
25
e65fc94b
LC
26dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
27dnl in time.h or sys/time.h.
28
29AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
30[
31 AC_CHECK_HEADERS_ONCE([sys/time.h])
32 AC_CACHE_CHECK([for struct timespec in <time.h>],
33 [gl_cv_sys_struct_timespec_in_time_h],
34 [AC_COMPILE_IFELSE(
35 [AC_LANG_PROGRAM(
1cd4fffc
LC
36 [[#include <time.h>
37 ]],
38 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
e65fc94b
LC
39 [gl_cv_sys_struct_timespec_in_time_h=yes],
40 [gl_cv_sys_struct_timespec_in_time_h=no])])
41
42 TIME_H_DEFINES_STRUCT_TIMESPEC=0
43 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
44 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
45 TIME_H_DEFINES_STRUCT_TIMESPEC=1
46 else
47 AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
48 [gl_cv_sys_struct_timespec_in_sys_time_h],
49 [AC_COMPILE_IFELSE(
1cd4fffc
LC
50 [AC_LANG_PROGRAM(
51 [[#include <sys/time.h>
52 ]],
53 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
54 [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
55 [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
e65fc94b
LC
56 if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
57 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
58 fi
59 fi
60 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
61 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
62])
f4c79b3c
LC
63
64AC_DEFUN([gl_TIME_MODULE_INDICATOR],
65[
66 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
67 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
68 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
69 dnl Define it also as a C macro, for the benefit of the unit tests.
70 gl_MODULE_INDICATOR([$1])
71])
72
73AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
74[
75 GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME])
76 GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP])
77 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
78 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
79 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
80 dnl If another module says to replace or to not replace, do that.
81 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
82 dnl this lets maintainers check for portability.
83 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
84 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
85 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
86 REPLACE_STRPTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRPTIME])
87 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
88])