2 dnl Copyright (C) 2009, 2010 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 # Make sure that pty.h provides forkpty, or sets up a replacement header.
10 # Also define automake variable PTY_LIB to the library needed (if any).
11 AC_DEFUN_ONCE([gl_PTY],
13 AC_REQUIRE([gl_PTY_H_DEFAULTS])
16 # First make sure that pty.h provides forkpty, or setup the replacement.
17 AC_CHECK_HEADERS_ONCE([pty.h])
18 if test $ac_cv_header_pty_h != yes; then
20 AC_CHECK_HEADERS([util.h libutil.h])
21 if test $ac_cv_header_util_h = yes; then
24 if test $ac_cv_header_libutil_h = yes; then
27 AC_CHECK_DECLS([forkpty],,, [[
35 if test $ac_cv_have_decl_forkpty = no; then
36 AC_MSG_WARN([[Cannot find forkpty, build will likely fail]])
38 else # Have <pty.h>, assume forkpty is declared there.
41 AC_SUBST([HAVE_PTY_H])
42 dnl <pty.h> is always overridden, because of GNULIB_POSIXCHECK.
43 gl_CHECK_NEXT_HEADERS([pty.h])
45 # Second check for the library required for forkpty.
47 AC_SEARCH_LIBS([forkpty], [util],
48 [if test "$ac_cv_search_forkpty" != "none required"; then
49 PTY_LIB="$ac_cv_search_forkpty"
54 dnl Check for declarations of anything we want to poison if the
55 dnl corresponding gnulib module is not in use.
56 gl_WARN_ON_USE_PREPARE([[
66 ]], [forkpty openpty])
69 AC_DEFUN([gl_PTY_MODULE_INDICATOR],
71 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
72 AC_REQUIRE([gl_PTY_H_DEFAULTS])
73 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
76 AC_DEFUN([gl_PTY_H_DEFAULTS],
78 dnl Assume proper GNU behavior unless another module says otherwise.
79 HAVE_UTIL_H=0; AC_SUBST([HAVE_UTIL_H])
80 HAVE_LIBUTIL_H=0; AC_SUBST([HAVE_LIBUTIL_H])