ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/ptytty.m4
Revision: 1.16
Committed: Mon May 30 21:31:12 2011 UTC (12 years, 11 months ago) by sf-exg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.15: +0 -0 lines
State: FILE REMOVED
Log Message:
Purge ptytty.m4.

File Contents

# Content
1 dnl this file is part of libptytty, do not make local modifications
2 dnl http://software.schmorp.de/pkg/libptytty
3
4 AC_DEFUN([PTY_CHECK],
5 [
6 AC_CHECK_HEADERS( \
7 pty.h \
8 util.h \
9 libutil.h \
10 sys/ioctl.h \
11 sys/stropts.h \
12 stropts.h \
13 )
14
15 AC_CHECK_FUNCS( \
16 revoke \
17 _getpty \
18 getpt \
19 posix_openpt \
20 isastream \
21 setuid \
22 seteuid \
23 setreuid \
24 setresuid \
25 )
26
27 have_clone=no
28
29 AC_MSG_CHECKING(for /dev/ptc)
30 if test -e /dev/ptc; then
31 AC_MSG_RESULT(yes)
32 AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename])
33 have_clone=yes
34 else
35 AC_MSG_RESULT(no)
36 fi
37
38 case $host in
39 *-*-cygwin*)
40 have_clone=yes
41 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
42 ;;
43 *)
44 AC_MSG_CHECKING(for /dev/ptmx)
45 if test -e /dev/ptmx; then
46 AC_MSG_RESULT(yes)
47 AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx])
48 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
49 have_clone=yes
50 else
51 AC_MSG_RESULT(no)
52 fi
53 ;;
54 esac
55
56 if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then
57 AC_MSG_CHECKING(for UNIX98 ptys)
58 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
59 [[grantpt(0);unlockpt(0);ptsname(0);]])],
60 [unix98_pty=yes
61 AC_DEFINE(UNIX98_PTY, 1, "")
62 AC_MSG_RESULT(yes)],
63 [AC_MSG_RESULT(no)])
64 fi
65
66 if test -z "$unix98_pty"; then
67 AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, ""))
68 fi
69 ])
70
71 AC_DEFUN([UTMP_CHECK],
72 [
73 support_utmp=yes
74 support_wtmp=yes
75 support_lastlog=yes
76
77 AC_ARG_ENABLE(utmp,
78 [AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])],
79 [if test x$enableval = xyes -o x$enableval = xno; then
80 support_utmp=$enableval
81 fi])
82
83 AC_ARG_ENABLE(wtmp,
84 [AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])],
85 [if test x$enableval = xyes -o x$enableval = xno; then
86 support_wtmp=$enableval
87 fi])
88
89 AC_ARG_ENABLE(lastlog,
90 [AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])],
91 [if test x$enableval = xyes -o x$enableval = xno; then
92 support_lastlog=$enableval
93 fi])
94
95 if test x$support_utmp = xyes; then
96 AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support)
97 fi
98 if test x$support_wtmp = xyes; then
99 AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled)
100 fi
101 if test x$support_lastlog = xyes; then
102 AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled)
103 fi
104
105 AC_CHECK_FUNCS( \
106 updwtmp \
107 updwtmpx \
108 updlastlogx \
109 )
110
111 AC_CHECK_HEADERS(lastlog.h)
112
113 dnl# --------------------------------------------------------------------------
114 dnl# DO ALL UTMP AND WTMP CHECKING
115 dnl# --------------------------------------------------------------------------
116 dnl# check for host field in utmp structure
117
118 dnl# --------------------------------------------
119 AC_CHECK_HEADERS(utmp.h,
120 [AC_CACHE_CHECK([for struct utmp], pt_cv_struct_utmp,
121 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
122 #include <utmp.h>]], [[struct utmp ut;]])],[pt_cv_struct_utmp=yes],[pt_cv_struct_utmp=no])])
123 if test x$pt_cv_struct_utmp = xyes; then
124 AC_DEFINE(HAVE_STRUCT_UTMP, 1, Define if utmp.h has struct utmp)
125 fi
126 ]
127
128 AC_CACHE_CHECK(for ut_host in utmp struct, pt_cv_struct_utmp_host,
129 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
130 #include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],[pt_cv_struct_utmp_host=yes],[pt_cv_struct_utmp_host=no])])
131 if test x$pt_cv_struct_utmp_host = xyes; then
132 AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)
133 fi
134
135 AC_CACHE_CHECK(for ut_pid in utmp struct, pt_cv_struct_utmp_pid,
136 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
137 #include <utmp.h>]], [[struct utmp ut; ut.ut_pid;]])],[pt_cv_struct_utmp_pid=yes],[pt_cv_struct_utmp_pid=no])])
138 if test x$pt_cv_struct_utmp_pid = xyes; then
139 AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)
140 fi
141 ) dnl# AC_CHECK_HEADERS(utmp.h
142
143 dnl# --------------------------------------------
144
145 AC_CHECK_HEADERS(utmpx.h,
146 [AC_CACHE_CHECK([for struct utmpx], pt_cv_struct_utmpx,
147 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
148 #include <utmpx.h>]], [[struct utmpx ut;]])],[pt_cv_struct_utmpx=yes],[pt_cv_struct_utmpx=no])])
149 if test x$pt_cv_struct_utmpx = xyes; then
150 AC_DEFINE(HAVE_STRUCT_UTMPX, 1, Define if utmpx.h has struct utmpx)
151 fi
152 ]
153
154 AC_CACHE_CHECK(for host in utmpx struct, pt_cv_struct_utmpx_host,
155 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
156 #include <utmpx.h>]], [[struct utmpx utx; utx.ut_host;]])],[pt_cv_struct_utmpx_host=yes],[pt_cv_struct_utmpx_host=no])])
157 if test x$pt_cv_struct_utmpx_host = xyes; then
158 AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)
159 fi
160
161 AC_CACHE_CHECK(for session in utmpx struct, pt_cv_struct_utmpx_session,
162 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
163 #include <utmpx.h>]], [[struct utmpx utx; utx.ut_session;]])],[pt_cv_struct_utmpx_session=yes],[pt_cv_struct_utmpx_session=no])])
164 if test x$pt_cv_struct_utmpx_session = xyes; then
165 AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)
166 fi
167 ) dnl# AC_CHECK_HEADERS(utmpx.h
168
169 dnl# --------------------------------------------------------------------------
170 dnl# check for struct lastlog
171 AC_CACHE_CHECK(for struct lastlog, pt_cv_struct_lastlog,
172 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
173 #include <utmp.h>
174 #ifdef HAVE_LASTLOG_H
175 #include <lastlog.h>
176 #endif
177 ]], [[struct lastlog ll;]])],[pt_cv_struct_lastlog=yes],[pt_cv_struct_lastlog=no])])
178 if test x$pt_cv_struct_lastlog = xyes; then
179 AC_DEFINE(HAVE_STRUCT_LASTLOG, 1, Define if utmp.h or lastlog.h has struct lastlog)
180 fi
181
182 dnl# check for struct lastlogx
183 AC_CACHE_CHECK(for struct lastlogx, pt_cv_struct_lastlogx,
184 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
185 #include <utmpx.h>
186 #ifdef HAVE_LASTLOG_H
187 #include <lastlog.h>
188 #endif
189 ]], [[struct lastlogx ll;]])],[pt_cv_struct_lastlogx=yes],[pt_cv_struct_lastlogx=no])])
190 if test x$pt_cv_struct_lastlogx = xyes; then
191 AC_DEFINE(HAVE_STRUCT_LASTLOGX, 1, Define if utmpx.h or lastlog.h has struct lastlogx)
192 fi
193
194 dnl# --------------------------------------------------------------------------
195 dnl# FIND FILES
196 dnl# --------------------------------------------------------------------------
197
198 dnl# find utmp
199 AC_CACHE_CHECK(where utmp is located, pt_cv_path_utmp,
200 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
201 #include <stdlib.h>
202 #include <sys/types.h>
203 #include <utmp.h>
204 #include <errno.h>
205 int main()
206 {
207 char **u, *utmplist[] = {
208 "/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp", NULL };
209 FILE *a, *f=fopen("conftestval", "w");
210 if (!f) exit(1);
211 #ifdef UTMP_FILE
212 fprintf(f, "%s\n", UTMP_FILE);
213 exit(0);
214 #endif
215 #ifdef _PATH_UTMP
216 fprintf(f, "%s\n", _PATH_UTMP);
217 exit(0);
218 #endif
219 for (u = utmplist; *u; u++) {
220 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
221 fprintf(f, "%s\n", *u);
222 exit(0);
223 }
224 }
225 exit(0);
226 }]])],[pt_cv_path_utmp=`cat conftestval`],[pt_cv_path_utmp=],[dnl
227 AC_MSG_WARN(Define UTMP_FILE in config.h manually)])])
228 if test x$pt_cv_path_utmp != x; then
229 AC_DEFINE_UNQUOTED(UTMP_FILE, "$pt_cv_path_utmp", Define location of utmp)
230 fi
231
232 dnl# --------------------------------------------------------------------------
233
234 dnl# find wtmp
235 AC_CACHE_CHECK(where wtmp is located, pt_cv_path_wtmp,
236 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
237 #include <stdlib.h>
238 #include <sys/types.h>
239 #ifdef HAVE_UTMP_H
240 #include <utmp.h>
241 #endif
242 #include <errno.h>
243 int main()
244 {
245 char **w, *wtmplist[] = {
246 "/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp", NULL };
247 FILE *a, *f=fopen("conftestval", "w");
248 if (!f) exit(1);
249 #ifdef WTMP_FILE
250 fprintf(f, "%s\n", WTMP_FILE);
251 exit(0);
252 #endif
253 #ifdef _PATH_WTMP
254 fprintf(f, "%s\n", _PATH_WTMP);
255 exit(0);
256 #endif
257 for (w = wtmplist; *w; w++) {
258 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
259 fprintf(f, "%s\n", *w);
260 exit(0);
261 }
262 }
263 exit(0);
264 }]])],[pt_cv_path_wtmp=`cat conftestval`],[pt_cv_path_wtmp=],[dnl
265 AC_MSG_WARN(Define WTMP_FILE in config.h manually)])])
266 if test x$pt_cv_path_wtmp != x; then
267 AC_DEFINE_UNQUOTED(WTMP_FILE, "$pt_cv_path_wtmp", Define location of wtmp)
268 fi
269 dnl# --------------------------------------------------------------------------
270
271 dnl# find wtmpx
272 AC_CACHE_CHECK(where wtmpx is located, pt_cv_path_wtmpx,
273 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
274 #include <stdlib.h>
275 #ifdef HAVE_UTMPX_H
276 #include <utmpx.h>
277 #endif
278 #include <errno.h>
279 int main()
280 {
281 char **w, *wtmplist[] = {
282 "/var/log/wtmpx", "/var/adm/wtmpx", NULL };
283 FILE *a, *f=fopen("conftestval", "w");
284 if (!f) exit(1);
285 #ifdef WTMPX_FILE
286 fprintf(f, "%s\n", WTMPX_FILE);
287 exit(0);
288 #endif
289 #ifdef _PATH_WTMPX
290 fprintf(f, "%s\n", _PATH_WTMPX);
291 exit(0);
292 #endif
293 for (w = wtmplist; *w; w++) {
294 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
295 fprintf(f, "%s\n", *w);
296 exit(0);
297 }
298 }
299 exit(0);
300 }]])],[pt_cv_path_wtmpx=`cat conftestval`],[pt_cv_path_wtmpx=],[dnl
301 AC_MSG_WARN(Define WTMPX_FILE in config.h manually)])])
302 if test x$pt_cv_path_wtmpx != x; then
303 AC_DEFINE_UNQUOTED(WTMPX_FILE, "$pt_cv_path_wtmpx", Define location of wtmpx)
304 fi
305 dnl# --------------------------------------------------------------------------
306
307 dnl# find lastlog
308 AC_CACHE_CHECK(where lastlog is located, pt_cv_path_lastlog,
309 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
310 #include <stdlib.h>
311 #include <sys/types.h>
312 #ifdef HAVE_UTMPX_H
313 #include <utmpx.h>
314 #elif defined(HAVE_UTMP_H)
315 #include <utmp.h>
316 #endif
317 #ifdef HAVE_LASTLOG_H
318 #include <lastlog.h>
319 #endif
320 #include <errno.h>
321 int main()
322 {
323 char **w, *lastloglist[] = { "/var/log/lastlog", NULL };
324 FILE *a, *f=fopen("conftestval", "w");
325 if (!f) exit(1);
326 #ifdef LASTLOG_FILE
327 fprintf(f, "%s\n", LASTLOG_FILE);
328 exit(0);
329 #endif
330 #ifdef _PATH_LASTLOG
331 fprintf(f, "%s\n", _PATH_LASTLOG);
332 exit(0);
333 #endif
334 for (w = lastloglist; *w; w++) {
335 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
336 fprintf(f, "%s\n", *w);
337 exit(0);
338 }
339 }
340 exit(0);
341 }]])],[pt_cv_path_lastlog=`cat conftestval`],[pt_cv_path_lastlog=],[dnl
342 AC_MSG_WARN(Define LASTLOG_FILE in config.h manually)])])
343 if test x$pt_cv_path_lastlog != x; then
344 AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$pt_cv_path_lastlog", Define location of lastlog)
345 fi
346 dnl# --------------------------------------------------------------------------
347
348 dnl# find lastlogx
349 AC_CACHE_CHECK(where lastlogx is located, pt_cv_path_lastlogx,
350 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
351 #include <stdlib.h>
352 #ifdef HAVE_UTMPX_H
353 #include <utmpx.h>
354 #endif
355 #include <errno.h>
356 int main()
357 {
358 char **w, *wtmplist[] = { "/var/log/lastlogx", "/var/adm/lastlogx", NULL };
359 FILE *a, *f=fopen("conftestval", "w");
360 if (!f) exit(1);
361 #ifdef LASTLOGX_FILE
362 fprintf(f, "%s\n", LASTLOGX_FILE);
363 exit(0);
364 #endif
365 #ifdef _PATH_LASTLOGX
366 fprintf(f, "%s\n", _PATH_LASTLOGX);
367 exit(0);
368 #endif
369 for (w = wtmplist; *w; w++) {
370 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
371 fprintf(f, "%s\n", *w);
372 exit(0);
373 }
374 }
375 exit(0);
376 }]])],[pt_cv_path_lastlogx=`cat conftestval`],[pt_cv_path_lastlogx=],[dnl
377 AC_MSG_WARN(Define LASTLOGX_FILE in config.h manually)])])
378 if test x$pt_cv_path_lastlogx != x; then
379 AC_DEFINE_UNQUOTED(LASTLOGX_FILE, "$pt_cv_path_lastlogx", Define location of lastlogx)
380 fi
381 ])
382
383 AC_DEFUN([SCM_RIGHTS_CHECK],
384 [
385 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds,
386 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
387 #include <cstddef> // broken bsds (is that redundant?) need this
388 #include <sys/types.h>
389 #include <sys/socket.h>
390 #include <sys/uio.h>
391 ]], [[
392 {
393 msghdr msg;
394 iovec iov;
395 char buf [100];
396 char data = 0;
397
398 iov.iov_base = &data;
399 iov.iov_len = 1;
400
401 msg.msg_iov = &iov;
402 msg.msg_iovlen = 1;
403 msg.msg_control = buf;
404 msg.msg_controllen = sizeof buf;
405
406 cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
407 cmsg->cmsg_level = SOL_SOCKET;
408 cmsg->cmsg_type = SCM_RIGHTS;
409 cmsg->cmsg_len = 100;
410
411 *(int *)CMSG_DATA (cmsg) = 5;
412
413 return sendmsg (3, &msg, 0);
414 }
415 ]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])])
416 if test x$pt_cv_can_pass_fds = xyes; then
417 AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing)
418 else
419 AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability])
420 fi
421 ])
422
423 AC_DEFUN([TTY_GROUP_CHECK],
424 [
425 AC_CACHE_CHECK([for tty group], pt_cv_tty_group,
426 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
427 #include <sys/types.h>
428 #include <sys/stat.h>
429 #include <unistd.h>
430 #include <grp.h>
431
432 int main()
433 {
434 struct stat st;
435 struct group *gr;
436 char *tty;
437 gr = getgrnam("tty");
438 tty = ttyname(0);
439 if (gr != 0
440 && tty != 0
441 && (stat(tty, &st)) == 0
442 && st.st_gid == gr->gr_gid)
443 return 0;
444 else
445 return 1;
446 }]])],[pt_cv_tty_group=yes],[pt_cv_tty_group=no],[pt_cv_tty_group=no])])
447 if test x$pt_cv_tty_group = xyes; then
448 AC_DEFINE(TTY_GID_SUPPORT, 1, "")
449 fi])
450