1 dnl this file is part of libptytty, do not make local modifications
2 dnl http://software.schmorp.de/pkg/libptytty
28 AC_MSG_CHECKING(for /dev/ptym/clone)
29 if test -e /dev/ptym/clone; then
31 AC_DEFINE(HAVE_DEV_CLONE, 1, [Define to 1 if you have /dev/ptym/clone])
32 AC_DEFINE(CLONE_DEVICE, "/dev/ptym/clone", [clone device filename])
38 AC_MSG_CHECKING(for /dev/ptc)
39 if test -e /dev/ptc; then
41 AC_DEFINE(HAVE_DEV_PTC, 1, [Define to 1 if you have /dev/ptc])
42 AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename])
51 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
54 AC_MSG_CHECKING(for /dev/ptmx)
55 if test -e /dev/ptmx; then
57 AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx])
58 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
66 if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then
67 AC_MSG_CHECKING(for UNIX98 ptys)
68 AC_TRY_LINK([#include <stdlib.h>],
69 [grantpt(0);unlockpt(0);ptsname(0);],
71 AC_DEFINE(UNIX98_PTY, 1, "")
76 if test -z "$unix98_pty"; then
77 AC_CHECK_FUNCS(openpty, [], [AC_CHECK_LIB(util, openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"])])
81 AC_DEFUN([UTMP_CHECK],
88 [ --enable-utmp enable utmp (utmpx) support],
89 [if test x$enableval = xyes -o x$enableval = xno; then
90 support_utmp=$enableval
94 [ --enable-wtmp enable wtmp (wtmpx) support (requires --enable-utmp)],
95 [if test x$enableval = xyes -o x$enableval = xno; then
96 support_wtmp=$enableval
99 AC_ARG_ENABLE(lastlog,
100 [ --enable-lastlog enable lastlog support (requires --enable-utmp)],
101 [if test x$enableval = xyes -o x$enableval = xno; then
102 support_lastlog=$enableval
105 if test x$support_utmp = xyes; then
106 AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support)
108 if test x$support_wtmp = xyes; then
109 AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled)
111 if test x$support_lastlog = xyes; then
112 AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled)
127 dnl# --------------------------------------------------------------------------
128 dnl# DO ALL UTMP AND WTMP CHECKING
129 dnl# --------------------------------------------------------------------------
130 dnl# check for host field in utmp structure
132 dnl# --------------------------------------------
133 AC_CHECK_HEADER(utmp.h,
134 [AC_CACHE_CHECK([for struct utmp], struct_utmp,
135 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
136 #include <utmp.h>]], [[struct utmp ut;]])],[struct_utmp=yes],[struct_utmp=no])])
137 if test x$struct_utmp = xyes; then
138 AC_DEFINE(HAVE_STRUCT_UTMP, 1, Define if utmp.h has struct utmp)
142 AC_CACHE_CHECK(for ut_host in utmp struct, struct_utmp_host,
143 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
144 #include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],[struct_utmp_host=yes],[struct_utmp_host=no])])
145 if test x$struct_utmp_host = xyes; then
146 AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)
149 AC_CACHE_CHECK(for ut_pid in utmp struct, struct_utmp_pid,
150 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
151 #include <utmp.h>]], [[struct utmp ut; ut.ut_pid;]])],[struct_utmp_pid=yes],[struct_utmp_pid=no])])
152 if test x$struct_utmp_pid = xyes; then
153 AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)
155 ) dnl# AC_CHECK_HEADER(utmp.h
157 dnl# --------------------------------------------
159 AC_CHECK_HEADER(utmpx.h,
160 [AC_CACHE_CHECK([for struct utmpx], struct_utmpx,
161 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
162 #include <utmpx.h>]], [[struct utmpx ut;]])],[struct_utmpx=yes],[struct_utmpx=no])])
163 if test x$struct_utmpx = xyes; then
164 AC_DEFINE(HAVE_STRUCT_UTMPX, 1, Define if utmpx.h has struct utmpx)
168 AC_CACHE_CHECK(for host in utmpx struct, struct_utmpx_host,
169 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
170 #include <utmpx.h>]], [[struct utmpx utx; utx.ut_host;]])],[struct_utmpx_host=yes],[struct_utmpx_host=no])])
171 if test x$struct_utmpx_host = xyes; then
172 AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)
175 AC_CACHE_CHECK(for session in utmpx struct, struct_utmpx_session,
176 [AC_TRY_COMPILE([#include <sys/types.h>
178 [struct utmpx utx; utx.ut_session;],
179 struct_utmpx_session=yes, struct_utmpx_session=no)])
180 if test x$struct_utmpx_session = xyes; then
181 AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)
183 ) dnl# AC_CHECK_HEADER(utmpx.h
185 dnl# --------------------------------------------------------------------------
186 dnl# check for struct lastlog
187 AC_CACHE_CHECK(for struct lastlog, struct_lastlog,
188 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
190 #ifdef HAVE_LASTLOG_H
193 ]], [[struct lastlog ll;]])],[struct_lastlog=yes],[struct_lastlog=no])])
194 if test x$struct_lastlog = xyes; then
195 AC_DEFINE(HAVE_STRUCT_LASTLOG, 1, Define if utmp.h or lastlog.h has struct lastlog)
198 dnl# check for struct lastlogx
199 AC_CACHE_CHECK(for struct lastlogx, struct_lastlogx,
200 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
202 #ifdef HAVE_LASTLOG_H
205 ]], [[struct lastlogx ll;]])],[struct_lastlogx=yes],[struct_lastlogx=no])])
206 if test x$struct_lastlogx = xyes; then
207 AC_DEFINE(HAVE_STRUCT_LASTLOGX, 1, Define if utmpx.h or lastlog.h has struct lastlogx)
210 dnl# --------------------------------------------------------------------------
212 dnl# --------------------------------------------------------------------------
215 AC_CACHE_CHECK(where utmp is located, path_utmp,
216 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
217 #include <sys/types.h>
222 char **u, *utmplist[] = {
223 "/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp", NULL };
224 FILE *a, *f=fopen("conftestval", "w");
227 fprintf(f, "%s\n", UTMP_FILE);
231 fprintf(f, "%s\n", _PATH_UTMP);
234 for (u = utmplist; *u; u++) {
235 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
236 fprintf(f, "%s\n", *u);
241 }]])],[path_utmp=`cat conftestval`],[path_utmp=],[dnl
242 AC_MSG_WARN(Define UTMP_FILE in config.h manually)])])
243 if test x$path_utmp != x; then
244 AC_DEFINE_UNQUOTED(UTMP_FILE, "$path_utmp", Define location of utmp)
247 dnl# --------------------------------------------------------------------------
249 dnl# find utmpx - if a utmp file exists at the same location and is more than
250 dnl# a day newer, then dump the utmpx. People leave lots of junk around.
251 AC_CACHE_CHECK(where utmpx is located, path_utmpx,
252 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
253 #include <sys/types.h>
256 #include <sys/stat.h>
262 char **u, *p, *utmplist[] = {
269 "/var/adm/utmpx", "/etc/utmpx", NULL };
270 FILE *a, *f=fopen("conftestval", "w");
271 struct stat statu, statux;
273 for (u = utmplist; *u; u++) {
274 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
275 if (stat(*u, &statux) < 0)
278 p[strlen(p) - 1] = '\0';
279 if (stat(p, &statu) >= 0
280 && (statu.st_mtime - statux.st_mtime > 86400))
282 fprintf(f, "%s\n", *u);
287 }]])],[path_utmpx=`cat conftestval`],[path_utmpx=],[dnl
288 AC_MSG_WARN(Define UTMPX_FILE in config.h manually)])])
289 if test x$path_utmpx != x; then
290 AC_DEFINE_UNQUOTED(UTMPX_FILE, "$path_utmpx", Define location of utmpx)
293 dnl# --------------------------------------------------------------------------
296 AC_CACHE_CHECK(where wtmp is located, path_wtmp,
297 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
298 #include <sys/types.h>
305 char **w, *wtmplist[] = {
306 "/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp", NULL };
307 FILE *a, *f=fopen("conftestval", "w");
310 fprintf(f, "%s\n", WTMP_FILE);
314 fprintf(f, "%s\n", _PATH_WTMP);
317 for (w = wtmplist; *w; w++) {
318 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
319 fprintf(f, "%s\n", *w);
324 }]])],[path_wtmp=`cat conftestval`],[path_wtmp=],[dnl
325 AC_MSG_WARN(Define WTMP_FILE in config.h manually)])])
326 if test x$path_wtmp != x; then
327 AC_DEFINE_UNQUOTED(WTMP_FILE, "$path_wtmp", Define location of wtmp)
329 dnl# --------------------------------------------------------------------------
332 AC_CACHE_CHECK(where wtmpx is located, path_wtmpx,
333 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
340 char **w, *wtmplist[] = {
341 "/var/log/wtmpx", "/var/adm/wtmpx", NULL };
342 FILE *a, *f=fopen("conftestval", "w");
345 fprintf(f, "%s\n", WTMPX_FILE);
349 fprintf(f, "%s\n", _PATH_WTMPX);
352 for (w = wtmplist; *w; w++) {
353 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
354 fprintf(f, "%s\n", *w);
359 }]])],[path_wtmpx=`cat conftestval`],[path_wtmpx=],[dnl
360 AC_MSG_WARN(Define WTMPX_FILE in config.h manually)])])
361 if test x$path_wtmpx != x; then
362 AC_DEFINE_UNQUOTED(WTMPX_FILE, "$path_wtmpx", Define location of wtmpx)
364 dnl# --------------------------------------------------------------------------
367 AC_CACHE_CHECK(where lastlog is located, path_lastlog,
368 [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)
403 if test -d "$path_lastlog"; then
404 AC_DEFINE(LASTLOG_IS_DIR, 1, Define if lastlog is provided via a directory)
407 dnl# --------------------------------------------------------------------------
410 AC_CACHE_CHECK(where lastlogx is located, path_lastlogx,
411 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
418 char **w, *wtmplist[] = { "/var/log/lastlogx", "/var/adm/lastlogx", NULL };
419 FILE *a, *f=fopen("conftestval", "w");
422 fprintf(f, "%s\n", LASTLOGX_FILE);
425 #ifdef _PATH_LASTLOGX
426 fprintf(f, "%s\n", _PATH_LASTLOGX);
429 for (w = wtmplist; *w; w++) {
430 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
431 fprintf(f, "%s\n", *w);
436 }]])],[path_lastlogx=`cat conftestval`],[path_lastlogx=],[dnl
437 AC_MSG_WARN(Define LASTLOGX_FILE in config.h manually)])])
438 if test x$path_lastlogx != x; then
439 AC_DEFINE_UNQUOTED(LASTLOGX_FILE, "$path_lastlogx", Define location of lastlogx)
442 if test x$support_utmp != xyes; then
443 echo " utmp support: disabled"
446 echo " utmp support: enabled
447 utmp file: $path_utmp
448 utmpx file: $path_utmpx
449 wtmp file: $path_wtmp
450 wtmpx file: $path_wtmpx
451 lastlog file: $path_lastlog
452 lastlogx file: $path_lastlogx"
456 AC_DEFUN([SCM_RIGHTS_CHECK],
458 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, can_pass_fds,
460 #include <cstddef> // broken bsds (is that redundant?) need this
461 #include <sys/types.h>
462 #include <sys/socket.h>
471 iov.iov_base = &data;
476 msg.msg_control = buf;
477 msg.msg_controllen = sizeof buf;
479 cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
480 cmsg->cmsg_level = SOL_SOCKET;
481 cmsg->cmsg_type = SCM_RIGHTS;
482 cmsg->cmsg_len = 100;
484 *(int *)CMSG_DATA (cmsg) = 5;
486 return sendmsg (3, &msg, 0);
488 ],[can_pass_fds=yes],[can_pass_fds=no])])
489 if test x$can_pass_fds = xyes; then
490 AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing)
492 AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability])
496 AC_DEFUN([TTY_GROUP_CHECK],
498 AC_CACHE_CHECK([for tty group], tty_group,
500 #include <sys/types.h>
501 #include <sys/stat.h>
510 gr = getgrnam("tty");
514 && (stat(tty, &st)) == 0
515 && st.st_gid == gr->gr_gid)
520 [tty_group=yes],[tty_group=no],[tty_group=no])])
521 if test x$tty_group = xyes; then
522 AC_DEFINE(TTY_GID_SUPPORT, 1, "")