1 | # Checks for availability of various utmp fields |
---|
2 | # |
---|
3 | # Original code by Bernhard Rosenkraenzer (bero@linux.net.eu.org), 1998. |
---|
4 | # Modifications by Timur Bakeyev (timur@gnu.org), 1999. |
---|
5 | # Patched from http://bugzilla.gnome.org/show_bug.cgi?id=93774 |
---|
6 | # |
---|
7 | |
---|
8 | dnl GPH_CHECK_UTMP() |
---|
9 | dnl Test for presence of the field and define HAVE_UT_UT_field macro |
---|
10 | dnl |
---|
11 | |
---|
12 | AC_DEFUN([GPH_CHECK_UTMP],[ |
---|
13 | |
---|
14 | AC_CHECK_HEADERS(sys/time.h utmp.h utmpx.h) |
---|
15 | AC_HEADER_TIME |
---|
16 | |
---|
17 | if test "$ac_cv_header_utmpx_h" = "yes"; then |
---|
18 | AC_DEFINE(UTMP,[struct utmpx],[Define to the name of a structure which holds utmp data.]) |
---|
19 | else |
---|
20 | AC_DEFINE(UTMP,[struct utmp],[Define to the name of a structure which holds utmp data.]) |
---|
21 | fi |
---|
22 | |
---|
23 | dnl some systems (BSD4.4-like) require time.h to be included before utmp.h :/ |
---|
24 | AC_MSG_CHECKING(for ut_host field in the utmp structure) |
---|
25 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
26 | #include <sys/time.h> |
---|
27 | #include <time.h> |
---|
28 | #else |
---|
29 | #ifdef HAVE_SYS_TIME_H |
---|
30 | #include <sys/time.h> |
---|
31 | #else |
---|
32 | #include <time.h> |
---|
33 | #endif |
---|
34 | #endif |
---|
35 | #ifdef HAVE_UTMP_H |
---|
36 | #include <utmp.h> |
---|
37 | #endif |
---|
38 | #ifdef HAVE_UTMPX_H |
---|
39 | #include <utmpx.h> |
---|
40 | #endif],[UTMP ut; char *p; p=ut.ut_host;],result=yes,result=no) |
---|
41 | if test "$result" = "yes"; then |
---|
42 | AC_DEFINE(HAVE_UT_UT_HOST,1,[Define if your utmp struct contains a ut_host field.]) |
---|
43 | fi |
---|
44 | AC_MSG_RESULT($result) |
---|
45 | |
---|
46 | AC_MSG_CHECKING(for ut_pid field in the utmp structure) |
---|
47 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
48 | #include <sys/time.h> |
---|
49 | #include <time.h> |
---|
50 | #else |
---|
51 | #ifdef HAVE_SYS_TIME_H |
---|
52 | #include <sys/time.h> |
---|
53 | #else |
---|
54 | #include <time.h> |
---|
55 | #endif |
---|
56 | #endif |
---|
57 | #ifdef HAVE_UTMP_H |
---|
58 | #include <utmp.h> |
---|
59 | #endif |
---|
60 | #ifdef HAVE_UTMPX_H |
---|
61 | #include <utmpx.h> |
---|
62 | #endif],[UTMP ut; int i; i=ut.ut_pid;],result=yes,result=no) |
---|
63 | if test "$result" = "yes"; then |
---|
64 | AC_DEFINE(HAVE_UT_UT_PID,1,[Define if your utmp struct contains a ut_pid field.]) |
---|
65 | fi |
---|
66 | AC_MSG_RESULT($result) |
---|
67 | |
---|
68 | AC_MSG_CHECKING(for ut_id field in the utmp structure) |
---|
69 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
70 | #include <sys/time.h> |
---|
71 | #include <time.h> |
---|
72 | #else |
---|
73 | #ifdef HAVE_SYS_TIME_H |
---|
74 | #include <sys/time.h> |
---|
75 | #else |
---|
76 | #include <time.h> |
---|
77 | #endif |
---|
78 | #endif |
---|
79 | #ifdef HAVE_UTMP_H |
---|
80 | #include <utmp.h> |
---|
81 | #endif |
---|
82 | #ifdef HAVE_UTMPX_H |
---|
83 | #include <utmpx.h> |
---|
84 | #endif],[UTMP ut; char *p; p=ut.ut_id;],result=yes,result=no) |
---|
85 | if test "$result" = "yes"; then |
---|
86 | AC_DEFINE(HAVE_UT_UT_ID,1,[Define if your utmp struct contains a ut_id field.]) |
---|
87 | fi |
---|
88 | AC_MSG_RESULT($result) |
---|
89 | |
---|
90 | AC_MSG_CHECKING(for ut_name field in the utmp structure) |
---|
91 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
92 | #include <sys/time.h> |
---|
93 | #include <time.h> |
---|
94 | #else |
---|
95 | #ifdef HAVE_SYS_TIME_H |
---|
96 | #include <sys/time.h> |
---|
97 | #else |
---|
98 | #include <time.h> |
---|
99 | #endif |
---|
100 | #endif |
---|
101 | #ifdef HAVE_UTMP_H |
---|
102 | #include <utmp.h> |
---|
103 | #endif |
---|
104 | #ifdef HAVE_UTMPX_H |
---|
105 | #include <utmpx.h> |
---|
106 | #endif],[UTMP ut; char *p; p=ut.ut_name;],result=yes,result=no) |
---|
107 | if test "$result" = "yes"; then |
---|
108 | AC_DEFINE(HAVE_UT_UT_NAME,1,[Define if your utmp struct contains a ut_name field.]) |
---|
109 | fi |
---|
110 | AC_MSG_RESULT($result) |
---|
111 | |
---|
112 | AC_MSG_CHECKING(for ut_type field in the utmp structure) |
---|
113 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
114 | #include <sys/time.h> |
---|
115 | #include <time.h> |
---|
116 | #else |
---|
117 | #ifdef HAVE_SYS_TIME_H |
---|
118 | #include <sys/time.h> |
---|
119 | #else |
---|
120 | #include <time.h> |
---|
121 | #endif |
---|
122 | #endif |
---|
123 | #ifdef HAVE_UTMP_H |
---|
124 | #include <utmp.h> |
---|
125 | #endif |
---|
126 | #ifdef HAVE_UTMPX_H |
---|
127 | #include <utmpx.h> |
---|
128 | #endif],[UTMP ut; int i; i=(int) ut.ut_type;],result=yes,result=no) |
---|
129 | if test "$result" = "yes"; then |
---|
130 | AC_DEFINE(HAVE_UT_UT_TYPE,1,[Define if your utmp struct contains a ut_type field.]) |
---|
131 | fi |
---|
132 | AC_MSG_RESULT($result) |
---|
133 | |
---|
134 | AC_MSG_CHECKING(for ut_exit.e_termination field in the utmp structure) |
---|
135 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
136 | #include <sys/time.h> |
---|
137 | #include <time.h> |
---|
138 | #else |
---|
139 | #ifdef HAVE_SYS_TIME_H |
---|
140 | #include <sys/time.h> |
---|
141 | #else |
---|
142 | #include <time.h> |
---|
143 | #endif |
---|
144 | #endif |
---|
145 | #ifdef HAVE_UTMP_H |
---|
146 | #include <utmp.h> |
---|
147 | #endif |
---|
148 | #ifdef HAVE_UTMPX_H |
---|
149 | #include <utmpx.h> |
---|
150 | #endif],[UTMP ut; ut.ut_exit.e_termination=0;],result=yes,result=no) |
---|
151 | if test "$result" = "yes"; then |
---|
152 | AC_DEFINE(HAVE_UT_UT_EXIT_E_TERMINATION,1,[Define if your utmp struct contains a ut_exit.e_termination field.]) |
---|
153 | fi |
---|
154 | AC_MSG_RESULT($result) |
---|
155 | |
---|
156 | AC_MSG_CHECKING(for ut_user field in the utmp structure) |
---|
157 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
158 | #include <sys/time.h> |
---|
159 | #include <time.h> |
---|
160 | #else |
---|
161 | #ifdef HAVE_SYS_TIME_H |
---|
162 | #include <sys/time.h> |
---|
163 | #else |
---|
164 | #include <time.h> |
---|
165 | #endif |
---|
166 | #endif |
---|
167 | #ifdef HAVE_UTMP_H |
---|
168 | #include <utmp.h> |
---|
169 | #endif |
---|
170 | #ifdef HAVE_UTMPX_H |
---|
171 | #include <utmpx.h> |
---|
172 | #endif],[UTMP ut; char *p; p=ut.ut_user;],result=yes,result=no) |
---|
173 | if test "$result" = "yes"; then |
---|
174 | AC_DEFINE(HAVE_UT_UT_USER,1,[Define if your utmp struct contains a ut_user field.]) |
---|
175 | fi |
---|
176 | AC_MSG_RESULT($result) |
---|
177 | |
---|
178 | AC_MSG_CHECKING(for ut_time field in the utmp structure) |
---|
179 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
180 | #include <sys/time.h> |
---|
181 | #include <time.h> |
---|
182 | #else |
---|
183 | #ifdef HAVE_SYS_TIME_H |
---|
184 | #include <sys/time.h> |
---|
185 | #else |
---|
186 | #include <time.h> |
---|
187 | #endif |
---|
188 | #endif |
---|
189 | #ifdef HAVE_UTMP_H |
---|
190 | #include <utmp.h> |
---|
191 | #endif |
---|
192 | #ifdef HAVE_UTMPX_H |
---|
193 | #include <utmpx.h> |
---|
194 | #endif],[UTMP ut; ut.ut_time=0;],result=yes,result=no) |
---|
195 | if test "$result" = "yes"; then |
---|
196 | AC_DEFINE(HAVE_UT_UT_TIME,1,[Define if your utmp struct contains a ut_time field.]) |
---|
197 | fi |
---|
198 | AC_MSG_RESULT($result) |
---|
199 | |
---|
200 | AC_MSG_CHECKING(for ut_tv field in the utmp structure) |
---|
201 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
202 | #include <sys/time.h> |
---|
203 | #include <time.h> |
---|
204 | #else |
---|
205 | #ifdef HAVE_SYS_TIME_H |
---|
206 | #include <sys/time.h> |
---|
207 | #else |
---|
208 | #include <time.h> |
---|
209 | #endif |
---|
210 | #endif |
---|
211 | #ifdef HAVE_UTMP_H |
---|
212 | #include <utmp.h> |
---|
213 | #endif |
---|
214 | #ifdef HAVE_UTMPX_H |
---|
215 | #include <utmpx.h> |
---|
216 | #endif],[UTMP ut; ut.ut_tv.tv_sec=0; ut.ut_tv.tv_usec=0; ],result=yes,result=no) |
---|
217 | if test "$result" = "yes"; then |
---|
218 | AC_DEFINE(HAVE_UT_UT_TV,1,[Define if your utmp struct contains a ut_tv field.]) |
---|
219 | fi |
---|
220 | AC_MSG_RESULT($result) |
---|
221 | |
---|
222 | AC_MSG_CHECKING(for ut_syslen field in the utmp structure) |
---|
223 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
224 | #include <sys/time.h> |
---|
225 | #include <time.h> |
---|
226 | #else |
---|
227 | #ifdef HAVE_SYS_TIME_H |
---|
228 | #include <sys/time.h> |
---|
229 | #else |
---|
230 | #include <time.h> |
---|
231 | #endif |
---|
232 | #endif |
---|
233 | #ifdef HAVE_UTMP_H |
---|
234 | #include <utmp.h> |
---|
235 | #endif |
---|
236 | #ifdef HAVE_UTMPX_H |
---|
237 | #include <utmpx.h> |
---|
238 | #endif],[UTMP ut; ut.ut_syslen=0;],result=yes,result=no) |
---|
239 | if test "$result" = "yes"; then |
---|
240 | AC_DEFINE(HAVE_UT_UT_SYSLEN,1,[Define if your utmp struct contains a ut_syslen field.]) |
---|
241 | fi |
---|
242 | AC_MSG_RESULT($result) |
---|
243 | |
---|
244 | ]) |
---|