3 dnl Copyright (C) 2010-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
10 # Define automake variable PTY_LIB to the library needed (if any).
11 AC_DEFUN([gl_PTY_LIB],
13 AC_REQUIRE([AC_CANONICAL_HOST])
14 # Check for the library required for forkpty.
17 haiku*) PTY_LIB='-lbsd' ;;
20 AC_SEARCH_LIBS([forkpty], [util],
21 [if test "$ac_cv_search_forkpty" != "none required"; then
22 PTY_LIB="$ac_cv_search_forkpty"
31 AC_DEFUN([gl_FUNC_FORKPTY],
33 AC_REQUIRE([gl_PTY_LIB])
34 AC_REQUIRE([gl_PTY_H])
36 dnl We assume that forkpty exists (possibly in libc, possibly in libutil or
37 dnl libbsd) if and only if it is declared.
38 AC_CHECK_DECLS([forkpty],,, [[
39 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
40 #include <sys/types.h>
54 if test $ac_cv_have_decl_forkpty = yes; then
55 dnl The system has forkpty.
56 dnl Prefer glibc's const-safe prototype, if available.
57 AC_CACHE_CHECK([for const-safe forkpty signature],
58 [gl_cv_func_forkpty_const],
61 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
62 #include <sys/types.h>
76 int forkpty (int *, char *, struct termios const *,
77 struct winsize const *);
80 [gl_cv_func_forkpty_const=yes], [gl_cv_func_forkpty_const=no])
82 if test $gl_cv_func_forkpty_const != yes; then
86 dnl The system does not have forkpty.
89 AC_DEFINE_UNQUOTED([HAVE_FORKPTY], [$HAVE_FORKPTY],
90 [Define to 1 if the system has the 'forkpty' function.])
93 AC_DEFUN([gl_FUNC_OPENPTY],
95 AC_REQUIRE([gl_PTY_LIB])
96 AC_REQUIRE([gl_PTY_H])
98 dnl Persuade Solaris <stdlib.h> to declare posix_openpt().
99 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
101 dnl We assume that openpty exists (possibly in libc, possibly in libutil or
102 dnl libbsd) if and only if it is declared.
103 AC_CHECK_DECLS([openpty],,, [[
104 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
105 #include <sys/types.h>
113 # include <libutil.h>
116 # include <termios.h>
119 if test $ac_cv_have_decl_openpty = yes; then
120 AC_DEFINE([HAVE_OPENPTY], [1],
121 [Define to 1 if the system has the 'openpty' function.])
122 dnl The system has openpty.
123 dnl Prefer glibc's const-safe prototype, if available.
124 AC_CACHE_CHECK([for const-safe openpty signature],
125 [gl_cv_func_openpty_const],
128 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */
129 #include <sys/types.h>
137 # include <libutil.h>
140 # include <termios.h>
143 int openpty (int *, int *, char *, struct termios const *,
144 struct winsize const *);
147 [gl_cv_func_openpty_const=yes], [gl_cv_func_openpty_const=no])
149 if test $gl_cv_func_openpty_const != yes; then
153 dnl The system does not have openpty.
155 dnl Prerequisites of lib/openpty.c in this case.
156 AC_CHECK_FUNCS([_getpty])
157 gl_CHECK_FUNCS_ANDROID([posix_openpt], [[#include <stdlib.h>]])