| 1 |
# termios_h.m4 |
| 2 |
# serial 8 |
| 3 |
dnl Copyright (C) 2010-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 |
AC_DEFUN_ONCE([gl_TERMIOS_H], |
| 10 |
[ |
| 11 |
dnl Ensure to expand the default settings once only, before all statements |
| 12 |
dnl that occur in other macros. |
| 13 |
AC_REQUIRE([gl_TERMIOS_H_DEFAULTS]) |
| 14 |
|
| 15 |
gl_CHECK_NEXT_HEADERS([termios.h]) |
| 16 |
if test $ac_cv_header_termios_h != yes; then |
| 17 |
HAVE_TERMIOS_H=0 |
| 18 |
fi |
| 19 |
|
| 20 |
if test $ac_cv_header_termios_h = yes; then |
| 21 |
AC_CACHE_CHECK([for struct winsize in <termios.h>], |
| 22 |
[gl_cv_struct_winsize_in_termios_h], |
| 23 |
[AC_COMPILE_IFELSE( |
| 24 |
[AC_LANG_PROGRAM( |
| 25 |
[[#include <termios.h> |
| 26 |
]], |
| 27 |
[[static struct winsize x; x.ws_row = x.ws_col;]])], |
| 28 |
[gl_cv_struct_winsize_in_termios_h=yes], |
| 29 |
[gl_cv_struct_winsize_in_termios_h=no]) |
| 30 |
]) |
| 31 |
if test $gl_cv_struct_winsize_in_termios_h = no; then |
| 32 |
AC_CHECK_HEADERS_ONCE([sys/ioctl.h]) |
| 33 |
if test $ac_cv_header_sys_ioctl_h = yes; then |
| 34 |
AC_CACHE_CHECK([for struct winsize in <sys/ioctl.h>], |
| 35 |
[gl_cv_struct_winsize_in_sys_ioctl_h], |
| 36 |
[AC_COMPILE_IFELSE( |
| 37 |
[AC_LANG_PROGRAM( |
| 38 |
[[#include <sys/ioctl.h> |
| 39 |
]], |
| 40 |
[[static struct winsize x; x.ws_row = x.ws_col;]])], |
| 41 |
[gl_cv_struct_winsize_in_sys_ioctl_h=yes], |
| 42 |
[gl_cv_struct_winsize_in_sys_ioctl_h=no]) |
| 43 |
]) |
| 44 |
fi |
| 45 |
fi |
| 46 |
fi |
| 47 |
|
| 48 |
TERMIOS_H_DEFINES_STRUCT_WINSIZE=0 |
| 49 |
SYS_IOCTL_H_DEFINES_STRUCT_WINSIZE=0 |
| 50 |
if test "$gl_cv_struct_winsize_in_termios_h" != yes \ |
| 51 |
|| test "$gl_cv_struct_winsize_in_sys_ioctl_h" != yes; then |
| 52 |
if test "$gl_cv_struct_winsize_in_termios_h" = yes; then |
| 53 |
TERMIOS_H_DEFINES_STRUCT_WINSIZE=1 |
| 54 |
elif test "$gl_cv_struct_winsize_in_sys_ioctl_h" = yes; then |
| 55 |
SYS_IOCTL_H_DEFINES_STRUCT_WINSIZE=1 |
| 56 |
fi |
| 57 |
fi |
| 58 |
|
| 59 |
dnl Ensure the type pid_t gets defined. |
| 60 |
AC_REQUIRE([AC_TYPE_PID_T]) |
| 61 |
|
| 62 |
dnl Check for declarations of anything we want to poison if the |
| 63 |
dnl corresponding gnulib module is not in use, and which is not |
| 64 |
dnl guaranteed by C89. |
| 65 |
gl_WARN_ON_USE_PREPARE([[#include <termios.h>]], |
| 66 |
[tcgetsid]) |
| 67 |
|
| 68 |
AC_SUBST([TERMIOS_H_DEFINES_STRUCT_WINSIZE]) |
| 69 |
AC_SUBST([SYS_IOCTL_H_DEFINES_STRUCT_WINSIZE]) |
| 70 |
]) |
| 71 |
|
| 72 |
# gl_TERMIOS_MODULE_INDICATOR([modulename]) |
| 73 |
# sets the shell variable that indicates the presence of the given module |
| 74 |
# to a C preprocessor expression that will evaluate to 1. |
| 75 |
# This macro invocation must not occur in macros that are AC_REQUIREd. |
| 76 |
AC_DEFUN([gl_TERMIOS_MODULE_INDICATOR], |
| 77 |
[ |
| 78 |
dnl Ensure to expand the default settings once only. |
| 79 |
gl_TERMIOS_H_REQUIRE_DEFAULTS |
| 80 |
gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
| 81 |
dnl Define it also as a C macro, for the benefit of the unit tests. |
| 82 |
gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
| 83 |
]) |
| 84 |
|
| 85 |
# Initializes the default values for AC_SUBSTed shell variables. |
| 86 |
# This macro must not be AC_REQUIREd. It must only be invoked, and only |
| 87 |
# outside of macros or in macros that are not AC_REQUIREd. |
| 88 |
AC_DEFUN([gl_TERMIOS_H_REQUIRE_DEFAULTS], |
| 89 |
[ |
| 90 |
m4_defun(GL_MODULE_INDICATOR_PREFIX[_TERMIOS_H_MODULE_INDICATOR_DEFAULTS], [ |
| 91 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TCGETSID]) |
| 92 |
]) |
| 93 |
m4_require(GL_MODULE_INDICATOR_PREFIX[_TERMIOS_H_MODULE_INDICATOR_DEFAULTS]) |
| 94 |
AC_REQUIRE([gl_TERMIOS_H_DEFAULTS]) |
| 95 |
]) |
| 96 |
|
| 97 |
AC_DEFUN([gl_TERMIOS_H_DEFAULTS], |
| 98 |
[ |
| 99 |
dnl Assume proper GNU behavior unless another module says otherwise. |
| 100 |
HAVE_DECL_TCGETSID=1; AC_SUBST([HAVE_DECL_TCGETSID]) |
| 101 |
HAVE_TERMIOS_H=1; AC_SUBST([HAVE_TERMIOS_H]) |
| 102 |
]) |