1 ?RCS: $Id: i_time.U,v 3.0 1993/08/18 12:08:45 ram Exp $
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
11 ?RCS: $Log: i_time.U,v $
12 ?RCS: Revision 3.0 1993/08/18 12:08:45 ram
13 ?RCS: Baseline for dist 3.0 netwide release.
16 ?X: This unit finds which "time" include to use. If 'timezone' is used by the
17 ?X: program, we also try to find which header should be included. Eventually,
18 ?X: we look for <sys/select.h> if I_SYSSELECT is used, to get struct timeval.
20 ?MAKE:i_time i_systime i_systimek timeincl d_tm_tm_zone d_tm_tm_gmtoff: \
22 contains rm_try echo n c +i_sysselct Findhdr Hasfield i_stdlib
23 ?MAKE: -pick add $@ %<
25 ?S: This variable conditionally defines I_TIME, which indicates
26 ?S: to the C program that it should include <time.h>.
29 ?S: This variable conditionally defines I_SYS_TIME, which indicates
30 ?S: to the C program that it should include <sys/time.h>.
33 ?S: This variable conditionally defines I_SYS_TIME_KERNEL, which
34 ?S: indicates to the C program that it should include <sys/time.h>
35 ?S: with KERNEL defined.
38 ?S: This variable holds the full path of the included time header(s).
41 ?S: This variable conditionally defines HAS_TM_TM_ZONE, which indicates
42 ?S: indicates to the C program that the struct tm has the tm_zone field.
45 ?S: This variable conditionally defines HAS_TM_TM_GMTOFF, which indicates
46 ?S: indicates to the C program that the struct tm has the tm_gmtoff field.
48 ?C:I_TIME (USE_TIME_H):
49 ?C: This symbol, if defined, indicates to the C program that it should
52 ?C:I_SYS_TIME (I_SYSTIME USE_SYS_TIME_H NO_TIME_WITH_SYS_TIME):
53 ?C: This symbol, if defined, indicates to the C program that it should
54 ?C: include <sys/time.h>.
56 ?C:I_SYS_TIME_KERNEL (I_SYSTIMEKERNEL):
57 ?C: This symbol, if defined, indicates to the C program that it should
58 ?C: include <sys/time.h> with KERNEL defined.
61 ?C: This symbol, if defined, indicates to the C program that
62 ?C: the struct tm has a tm_zone field.
65 ?C: This symbol, if defined, indicates to the C program that
66 ?C: the struct tm has a tm_gmtoff field.
68 ?H:#$i_time I_TIME /**/
69 ?H:#$i_systime I_SYS_TIME /**/
70 ?H:#$i_systimek I_SYS_TIME_KERNEL /**/
71 ?H:#$d_tm_tm_zone HAS_TM_TM_ZONE /**/
72 ?H:#$d_tm_tm_gmtoff HAS_TM_TM_GMTOFF /**/
75 ?T:xselect flags sysselect s_timeval s_timezone
76 ?LINT:change i_sysselct
77 ?LINT:set d_tm_tm_zone
78 ?LINT:set d_tm_tm_gmtoff
79 : see if we should include time.h, sys/time.h, or both
81 if test "X$timeincl" = X; then
82 echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
83 $echo $n "I'm now running the test program...$c"
85 #include <sys/types.h>
96 #include <sys/select.h>
111 if (foo.tm_sec == foo.tm_sec)
114 if (bar.tv_sec == bar.tv_sec)
122 if $contains 'timeval.*{' `./findhdr sys/select.h` >/dev/null 2>&1; then
123 xselect='-DI_SYSSELECT'
129 for s_timezone in '-DS_TIMEZONE' ''; do
133 ?X: Every package is given a try with 'struct timeval'
135 for sysselect in $xselect ''; do
139 for s_timeval in '-DS_TIMEVAL' ''; do
140 for i_systimek in '' '-DSYSTIMEKERNEL'; do
141 for i_time in '' '-DI_TIME'; do
142 for i_systime in '-DI_SYSTIME' ''; do
145 set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
146 if eval $compile; then
147 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
151 $echo $n "Succeeded with $flags$c"
168 *SYSTIMEKERNEL*) i_systimek="$define"
169 timeincl=`./findhdr sys/time.h`
170 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
171 *) i_systimek="$undef";;
174 *I_TIME*) i_time="$define"
175 timeincl=`./findhdr time.h`" $timeincl"
176 echo "We'll include <time.h>." >&4;;
180 *I_SYSTIME*) i_systime="$define"
181 timeincl=`./findhdr sys/time.h`" $timeincl"
182 echo "We'll include <sys/time.h>." >&4;;
183 *) i_systime="$undef";;
187 *I_SYSSELECT*) i_sysselct="$define"
188 timeincl=`./findhdr sys/select.h`" $timeincl"
189 echo "We'll also include <sys/select.h> to get struct timeval." >&4;;
190 *) case "$i_sysselct" in
191 '') i_sysselct="$undef";;
197 : see if struct tm knows about tm_zone
198 case "$i_systime$i_time" in
201 echo "Checking to see if your struct tm has tm_zone field..." >&4
202 set d_tm_tm_zone tm tm_zone $i_systime sys/time.h $i_time time.h
210 case "$d_tm_tm_zone" in
211 "$define") echo "Yes, it does." ;;
212 *) echo "No, it doesn't." ;;
214 : see if struct tm knows about tm_gmtoff
215 case "$i_systime$i_time" in
218 echo "Checking to see if your struct tm has tm_gmtoff field..." >&4
219 set d_tm_tm_gmtoff tm tm_gmtoff $i_systime sys/time.h $i_time time.h
227 case "$d_tm_tm_gmtoff" in
228 "$define") echo "Yes, it does." ;;
229 *) echo "No, it doesn't." ;;