ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/ptytty.m4
Revision: 1.1
Committed: Sun Jan 22 00:48:13 2006 UTC (18 years, 3 months ago) by root
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

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