maint: update copyright
[gnulib.git] / m4 / pty_h.m4
1 # pty_h.m4 serial 10
2 dnl Copyright (C) 2009-2014 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.
6
7 # gl_PTY_H
8 # --------
9 # Set up the GNU-like <pty.h> replacement header.
10 AC_DEFUN_ONCE([gl_PTY_H],
11 [
12   AC_REQUIRE([gl_PTY_H_DEFAULTS])
13
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   else # Have <pty.h>, assume forkpty is declared there.
26     HAVE_PTY_H=1
27   fi
28   AC_SUBST([HAVE_PTY_H])
29   dnl <pty.h> is always overridden, because of GNULIB_POSIXCHECK.
30   gl_CHECK_NEXT_HEADERS([pty.h])
31
32   dnl Check for declarations of anything we want to poison if the
33   dnl corresponding gnulib module is not in use.
34   gl_WARN_ON_USE_PREPARE([[
35 /* <sys/types.h> is a prerequisite of <libutil.h> on FreeBSD 8.0.  */
36 #include <sys/types.h>
37 #if HAVE_PTY_H
38 # include <pty.h>
39 #endif
40 #if HAVE_UTIL_H
41 # include <util.h>
42 #endif
43 #if HAVE_LIBUTIL_H
44 # include <libutil.h>
45 #endif
46     ]], [forkpty openpty])
47 ])
48
49 AC_DEFUN([gl_PTY_MODULE_INDICATOR],
50 [
51   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
52   AC_REQUIRE([gl_PTY_H_DEFAULTS])
53   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
54   dnl Define it also as a C macro, for the benefit of the unit tests.
55   gl_MODULE_INDICATOR_FOR_TESTS([$1])
56 ])
57
58 AC_DEFUN([gl_PTY_H_DEFAULTS],
59 [
60   GNULIB_FORKPTY=0;     AC_SUBST([GNULIB_FORKPTY])
61   GNULIB_OPENPTY=0;     AC_SUBST([GNULIB_OPENPTY])
62   dnl Assume proper GNU behavior unless another module says otherwise.
63   HAVE_UTIL_H=0;        AC_SUBST([HAVE_UTIL_H])
64   HAVE_LIBUTIL_H=0;     AC_SUBST([HAVE_LIBUTIL_H])
65   HAVE_FORKPTY=1;       AC_SUBST([HAVE_FORKPTY])
66   HAVE_OPENPTY=1;       AC_SUBST([HAVE_OPENPTY])
67   REPLACE_FORKPTY=0;    AC_SUBST([REPLACE_FORKPTY])
68   REPLACE_OPENPTY=0;    AC_SUBST([REPLACE_OPENPTY])
69 ])