2 dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
9 # Define automake variable PTY_LIB to the library needed (if any).
10 AC_DEFUN([gl_PTY_LIB],
12 # Check for the library required for forkpty.
15 AC_SEARCH_LIBS([forkpty], [util],
16 [if test "$ac_cv_search_forkpty" != "none required"; then
17 PTY_LIB="$ac_cv_search_forkpty"
23 AC_DEFUN([gl_FUNC_FORKPTY],
25 AC_REQUIRE([gl_PTY_LIB])
26 AC_REQUIRE([gl_PTY_H])
28 dnl We assume that forkpty exists (possibly in libc, possibly in libutil)
29 dnl if and only if it is declared.
30 AC_CHECK_DECLS([forkpty],,, [[
31 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
32 #include <sys/types.h>
43 if test $ac_cv_have_decl_forkpty = yes; then
44 dnl The system has forkpty.
45 dnl Prefer glibc's const-safe prototype, if available.
46 AC_CACHE_CHECK([for const-safe forkpty signature],
47 [gl_cv_func_forkpty_const],
50 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
51 #include <sys/types.h>
62 int forkpty (int *, char *, struct termios const *,
63 struct winsize const *);
66 [gl_cv_func_forkpty_const=yes], [gl_cv_func_forkpty_const=no])
68 if test $gl_cv_func_forkpty_const != yes; then
73 dnl The system does not have forkpty.
79 AC_DEFUN([gl_FUNC_OPENPTY],
81 AC_REQUIRE([gl_PTY_LIB])
82 AC_REQUIRE([gl_PTY_H])
84 dnl Persuade Solaris <stdlib.h> to declare posix_openpt().
85 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
87 dnl We assume that openpty exists (possibly in libc, possibly in libutil)
88 dnl if and only if it is declared.
89 AC_CHECK_DECLS([openpty],,, [[
90 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
91 #include <sys/types.h>
102 if test $ac_cv_have_decl_openpty = yes; then
103 dnl The system has openpty.
104 dnl Prefer glibc's const-safe prototype, if available.
105 AC_CACHE_CHECK([for const-safe openpty signature],
106 [gl_cv_func_openpty_const],
109 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
110 #include <sys/types.h>
118 # include <libutil.h>
121 int openpty (int *, int *, char *, struct termios const *,
122 struct winsize const *);
125 [gl_cv_func_openpty_const=yes], [gl_cv_func_openpty_const=no])
127 if test $gl_cv_func_openpty_const != yes; then
130 AC_DEFINE([HAVE_OPENPTY], [1],
131 [Define to 1 if the system has the 'openpty' function.])
134 dnl The system does not have openpty.
137 AC_CHECK_FUNCS([_getpty posix_openpt])
141 AC_DEFUN([gl_FUNC_LOGIN_TTY],
143 AC_REQUIRE([gl_PTY_LIB])
145 gl_saved_libs="$LIBS"
146 LIBS="$LIBS $PTY_LIB"
147 AC_CHECK_FUNCS([login_tty])
148 LIBS="$gl_saved_LIBS"
149 if test $ac_cv_func_login_tty = no; then
150 AC_LIBOBJ([login_tty])