aboutsummaryrefslogtreecommitdiffhomepage
path: root/configure.ac
diff options
context:
space:
mode:
authorGravatar Quentin Smith <quentin@mit.edu>2012-04-20 04:59:09 -0400
committerGravatar Quentin Smith <quentin@mit.edu>2012-04-20 05:02:33 -0400
commitdd49b986ed3612910ae75d10cf78411bef361b2d (patch)
tree8ed4bcfdc5c40defeb3a9c6103b069e11df55c3a /configure.ac
parent8de74afb5f1e8c4f0147ddd2d04f701f95fb3a7d (diff)
Pull in third-party poll emulator and automatically link it in if we detect the system's poll is broken
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac61
1 files changed, 58 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 0c07a7b..246eeaa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,9 +242,63 @@ PKG_CHECK_MODULES([TINFO], [tinfo], ,
AC_ARG_VAR([poll_CFLAGS], [C compiler flags for poll])
AC_ARG_VAR([poll_LIBS], [linker flags for poll])
-if test -z "$poll_LIBS"; then
- AC_CHECK_LIB([poll], [poll], [poll_LIBS="-lpoll"])
-fi
+AS_IF([test -z "$poll_LIBS"], [
+ AC_CHECK_LIB([poll], [poll], [poll_LIBS="-lpoll"])
+])
+
+# Check to make sure poll() can handle stdin and ptys
+AC_CACHE_CHECK([whether poll can handle ptys],
+ [ac_cv_poll_pty],
+[
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+
+ AS_IF([test "x$poll_CFLAGS" != "x"],
+ [CFLAGS="$CFLAGS $poll_CFLAGS"])
+
+ AS_IF([test "x$poll_LIBS" != "x"],
+ [LIBS="$LIBS $poll_LIBS"])
+
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#if HAVE_PTY_H
+#include <pty.h>
+#elif HAVE_UTIL_H
+#include <util.h>
+#endif
+#include <sys/poll.h>
+
+int master, slave;
+struct pollfd pollfds[ 1 ];
+]], [[
+if ( openpty( &master, &slave, NULL, NULL, NULL ) < 0 ) {
+ perror( "openpty" );
+ exit( 1 );
+}
+pollfds[ 0 ].fd = master;
+pollfds[ 0 ].events = POLLIN;
+int active_fds = poll( pollfds, 1, 100 );
+if ( active_fds < 0 ) {
+ perror( "poll" );
+ exit( 1 );
+}
+if ( pollfds[ 0 ].revents & (POLLERR | POLLHUP | POLLNVAL) ) {
+ exit( 2 );
+}
+]])],
+ [ac_cv_poll_pty=yes],
+ [ac_cv_poll_pty=no])
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+])
+AM_CONDITIONAL([COND_THIRD_POLL], [test "x$ac_cv_poll_pty" = "xno"])
+AM_COND_IF([COND_THIRD_POLL],
+ [
+ poll_CFLAGS="-I\$(top_srcdir)/third/poll"
+ poll_LIBS="\$(top_builddir)/third/poll/libpoll.a"
+ ])
AC_MSG_CHECKING([whether pipe2(..., O_CLOEXEC) is supported])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define _GNU_SOURCE
@@ -306,6 +360,7 @@ AC_CONFIG_FILES([
Makefile
third/Makefile
third/libstddjb/Makefile
+ third/poll/Makefile
src/Makefile
src/crypto/Makefile
src/frontend/Makefile