dnl this file is part of libptytty, do not make local modifications dnl http://software.schmorp.de/pkg/libptytty AC_DEFUN([PT_FIND_FILE], [AC_CACHE_CHECK(where $1 is located, pt_cv_path_$1, [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include #include #include $5 int main() { char **path, *list[] = { $4, NULL }; FILE *f = fopen("conftestval", "w"); if (!f) return 1; #ifdef $2 fprintf(f, "%s\n", $2); #elif defined($3) fprintf(f, "%s\n", $3); #else for (path = list; *path; path++) { struct stat st; if (stat(*path, &st) == 0) { fprintf(f, "%s\n", *path); break; } } #endif return fclose(f) != 0; }]])],[pt_cv_path_$1=`cat conftestval`],[pt_cv_path_$1=], [AC_MSG_WARN(Define $2 in config.h manually)])]) if test x$pt_cv_path_$1 != x; then AC_DEFINE_UNQUOTED($2, "$pt_cv_path_$1", Define location of $1) fi]) AC_DEFUN([PTY_CHECK], [ AC_CHECK_HEADERS( \ pty.h \ util.h \ libutil.h \ sys/ioctl.h \ sys/stropts.h \ stropts.h \ ) AC_CHECK_FUNCS( \ revoke \ _getpty \ getpt \ posix_openpt \ isastream \ setuid \ seteuid \ setreuid \ setresuid \ ) have_clone=no AC_MSG_CHECKING(for /dev/ptc) if test -e /dev/ptc; then AC_MSG_RESULT(yes) AC_DEFINE(CLONE_DEVICE, "/dev/ptc", [clone device filename]) have_clone=yes else AC_MSG_RESULT(no) fi case $host in *-*-cygwin*) have_clone=yes AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename]) ;; *) AC_MSG_CHECKING(for /dev/ptmx) if test -e /dev/ptmx; then AC_MSG_RESULT(yes) AC_DEFINE(HAVE_DEV_PTMX, 1, [Define to 1 if you have /dev/ptmx]) AC_DEFINE(CLONE_DEVICE, "/dev/ptmx", [clone device filename]) have_clone=yes else AC_MSG_RESULT(no) fi ;; esac if test x$ac_cv_func_getpt = xyes -o x$ac_cv_func_posix_openpt = xyes -o x$have_clone = xyes; then AC_MSG_CHECKING(for UNIX98 ptys) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[grantpt(0);unlockpt(0);ptsname(0);]])], [unix98_pty=yes AC_DEFINE(UNIX98_PTY, 1, "") AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)]) fi if test -z "$unix98_pty"; then AC_SEARCH_LIBS(openpty, util, AC_DEFINE(HAVE_OPENPTY, 1, "")) fi ]) AC_DEFUN([UTMP_CHECK], [ support_utmp=yes support_wtmp=yes support_lastlog=yes AC_ARG_ENABLE(utmp, [AS_HELP_STRING([--enable-utmp],[enable utmp (utmpx) support])], [if test x$enableval = xyes -o x$enableval = xno; then support_utmp=$enableval fi]) AC_ARG_ENABLE(wtmp, [AS_HELP_STRING([--enable-wtmp],[enable wtmp (wtmpx) support (requires --enable-utmp)])], [if test x$enableval = xyes -o x$enableval = xno; then support_wtmp=$enableval fi]) AC_ARG_ENABLE(lastlog, [AS_HELP_STRING([--enable-lastlog],[enable lastlog support (requires --enable-utmp)])], [if test x$enableval = xyes -o x$enableval = xno; then support_lastlog=$enableval fi]) if test x$support_utmp = xyes; then AC_DEFINE(UTMP_SUPPORT, 1, Define if you want to have utmp/utmpx support) fi if test x$support_wtmp = xyes; then AC_DEFINE(WTMP_SUPPORT, 1, Define if you want to have wtmp support when utmp/utmpx is enabled) fi if test x$support_lastlog = xyes; then AC_DEFINE(LASTLOG_SUPPORT, 1, Define if you want to have lastlog support when utmp/utmpx is enabled) fi AC_CHECK_FUNCS( \ updwtmp \ updwtmpx \ updlastlogx \ ) AC_CHECK_HEADERS(lastlog.h) dnl# -------------------------------------------------------------------------- dnl# DO ALL UTMP AND WTMP CHECKING dnl# -------------------------------------------------------------------------- dnl# check for host field in utmp structure dnl# -------------------------------------------- AC_CHECK_HEADERS(utmp.h, AC_CHECK_TYPES([struct utmp], [], [], [ #include #include ]) AC_CHECK_MEMBER([struct utmp.ut_host], [AC_DEFINE(HAVE_UTMP_HOST, 1, Define if struct utmp contains ut_host)], [], [ #include #include ]) AC_CHECK_MEMBER([struct utmp.ut_pid], [AC_DEFINE(HAVE_UTMP_PID, 1, Define if struct utmp contains ut_pid)], [], [ #include #include ]) ) dnl# AC_CHECK_HEADERS(utmp.h dnl# -------------------------------------------- AC_CHECK_HEADERS(utmpx.h, AC_CHECK_TYPES([struct utmpx], [], [], [ #include #include ]) AC_CHECK_MEMBER([struct utmpx.ut_host], [AC_DEFINE(HAVE_UTMPX_HOST, 1, Define if struct utmpx contains ut_host)], [], [ #include #include ]) AC_CHECK_MEMBER([struct utmpx.ut_session], [AC_DEFINE(HAVE_UTMPX_SESSION, 1, Define if struct utmpx contains ut_session)], [], [ #include #include ]) ) dnl# AC_CHECK_HEADERS(utmpx.h dnl# -------------------------------------------------------------------------- dnl# check for struct lastlog AC_CHECK_TYPES([struct lastlog], [], [], [ #include #include #ifdef HAVE_LASTLOG_H #include #endif ]) dnl# check for struct lastlogx AC_CHECK_TYPES([struct lastlogx], [], [], [ #include #include #ifdef HAVE_LASTLOG_H #include #endif ]) dnl# -------------------------------------------------------------------------- dnl# FIND FILES dnl# -------------------------------------------------------------------------- dnl# find utmp PT_FIND_FILE([utmp], [UTMP_FILE], [_PATH_UTMP], ["/var/run/utmp", "/var/adm/utmp", "/etc/utmp", "/usr/etc/utmp", "/usr/adm/utmp"],[ #include #include ]) dnl# -------------------------------------------------------------------------- dnl# find wtmp PT_FIND_FILE([wtmp], [WTMP_FILE], [_PATH_WTMP], ["/var/log/wtmp", "/var/adm/wtmp", "/etc/wtmp", "/usr/etc/wtmp", "/usr/adm/wtmp"],[ #include #ifdef HAVE_UTMP_H #include #endif ]) dnl# -------------------------------------------------------------------------- dnl# find wtmpx PT_FIND_FILE([wtmpx], [WTMPX_FILE], [_PATH_WTMPX], ["/var/log/wtmpx", "/var/adm/wtmpx"],[ #ifdef HAVE_UTMPX_H #include #endif ]) dnl# -------------------------------------------------------------------------- dnl# find lastlog PT_FIND_FILE([lastlog], [LASTLOG_FILE], [_PATH_LASTLOG], ["/var/log/lastlog"],[ #include #ifdef HAVE_UTMP_H #include #endif #ifdef HAVE_LASTLOG_H #include #endif ]) dnl# -------------------------------------------------------------------------- dnl# find lastlogx PT_FIND_FILE([lastlogx], [LASTLOGX_FILE], [_PATH_LASTLOGX], ["/var/log/lastlogx", "/var/adm/lastlogx"],[ #ifdef HAVE_UTMPX_H #include #endif ]) ]) AC_DEFUN([SCM_RIGHTS_CHECK], [ AC_CACHE_CHECK(for unix-compliant filehandle passing ability, pt_cv_can_pass_fds, [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include // broken bsds (is that redundant?) need this #include #include #include ]], [[ { msghdr msg; iovec iov; char buf [100]; char data = 0; iov.iov_base = &data; iov.iov_len = 1; msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_control = buf; msg.msg_controllen = sizeof buf; cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; cmsg->cmsg_len = 100; *(int *)CMSG_DATA (cmsg) = 5; return sendmsg (3, &msg, 0); } ]])],[pt_cv_can_pass_fds=yes],[pt_cv_can_pass_fds=no])]) if test x$pt_cv_can_pass_fds = xyes; then AC_DEFINE(HAVE_UNIX_FDPASS, 1, Define if sys/socket.h defines the necessary macros/functions for file handle passing) else AC_MSG_ERROR([libptytty requires unix-compliant filehandle passing ability]) fi ]) AC_DEFUN([TTY_GROUP_CHECK], [ AC_CACHE_CHECK([for tty group], pt_cv_tty_group, [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include #include int main() { struct stat st; struct group *gr; char *tty; gr = getgrnam("tty"); tty = ttyname(0); if (gr != 0 && tty != 0 && (stat(tty, &st)) == 0 && st.st_gid == gr->gr_gid) return 0; else return 1; }]])],[pt_cv_tty_group=yes],[pt_cv_tty_group=no],[pt_cv_tty_group=no])]) if test x$pt_cv_tty_group = xyes; then AC_DEFINE(TTY_GID_SUPPORT, 1, "") fi])