Commit | Line | Data |
---|---|---|
d8875586 MBT |
1 | ?RCS: $Id: i_time.U 1 2006-08-24 12:32:52Z rmanfredi $ |
2 | ?RCS: | |
3 | ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi | |
4 | ?RCS: | |
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 4.0. | |
10 | ?RCS: | |
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. | |
14 | ?RCS: | |
15 | ?X: | |
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. | |
19 | ?X: | |
20 | ?MAKE:i_time i_systime i_systimek timeincl: cat cc ccflags contains rm \ | |
21 | echo n c +i_sysselct Findhdr | |
22 | ?MAKE: -pick add $@ %< | |
23 | ?S:i_time: | |
24 | ?S: This variable conditionally defines I_TIME, which indicates | |
25 | ?S: to the C program that it should include <time.h>. | |
26 | ?S:. | |
27 | ?S:i_systime: | |
28 | ?S: This variable conditionally defines I_SYS_TIME, which indicates | |
29 | ?S: to the C program that it should include <sys/time.h>. | |
30 | ?S:. | |
31 | ?S:i_systimek: | |
32 | ?S: This variable conditionally defines I_SYS_TIME_KERNEL, which | |
33 | ?S: indicates to the C program that it should include <sys/time.h> | |
34 | ?S: with KERNEL defined. | |
35 | ?S:. | |
36 | ?S:timeincl: | |
37 | ?S: This variable holds the full path of the included time header(s). | |
38 | ?S:. | |
39 | ?C:I_TIME (USE_TIME_H): | |
40 | ?C: This symbol, if defined, indicates to the C program that it should | |
41 | ?C: include <time.h>. | |
42 | ?C:. | |
43 | ?C:I_SYS_TIME (I_SYSTIME USE_SYS_TIME_H NO_TIME_WITH_SYS_TIME): | |
44 | ?C: This symbol, if defined, indicates to the C program that it should | |
45 | ?C: include <sys/time.h>. | |
46 | ?C:. | |
47 | ?C:I_SYS_TIME_KERNEL (I_SYSTIMEKERNEL): | |
48 | ?C: This symbol, if defined, indicates to the C program that it should | |
49 | ?C: include <sys/time.h> with KERNEL defined. | |
50 | ?C:. | |
51 | ?H:#$i_time I_TIME /**/ | |
52 | ?H:#$i_systime I_SYS_TIME /**/ | |
53 | ?H:#$i_systimek I_SYS_TIME_KERNEL /**/ | |
54 | ?H:. | |
55 | ?W::timezone | |
56 | ?T:xselect flags sysselect s_timeval s_timezone | |
57 | ?LINT:change i_sysselct | |
58 | : see if we should include time.h, sys/time.h, or both | |
59 | echo " " | |
60 | echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4 | |
61 | $echo $n "I'm now running the test program...$c" | |
62 | $cat >try.c <<'EOCP' | |
63 | #include <sys/types.h> | |
64 | #ifdef I_TIME | |
65 | #include <time.h> | |
66 | #endif | |
67 | #ifdef I_SYSTIME | |
68 | #ifdef SYSTIMEKERNEL | |
69 | #define KERNEL | |
70 | #endif | |
71 | #include <sys/time.h> | |
72 | #endif | |
73 | #ifdef I_SYSSELECT | |
74 | #include <sys/select.h> | |
75 | #endif | |
76 | int main() | |
77 | { | |
78 | struct tm foo; | |
79 | #ifdef S_TIMEVAL | |
80 | struct timeval bar; | |
81 | #endif | |
82 | #ifdef S_TIMEZONE | |
83 | struct timezone tzp; | |
84 | #endif | |
85 | if (foo.tm_sec == foo.tm_sec) | |
86 | exit(0); | |
87 | #ifdef S_TIMEVAL | |
88 | if (bar.tv_sec == bar.tv_sec) | |
89 | exit(0); | |
90 | #endif | |
91 | exit(1); | |
92 | } | |
93 | EOCP | |
94 | flags='' | |
95 | @if I_SYSSELECT | |
96 | if $contains 'timeval.*{' `./findhdr sys/select.h` >/dev/null 2>&1; then | |
97 | xselect='-DI_SYSSELECT' | |
98 | else | |
99 | xselect='' | |
100 | fi | |
101 | @end | |
102 | @if timezone | |
103 | for s_timezone in '-DS_TIMEZONE' ''; do | |
104 | @else | |
105 | s_timezone='' | |
106 | @end | |
107 | ?X: Every package is given a try with 'struct timeval' | |
108 | @if I_SYSSELECT | |
109 | for sysselect in $xselect ''; do | |
110 | @else | |
111 | sysselect='' | |
112 | @end | |
113 | for s_timeval in '-DS_TIMEVAL' ''; do | |
114 | for i_systimek in '' '-DSYSTIMEKERNEL'; do | |
115 | for i_time in '' '-DI_TIME'; do | |
116 | for i_systime in '-DI_SYSTIME' ''; do | |
117 | case "$flags" in | |
118 | '') $echo $n ".$c" | |
119 | if $cc $ccflags \ | |
120 | $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone \ | |
121 | -o try try.c >/dev/null 2>&1 ; then | |
122 | set X $i_time $i_systime $i_systimek $sysselect $s_timeval | |
123 | shift | |
124 | flags="$*" | |
125 | echo " " | |
126 | $echo $n "Succeeded with $flags$c" | |
127 | fi | |
128 | ;; | |
129 | esac | |
130 | done | |
131 | done | |
132 | done | |
133 | done | |
134 | @if I_SYSSELECT | |
135 | done | |
136 | @end | |
137 | @if timezone | |
138 | done | |
139 | @end | |
140 | timeincl='' | |
141 | echo " " | |
142 | case "$flags" in | |
143 | *SYSTIMEKERNEL*) i_systimek="$define" | |
144 | timeincl=`./findhdr sys/time.h` | |
145 | echo "We'll include <sys/time.h> with KERNEL defined." >&4;; | |
146 | *) i_systimek="$undef";; | |
147 | esac | |
148 | case "$flags" in | |
149 | *I_TIME*) i_time="$define" | |
150 | timeincl=`./findhdr time.h`" $timeincl" | |
151 | echo "We'll include <time.h>." >&4;; | |
152 | *) i_time="$undef";; | |
153 | esac | |
154 | case "$flags" in | |
155 | *I_SYSTIME*) i_systime="$define" | |
156 | timeincl=`./findhdr sys/time.h`" $timeincl" | |
157 | echo "We'll include <sys/time.h>." >&4;; | |
158 | *) i_systime="$undef";; | |
159 | esac | |
160 | @if I_SYSSELECT | |
161 | case "$flags" in | |
162 | *I_SYSSELECT*) i_sysselct="$define" | |
163 | timeincl=`./findhdr sys/select.h`" $timeincl" | |
164 | echo "We'll also include <sys/select.h> to get struct timeval." >&4;; | |
165 | *) case "$i_sysselct" in | |
166 | '') i_sysselct="$undef";; | |
167 | esac | |
168 | esac | |
169 | @end | |
170 | $rm -f try.c try | |
171 |