immutable: Add tests.
[gnulib.git] / m4 / pty_h.m4
blob5fa13630bbbd994e3f9a3812e3ee25edb738d000
1 # pty_h.m4 serial 11
2 dnl Copyright (C) 2009-2021 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.
7 # gl_PTY_H
8 # --------
9 # Set up the GNU-like <pty.h> replacement header.
10 AC_DEFUN_ONCE([gl_PTY_H],
12   AC_REQUIRE([gl_PTY_H_DEFAULTS])
14   # Make sure that pty.h provides forkpty, or setup the replacement.
15   AC_CHECK_HEADERS_ONCE([pty.h])
16   if test $ac_cv_header_pty_h != yes; then
17     HAVE_PTY_H=0
18     AC_CHECK_HEADERS([util.h libutil.h])
19     if test $ac_cv_header_util_h = yes; then
20       HAVE_UTIL_H=1
21     fi
22     if test $ac_cv_header_libutil_h = yes; then
23       HAVE_LIBUTIL_H=1
24     fi
25     AC_CHECK_HEADERS_ONCE([termios.h])
26   else # Have <pty.h>, assume forkpty is declared there.
27     HAVE_PTY_H=1
28   fi
29   AC_SUBST([HAVE_PTY_H])
30   dnl <pty.h> is always overridden, because of GNULIB_POSIXCHECK.
31   gl_CHECK_NEXT_HEADERS([pty.h])
33   dnl Check for declarations of anything we want to poison if the
34   dnl corresponding gnulib module is not in use.
35   gl_WARN_ON_USE_PREPARE([[
36 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0.  */
37 #include <sys/types.h>
38 #if HAVE_PTY_H
39 # include <pty.h>
40 #endif
41 #if HAVE_UTIL_H
42 # include <util.h>
43 #endif
44 #if HAVE_LIBUTIL_H
45 # include <libutil.h>
46 #endif
47 #if HAVE_TERMIOS_H
48 # include <termios.h>
49 #endif
50     ]], [forkpty openpty])
53 AC_DEFUN([gl_PTY_MODULE_INDICATOR],
55   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
56   AC_REQUIRE([gl_PTY_H_DEFAULTS])
57   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
58   dnl Define it also as a C macro, for the benefit of the unit tests.
59   gl_MODULE_INDICATOR_FOR_TESTS([$1])
62 AC_DEFUN([gl_PTY_H_DEFAULTS],
64   GNULIB_FORKPTY=0;     AC_SUBST([GNULIB_FORKPTY])
65   GNULIB_OPENPTY=0;     AC_SUBST([GNULIB_OPENPTY])
66   dnl Assume proper GNU behavior unless another module says otherwise.
67   HAVE_UTIL_H=0;        AC_SUBST([HAVE_UTIL_H])
68   HAVE_LIBUTIL_H=0;     AC_SUBST([HAVE_LIBUTIL_H])
69   HAVE_FORKPTY=1;       AC_SUBST([HAVE_FORKPTY])
70   HAVE_OPENPTY=1;       AC_SUBST([HAVE_OPENPTY])
71   REPLACE_FORKPTY=0;    AC_SUBST([REPLACE_FORKPTY])
72   REPLACE_OPENPTY=0;    AC_SUBST([REPLACE_OPENPTY])