1 dnl this file is part of libptytty, do not make local modifications
2 dnl http://software.schmorp.de/pkg/libptytty
24 AC_MSG_CHECKING(for /dev/ptym/clone)
25 if test -e /dev/ptym/clone; then
27 AC_DEFINE(HAVE_DEV_CLONE, 1, [Define to 1 if you have /dev/ptym/clone])
28 AC_DEFINE(CLONE_DEVICE, "/dev/ptym/clone", [clone device filename])
34 AC_MSG_CHECKING(for /dev/ptc)
35 if test -e /dev/ptc; then
37 AC_DEFINE(HAVE_DEV_PTC, 1, [Define to 1 if you have /dev/ptc])
38 AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename])
47 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
50 AC_MSG_CHECKING(for /dev/ptmx)
51 if test -e /dev/ptmx; then
53 AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx])
54 AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename])
62 if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then
63 AC_MSG_CHECKING(for UNIX98 ptys)
64 AC_TRY_LINK([#include <stdlib.h>],
65 [grantpt(0);unlockpt(0);ptsname(0);],
67 AC_DEFINE(UNIX98_PTY, 1, "")
72 if test -z "$unix98_pty"; then
73 AC_CHECK_FUNCS(openpty, [], [AC_CHECK_LIB(util, openpty, [AC_DEFINE(HAVE_OPENPTY) LIBS="$LIBS -lutil"])])
77 AC_DEFUN([UTMP_CHECK],
84 [ --enable-utmp enable utmp (utmpx) support],
85 [if test x$enableval = xyes -o x$enableval = xno; then
86 support_utmp=$enableval
90 [ --enable-wtmp enable wtmp (wtmpx) support (requires --enable-utmp)],
91 [if test x$enableval = xyes -o x$enableval = xno; then
92 support_wtmp=$enableval
95 AC_ARG_ENABLE(lastlog,
96 [ --enable-lastlog enable lastlog support (requires --enable-utmp)],
97 [if test x$enableval = xyes -o x$enableval = xno; then
98 support_lastlog=$enableval
101 if test x$support_utmp = xyes; then
102 AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support)
104 if test x$support_wtmp = xyes; then
105 AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled)
107 if test x$support_lastlog = xyes; then
108 AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled)
123 dnl# --------------------------------------------------------------------------
124 dnl# DO ALL UTMP AND WTMP CHECKING
125 dnl# --------------------------------------------------------------------------
126 dnl# check for host field in utmp structure
128 dnl# --------------------------------------------
129 AC_CHECK_HEADER(utmp.h,
130 [AC_CACHE_CHECK([for struct utmp], struct_utmp,
131 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
132 #include <utmp.h>]], [[struct utmp ut;]])],[struct_utmp=yes],[struct_utmp=no])])
133 if test x$struct_utmp = xyes; then
134 AC_DEFINE(HAVE_STRUCT_UTMP, 1, Define if utmp.h has struct utmp)
138 AC_CACHE_CHECK(for ut_host in utmp struct, struct_utmp_host,
139 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
140 #include <utmp.h>]], [[struct utmp ut; ut.ut_host;]])],[struct_utmp_host=yes],[struct_utmp_host=no])])
141 if test x$struct_utmp_host = xyes; then
142 AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)
145 AC_CACHE_CHECK(for ut_pid in utmp struct, struct_utmp_pid,
146 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
147 #include <utmp.h>]], [[struct utmp ut; ut.ut_pid;]])],[struct_utmp_pid=yes],[struct_utmp_pid=no])])
148 if test x$struct_utmp_pid = xyes; then
149 AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)
151 ) dnl# AC_CHECK_HEADER(utmp.h
153 dnl# --------------------------------------------
155 AC_CHECK_HEADER(utmpx.h,
156 [AC_CACHE_CHECK([for struct utmpx], struct_utmpx,
157 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
158 #include <utmpx.h>]], [[struct utmpx ut;]])],[struct_utmpx=yes],[struct_utmpx=no])])
159 if test x$struct_utmpx = xyes; then
160 AC_DEFINE(HAVE_STRUCT_UTMPX, 1, Define if utmpx.h has struct utmpx)
164 AC_CACHE_CHECK(for host in utmpx struct, struct_utmpx_host,
165 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
166 #include <utmpx.h>]], [[struct utmpx utx; utx.ut_host;]])],[struct_utmpx_host=yes],[struct_utmpx_host=no])])
167 if test x$struct_utmpx_host = xyes; then
168 AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)
171 AC_CACHE_CHECK(for session in utmpx struct, struct_utmpx_session,
172 [AC_TRY_COMPILE([#include <sys/types.h>
174 [struct utmpx utx; utx.ut_session;],
175 struct_utmpx_session=yes, struct_utmpx_session=no)])
176 if test x$struct_utmpx_session = xyes; then
177 AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)
179 ) dnl# AC_CHECK_HEADER(utmpx.h
181 dnl# --------------------------------------------------------------------------
182 dnl# check for struct lastlog
183 AC_CACHE_CHECK(for struct lastlog, struct_lastlog,
184 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
186 #ifdef HAVE_LASTLOG_H
189 ]], [[struct lastlog ll;]])],[struct_lastlog=yes],[struct_lastlog=no])])
190 if test x$struct_lastlog = xyes; then
191 AC_DEFINE(HAVE_STRUCT_LASTLOG, 1, Define if utmp.h or lastlog.h has struct lastlog)
194 dnl# check for struct lastlogx
195 AC_CACHE_CHECK(for struct lastlogx, struct_lastlogx,
196 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
198 #ifdef HAVE_LASTLOG_H
201 ]], [[struct lastlogx ll;]])],[struct_lastlogx=yes],[struct_lastlogx=no])])
202 if test x$struct_lastlogx = xyes; then
203 AC_DEFINE(HAVE_STRUCT_LASTLOGX, 1, Define if utmpx.h or lastlog.h has struct lastlogx)
206 dnl# --------------------------------------------------------------------------
208 dnl# --------------------------------------------------------------------------
211 AC_CACHE_CHECK(where utmp is located, path_utmp,
212 [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>
249 #include <sys/types.h>
252 #include <sys/stat.h>
258 char **u, *p, *utmplist[] = {
265 "/var/adm/utmpx", "/etc/utmpx", NULL };
266 FILE *a, *f=fopen("conftestval", "w");
267 struct stat statu, statux;
269 for (u = utmplist; *u; u++) {
270 if ((a = fopen(*u, "r")) != NULL || errno == EACCES) {
271 if (stat(*u, &statux) < 0)
274 p[strlen(p) - 1] = '\0';
275 if (stat(p, &statu) >= 0
276 && (statu.st_mtime - statux.st_mtime > 86400))
278 fprintf(f, "%s\n", *u);
283 }]])],[path_utmpx=`cat conftestval`],[path_utmpx=],[dnl
284 AC_MSG_WARN(Define UTMPX_FILE in config.h manually)])])
285 if test x$path_utmpx != x; then
286 AC_DEFINE_UNQUOTED(UTMPX_FILE, "$path_utmpx", Define location of utmpx)
289 dnl# --------------------------------------------------------------------------
292 AC_CACHE_CHECK(where wtmp is located, path_wtmp,
293 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
294 #include <sys/types.h>
301 char **w, *wtmplist[] = {
302 "/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp", NULL };
303 FILE *a, *f=fopen("conftestval", "w");
306 fprintf(f, "%s\n", WTMP_FILE);
310 fprintf(f, "%s\n", _PATH_WTMP);
313 for (w = wtmplist; *w; w++) {
314 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
315 fprintf(f, "%s\n", *w);
320 }]])],[path_wtmp=`cat conftestval`],[path_wtmp=],[dnl
321 AC_MSG_WARN(Define WTMP_FILE in config.h manually)])])
322 if test x$path_wtmp != x; then
323 AC_DEFINE_UNQUOTED(WTMP_FILE, "$path_wtmp", Define location of wtmp)
325 dnl# --------------------------------------------------------------------------
328 AC_CACHE_CHECK(where wtmpx is located, path_wtmpx,
329 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
336 char **w, *wtmplist[] = {
337 "/var/log/wtmpx", "/var/adm/wtmpx", NULL };
338 FILE *a, *f=fopen("conftestval", "w");
341 fprintf(f, "%s\n", WTMPX_FILE);
345 fprintf(f, "%s\n", _PATH_WTMPX);
348 for (w = wtmplist; *w; w++) {
349 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
350 fprintf(f, "%s\n", *w);
355 }]])],[path_wtmpx=`cat conftestval`],[path_wtmpx=],[dnl
356 AC_MSG_WARN(Define WTMPX_FILE in config.h manually)])])
357 if test x$path_wtmpx != x; then
358 AC_DEFINE_UNQUOTED(WTMPX_FILE, "$path_wtmpx", Define location of wtmpx)
360 dnl# --------------------------------------------------------------------------
363 AC_CACHE_CHECK(where lastlog is located, path_lastlog,
364 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
365 #include <sys/types.h>
368 #elif defined(HAVE_UTMP_H)
371 #ifdef HAVE_LASTLOG_H
377 char **w, *lastloglist[] = { "/var/log/lastlog", NULL };
378 FILE *a, *f=fopen("conftestval", "w");
381 fprintf(f, "%s\n", LASTLOG_FILE);
385 fprintf(f, "%s\n", _PATH_LASTLOG);
388 for (w = lastloglist; *w; w++) {
389 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
390 fprintf(f, "%s\n", *w);
395 }]])],[path_lastlog=`cat conftestval`],[path_lastlog=],[dnl
396 AC_MSG_WARN(Define LASTLOG_FILE in config.h manually)])])
397 if test x$path_lastlog != x; then
398 AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$path_lastlog", Define location of lastlog)
399 if test -d "$path_lastlog"; then
400 AC_DEFINE(LASTLOG_IS_DIR, 1, Define if lastlog is provided via a directory)
403 dnl# --------------------------------------------------------------------------
406 AC_CACHE_CHECK(where lastlogx is located, path_lastlogx,
407 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
414 char **w, *wtmplist[] = { "/var/log/lastlogx", "/var/adm/lastlogx", NULL };
415 FILE *a, *f=fopen("conftestval", "w");
418 fprintf(f, "%s\n", LASTLOGX_FILE);
421 #ifdef _PATH_LASTLOGX
422 fprintf(f, "%s\n", _PATH_LASTLOGX);
425 for (w = wtmplist; *w; w++) {
426 if ((a = fopen(*w, "r")) != NULL || errno == EACCES) {
427 fprintf(f, "%s\n", *w);
432 }]])],[path_lastlogx=`cat conftestval`],[path_lastlogx=],[dnl
433 AC_MSG_WARN(Define LASTLOGX_FILE in config.h manually)])])
434 if test x$path_lastlogx != x; then
435 AC_DEFINE_UNQUOTED(LASTLOGX_FILE, "$path_lastlogx", Define location of lastlogx)
438 if test x$support_utmp != xyes; then
439 echo " utmp support: disabled"
442 echo " utmp support: enabled
443 utmp file: $path_utmp
444 utmpx file: $path_utmpx
445 wtmp file: $path_wtmp
446 wtmpx file: $path_wtmpx
447 lastlog file: $path_lastlog
448 lastlogx file: $path_lastlogx"
452 AC_DEFUN([SCM_RIGHTS_CHECK],
454 AC_CACHE_CHECK(for unix-compliant filehandle passing ability, can_pass_fds,
456 #include <cstddef> // broken bsds (is that redundant?) need this
457 #include <sys/types.h>
458 #include <sys/socket.h>
467 iov.iov_base = &data;
472 msg.msg_control = buf;
473 msg.msg_controllen = sizeof buf;
475 cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
476 cmsg->cmsg_level = SOL_SOCKET;
477 cmsg->cmsg_type = SCM_RIGHTS;
478 cmsg->cmsg_len = 100;
480 *(int *)CMSG_DATA (cmsg) = 5;
482 return sendmsg (3, &msg, 0);
484 ],[can_pass_fds=yes],[can_pass_fds=no])])
485 if test x$can_pass_fds = xyes; then
486 AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing)
488 AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability])
492 AC_DEFUN([TTY_GROUP_CHECK],
494 AC_CACHE_CHECK([for tty group], tty_group,
496 #include <sys/types.h>
497 #include <sys/stat.h>
506 gr = getgrnam("tty");
510 && (stat(tty, &st)) == 0
511 && st.st_gid == gr->gr_gid)
516 [tty_group=yes],[tty_group=no],[tty_group=no])])
517 if test x$tty_group = xyes; then
518 AC_DEFINE(TTY_GID_SUPPORT, 1, "")