1 dnl this file is part of libptytty, do not make local modifications
2 dnl http://software.schmorp.de/pkg/libptytty
29 AC_MSG_CHECKING(for /dev/ptym/clone)
30 if test -e /dev/ptym/clone; then
32 AC_DEFINE(HAVE_DEV_CLONE, 1, [Define to 1 if you have /dev/ptym/clone])
33 AC_DEFINE(CLONE_DEVICE, "/dev/ptym/clone", [clone device filename])
39 AC_MSG_CHECKING(for /dev/ptc)
40 if test -e /dev/ptc; then
42 AC_DEFINE(HAVE_DEV_PTC, 1, [Define to 1 if you have /dev/ptc])
43 AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename])
52 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
55 AC_MSG_CHECKING(for /dev/ptmx)
56 if test -e /dev/ptmx; then
58 AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx])
59 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
67 if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then
68 AC_MSG_CHECKING(for UNIX98 ptys)
69 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
70 [[grantpt(0);unlockpt(0);ptsname(0);]])],
72 AC_DEFINE(UNIX98_PTY, 1, "")
77 if test -z "$unix98_pty"; then
78 AC_CHECK_FUNCS(openpty, [], [AC_CHECK_LIB(util, openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"])])
82 AC_DEFUN([UTMP_CHECK],
89 [AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])],
90 [if test x$enableval = xyes -o x$enableval = xno; then
91 support_utmp=$enableval
95 [AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])],
96 [if test x$enableval = xyes -o x$enableval = xno; then
97 support_wtmp=$enableval
100 AC_ARG_ENABLE(lastlog,
101 [AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])],
102 [if test x$enableval = xyes -o x$enableval = xno; then
103 support_lastlog=$enableval
106 if test x$support_utmp = xyes; then
107 AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support)
109 if test x$support_wtmp = xyes; then
110 AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled)
112 if test x$support_lastlog = xyes; then
113 AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled)
122 AC_CHECK_HEADERS(lastlog.h)
124 dnl# --------------------------------------------------------------------------
125 dnl# DO ALL UTMP AND WTMP CHECKING
126 dnl# --------------------------------------------------------------------------
127 dnl# check for host field in utmp structure
129 dnl# --------------------------------------------
130 AC_CHECK_HEADERS(utmp.h,
131 [AC_CACHE_CHECK([for struct utmp], struct_utmp,
132 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
133 #include <utmp.h>]], [[struct utmp ut;]])],[struct_utmp=yes],[struct_utmp=no])])
134 if test x$struct_utmp = xyes; then
135 AC_DEFINE(HAVE_STRUCT_UTMP, 1, Define if utmp.h has struct utmp)
139 AC_CACHE_CHECK(for ut_host in utmp struct, struct_utmp_host,
140 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
141 #include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],[struct_utmp_host=yes],[struct_utmp_host=no])])
142 if test x$struct_utmp_host = xyes; then
143 AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)
146 AC_CACHE_CHECK(for ut_pid in utmp struct, struct_utmp_pid,
147 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
148 #include <utmp.h>]], [[struct utmp ut; ut.ut_pid;]])],[struct_utmp_pid=yes],[struct_utmp_pid=no])])
149 if test x$struct_utmp_pid = xyes; then
150 AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)
152 ) dnl# AC_CHECK_HEADERS(utmp.h
154 dnl# --------------------------------------------
156 AC_CHECK_HEADERS(utmpx.h,
157 [AC_CACHE_CHECK([for struct utmpx], struct_utmpx,
158 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
159 #include <utmpx.h>]], [[struct utmpx ut;]])],[struct_utmpx=yes],[struct_utmpx=no])])
160 if test x$struct_utmpx = xyes; then
161 AC_DEFINE(HAVE_STRUCT_UTMPX, 1, Define if utmpx.h has struct utmpx)
165 AC_CACHE_CHECK(for host in utmpx struct, struct_utmpx_host,
166 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
167 #include <utmpx.h>]], [[struct utmpx utx; utx.ut_host;]])],[struct_utmpx_host=yes],[struct_utmpx_host=no])])
168 if test x$struct_utmpx_host = xyes; then
169 AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)
172 AC_CACHE_CHECK(for session in utmpx struct, struct_utmpx_session,
173 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
174 #include <utmpx.h>]], [[struct utmpx utx; utx.ut_session;]])],[struct_utmpx_session=yes],[struct_utmpx_session=no])])
175 if test x$struct_utmpx_session = xyes; then
176 AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)
178 ) dnl# AC_CHECK_HEADERS(utmpx.h
180 dnl# --------------------------------------------------------------------------
181 dnl# check for struct lastlog
182 AC_CACHE_CHECK(for struct lastlog, struct_lastlog,
183 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
185 #ifdef HAVE_LASTLOG_H
188 ]], [[struct lastlog ll;]])],[struct_lastlog=yes],[struct_lastlog=no])])
189 if test x$struct_lastlog = xyes; then
190 AC_DEFINE(HAVE_STRUCT_LASTLOG, 1, Define if utmp.h or lastlog.h has struct lastlog)
193 dnl# check for struct lastlogx
194 AC_CACHE_CHECK(for struct lastlogx, struct_lastlogx,
195 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
197 #ifdef HAVE_LASTLOG_H
200 ]], [[struct lastlogx ll;]])],[struct_lastlogx=yes],[struct_lastlogx=no])])
201 if test x$struct_lastlogx = xyes; then
202 AC_DEFINE(HAVE_STRUCT_LASTLOGX, 1, Define if utmpx.h or lastlog.h has struct lastlogx)
205 dnl# --------------------------------------------------------------------------
207 dnl# --------------------------------------------------------------------------
210 AC_CACHE_CHECK(where utmp is located, path_utmp,
211 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
213 #include <sys/types.h>
218 char **u, *utmplist[] = {
219 "/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp", NULL };
220 FILE *a, *f=fopen("conftestval", "w");
223 fprintf(f, "%s\n", UTMP_FILE);
227 fprintf(f, "%s\n", _PATH_UTMP);
230 for (u = utmplist; *u; u++) {
231 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
232 fprintf(f, "%s\n", *u);
237 }]])],[path_utmp=`cat conftestval`],[path_utmp=],[dnl
238 AC_MSG_WARN(Define UTMP_FILE in config.h manually)])])
239 if test x$path_utmp != x; then
240 AC_DEFINE_UNQUOTED(UTMP_FILE, "$path_utmp", Define location of utmp)
243 dnl# --------------------------------------------------------------------------
245 dnl# find utmpx - if a utmp file exists at the same location and is more than
246 dnl# a day newer, then dump the utmpx. People leave lots of junk around.
247 AC_CACHE_CHECK(where utmpx is located, path_utmpx,
248 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
250 #include <sys/types.h>
253 #include <sys/stat.h>
259 char **u, *p, *utmplist[] = {
266 "/var/adm/utmpx", "/etc/utmpx", NULL };
267 FILE *a, *f=fopen("conftestval", "w");
268 struct stat statu, statux;
270 for (u = utmplist; *u; u++) {
271 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
272 if (stat(*u, &statux) < 0)
275 p[strlen(p) - 1] = '\0';
276 if (stat(p, &statu) >= 0
277 && (statu.st_mtime - statux.st_mtime > 86400))
279 fprintf(f, "%s\n", *u);
284 }]])],[path_utmpx=`cat conftestval`],[path_utmpx=],[dnl
285 AC_MSG_WARN(Define UTMPX_FILE in config.h manually)])])
286 if test x$path_utmpx != x; then
287 AC_DEFINE_UNQUOTED(UTMPX_FILE, "$path_utmpx", Define location of utmpx)
290 dnl# --------------------------------------------------------------------------
293 AC_CACHE_CHECK(where wtmp is located, path_wtmp,
294 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
296 #include <sys/types.h>
303 char **w, *wtmplist[] = {
304 "/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp", NULL };
305 FILE *a, *f=fopen("conftestval", "w");
308 fprintf(f, "%s\n", WTMP_FILE);
312 fprintf(f, "%s\n", _PATH_WTMP);
315 for (w = wtmplist; *w; w++) {
316 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
317 fprintf(f, "%s\n", *w);
322 }]])],[path_wtmp=`cat conftestval`],[path_wtmp=],[dnl
323 AC_MSG_WARN(Define WTMP_FILE in config.h manually)])])
324 if test x$path_wtmp != x; then
325 AC_DEFINE_UNQUOTED(WTMP_FILE, "$path_wtmp", Define location of wtmp)
327 dnl# --------------------------------------------------------------------------
330 AC_CACHE_CHECK(where wtmpx is located, path_wtmpx,
331 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
339 char **w, *wtmplist[] = {
340 "/var/log/wtmpx", "/var/adm/wtmpx", NULL };
341 FILE *a, *f=fopen("conftestval", "w");
344 fprintf(f, "%s\n", WTMPX_FILE);
348 fprintf(f, "%s\n", _PATH_WTMPX);
351 for (w = wtmplist; *w; w++) {
352 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
353 fprintf(f, "%s\n", *w);
358 }]])],[path_wtmpx=`cat conftestval`],[path_wtmpx=],[dnl
359 AC_MSG_WARN(Define WTMPX_FILE in config.h manually)])])
360 if test x$path_wtmpx != x; then
361 AC_DEFINE_UNQUOTED(WTMPX_FILE, "$path_wtmpx", Define location of wtmpx)
363 dnl# --------------------------------------------------------------------------
366 AC_CACHE_CHECK(where lastlog is located, path_lastlog,
367 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
369 #include <sys/types.h>
372 #elif defined(HAVE_UTMP_H)
375 #ifdef HAVE_LASTLOG_H
381 char **w, *lastloglist[] = { "/var/log/lastlog", NULL };
382 FILE *a, *f=fopen("conftestval", "w");
385 fprintf(f, "%s\n", LASTLOG_FILE);
389 fprintf(f, "%s\n", _PATH_LASTLOG);
392 for (w = lastloglist; *w; w++) {
393 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
394 fprintf(f, "%s\n", *w);
399 }]])],[path_lastlog=`cat conftestval`],[path_lastlog=],[dnl
400 AC_MSG_WARN(Define LASTLOG_FILE in config.h manually)])])
401 if test x$path_lastlog != x; then
402 AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$path_lastlog", Define location of lastlog)
404 dnl# --------------------------------------------------------------------------
407 AC_CACHE_CHECK(where lastlogx is located, path_lastlogx,
408 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
416 char **w, *wtmplist[] = { "/var/log/lastlogx", "/var/adm/lastlogx", NULL };
417 FILE *a, *f=fopen("conftestval", "w");
420 fprintf(f, "%s\n", LASTLOGX_FILE);
423 #ifdef _PATH_LASTLOGX
424 fprintf(f, "%s\n", _PATH_LASTLOGX);
427 for (w = wtmplist; *w; w++) {
428 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
429 fprintf(f, "%s\n", *w);
434 }]])],[path_lastlogx=`cat conftestval`],[path_lastlogx=],[dnl
435 AC_MSG_WARN(Define LASTLOGX_FILE in config.h manually)])])
436 if test x$path_lastlogx != x; then
437 AC_DEFINE_UNQUOTED(LASTLOGX_FILE, "$path_lastlogx", Define location of lastlogx)
441 AC_DEFUN([SCM_RIGHTS_CHECK],
443 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, can_pass_fds,
444 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
445 #include <cstddef> // broken bsds (is that redundant?) need this
446 #include <sys/types.h>
447 #include <sys/socket.h>
456 iov.iov_base = &data;
461 msg.msg_control = buf;
462 msg.msg_controllen = sizeof buf;
464 cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
465 cmsg->cmsg_level = SOL_SOCKET;
466 cmsg->cmsg_type = SCM_RIGHTS;
467 cmsg->cmsg_len = 100;
469 *(int *)CMSG_DATA (cmsg) = 5;
471 return sendmsg (3, &msg, 0);
473 ]])],[can_pass_fds=yes],[can_pass_fds=no])])
474 if test x$can_pass_fds = xyes; then
475 AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing)
477 AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability])
481 AC_DEFUN([TTY_GROUP_CHECK],
483 AC_CACHE_CHECK([for tty group], tty_group,
484 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
485 #include <sys/types.h>
486 #include <sys/stat.h>
495 gr = getgrnam("tty");
499 && (stat(tty, &st)) == 0
500 && st.st_gid == gr->gr_gid)
504 }]])],[tty_group=yes],[tty_group=no],[tty_group=no])])
505 if test x$tty_group = xyes; then
506 AC_DEFINE(TTY_GID_SUPPORT, 1, "")