| 1 |
# pty_h.m4 |
| 2 |
# serial 15 |
| 3 |
dnl Copyright (C) 2009-2026 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. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
# gl_PTY_H |
| 10 |
# -------- |
| 11 |
# Set up the GNU-like <pty.h> replacement header. |
| 12 |
AC_DEFUN_ONCE([gl_PTY_H], |
| 13 |
[ |
| 14 |
AC_REQUIRE([gl_PTY_H_DEFAULTS]) |
| 15 |
|
| 16 |
# 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 |
| 19 |
HAVE_PTY_H=0 |
| 20 |
gl_PTY_CHECK_UTIL_H |
| 21 |
AC_CHECK_HEADERS_ONCE([termios.h]) |
| 22 |
else # Have <pty.h>, assume forkpty is declared there. |
| 23 |
HAVE_PTY_H=1 |
| 24 |
fi |
| 25 |
AC_SUBST([HAVE_PTY_H]) |
| 26 |
dnl <pty.h> is always overridden, because of GNULIB_POSIXCHECK. |
| 27 |
gl_CHECK_NEXT_HEADERS([pty.h]) |
| 28 |
|
| 29 |
dnl Check for declarations of anything we want to poison if the |
| 30 |
dnl corresponding gnulib module is not in use. |
| 31 |
gl_WARN_ON_USE_PREPARE([[ |
| 32 |
/* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0. */ |
| 33 |
#include <sys/types.h> |
| 34 |
#if HAVE_PTY_H |
| 35 |
# include <pty.h> |
| 36 |
#endif |
| 37 |
#if HAVE_UTIL_H |
| 38 |
# include <util.h> |
| 39 |
#endif |
| 40 |
#if HAVE_LIBUTIL_H |
| 41 |
# include <libutil.h> |
| 42 |
#endif |
| 43 |
#if HAVE_TERMIOS_H |
| 44 |
# include <termios.h> |
| 45 |
#endif |
| 46 |
]], [forkpty openpty]) |
| 47 |
]) |
| 48 |
|
| 49 |
dnl Test for <util.h> and <libutil.h>. |
| 50 |
AC_DEFUN([gl_PTY_CHECK_UTIL_H], |
| 51 |
[ |
| 52 |
AC_REQUIRE([gl_PTY_H_DEFAULTS]) |
| 53 |
AC_CHECK_HEADERS([util.h libutil.h]) |
| 54 |
if test $ac_cv_header_util_h = yes; then |
| 55 |
HAVE_UTIL_H=1 |
| 56 |
fi |
| 57 |
if test $ac_cv_header_libutil_h = yes; then |
| 58 |
HAVE_LIBUTIL_H=1 |
| 59 |
fi |
| 60 |
]) |
| 61 |
|
| 62 |
# gl_PTY_MODULE_INDICATOR([modulename]) |
| 63 |
# sets the shell variable that indicates the presence of the given module |
| 64 |
# to a C preprocessor expression that will evaluate to 1. |
| 65 |
# This macro invocation must not occur in macros that are AC_REQUIREd. |
| 66 |
AC_DEFUN([gl_PTY_MODULE_INDICATOR], |
| 67 |
[ |
| 68 |
dnl Ensure to expand the default settings once only. |
| 69 |
gl_PTY_H_REQUIRE_DEFAULTS |
| 70 |
gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
| 71 |
dnl Define it also as a C macro, for the benefit of the unit tests. |
| 72 |
gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
| 73 |
]) |
| 74 |
|
| 75 |
# Initializes the default values for AC_SUBSTed shell variables. |
| 76 |
# This macro must not be AC_REQUIREd. It must only be invoked, and only |
| 77 |
# outside of macros or in macros that are not AC_REQUIREd. |
| 78 |
AC_DEFUN([gl_PTY_H_REQUIRE_DEFAULTS], |
| 79 |
[ |
| 80 |
m4_defun(GL_MODULE_INDICATOR_PREFIX[_PTY_H_MODULE_INDICATOR_DEFAULTS], [ |
| 81 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FORKPTY]) |
| 82 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENPTY]) |
| 83 |
]) |
| 84 |
m4_require(GL_MODULE_INDICATOR_PREFIX[_PTY_H_MODULE_INDICATOR_DEFAULTS]) |
| 85 |
AC_REQUIRE([gl_PTY_H_DEFAULTS]) |
| 86 |
]) |
| 87 |
|
| 88 |
AC_DEFUN([gl_PTY_H_DEFAULTS], |
| 89 |
[ |
| 90 |
dnl Assume proper GNU behavior unless another module says otherwise. |
| 91 |
HAVE_UTIL_H=0; AC_SUBST([HAVE_UTIL_H]) |
| 92 |
HAVE_LIBUTIL_H=0; AC_SUBST([HAVE_LIBUTIL_H]) |
| 93 |
HAVE_FORKPTY=1; AC_SUBST([HAVE_FORKPTY]) |
| 94 |
HAVE_OPENPTY=1; AC_SUBST([HAVE_OPENPTY]) |
| 95 |
REPLACE_FORKPTY=0; AC_SUBST([REPLACE_FORKPTY]) |
| 96 |
REPLACE_OPENPTY=0; AC_SUBST([REPLACE_OPENPTY]) |
| 97 |
]) |