| 1 |
# sys_ioctl_h.m4 |
| 2 |
# serial 15 |
| 3 |
dnl Copyright (C) 2008-2024 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 |
dnl Written by Bruno Haible. |
| 10 |
|
| 11 |
AC_DEFUN_ONCE([gl_SYS_IOCTL_H], |
| 12 |
[ |
| 13 |
dnl Ensure to expand the default settings once only, before all statements |
| 14 |
dnl that occur in other macros. |
| 15 |
AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS]) |
| 16 |
|
| 17 |
AC_CHECK_HEADERS_ONCE([sys/ioctl.h]) |
| 18 |
if test $ac_cv_header_sys_ioctl_h = yes; then |
| 19 |
HAVE_SYS_IOCTL_H=1 |
| 20 |
dnl Test whether <sys/ioctl.h> declares ioctl(), or whether some other |
| 21 |
dnl header file, such as <unistd.h> or <stropts.h>, is needed for that. |
| 22 |
AC_CACHE_CHECK([whether <sys/ioctl.h> declares ioctl], |
| 23 |
[gl_cv_decl_ioctl_in_sys_ioctl_h], |
| 24 |
[dnl We cannot use AC_CHECK_DECL because it produces its own messages. |
| 25 |
AC_COMPILE_IFELSE( |
| 26 |
[AC_LANG_PROGRAM( |
| 27 |
[[#include <sys/ioctl.h>]], |
| 28 |
[[(void) ioctl;]])], |
| 29 |
[gl_cv_decl_ioctl_in_sys_ioctl_h=yes], |
| 30 |
[gl_cv_decl_ioctl_in_sys_ioctl_h=no]) |
| 31 |
]) |
| 32 |
else |
| 33 |
HAVE_SYS_IOCTL_H=0 |
| 34 |
fi |
| 35 |
AC_SUBST([HAVE_SYS_IOCTL_H]) |
| 36 |
dnl <sys/ioctl.h> is always overridden, because of GNULIB_POSIXCHECK. |
| 37 |
gl_CHECK_NEXT_HEADERS([sys/ioctl.h]) |
| 38 |
|
| 39 |
dnl Check for declarations of anything we want to poison if the |
| 40 |
dnl corresponding gnulib module is not in use. |
| 41 |
gl_WARN_ON_USE_PREPARE([[#include <sys/ioctl.h> |
| 42 |
/* Some platforms declare ioctl in the wrong header. */ |
| 43 |
#if !(defined __GLIBC__ && !defined __UCLIBC__) |
| 44 |
# include <unistd.h> |
| 45 |
#endif |
| 46 |
]], [ioctl]) |
| 47 |
]) |
| 48 |
|
| 49 |
# gl_SYS_IOCTL_MODULE_INDICATOR([modulename]) |
| 50 |
# sets the shell variable that indicates the presence of the given module |
| 51 |
# to a C preprocessor expression that will evaluate to 1. |
| 52 |
# This macro invocation must not occur in macros that are AC_REQUIREd. |
| 53 |
AC_DEFUN([gl_SYS_IOCTL_MODULE_INDICATOR], |
| 54 |
[ |
| 55 |
dnl Ensure to expand the default settings once only. |
| 56 |
gl_SYS_IOCTL_H_REQUIRE_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]) |
| 60 |
]) |
| 61 |
|
| 62 |
# Initializes the default values for AC_SUBSTed shell variables. |
| 63 |
# This macro must not be AC_REQUIREd. It must only be invoked, and only |
| 64 |
# outside of macros or in macros that are not AC_REQUIREd. |
| 65 |
AC_DEFUN([gl_SYS_IOCTL_H_REQUIRE_DEFAULTS], |
| 66 |
[ |
| 67 |
m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_IOCTL_H_MODULE_INDICATOR_DEFAULTS], [ |
| 68 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_IOCTL]) |
| 69 |
]) |
| 70 |
m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_IOCTL_H_MODULE_INDICATOR_DEFAULTS]) |
| 71 |
AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS]) |
| 72 |
]) |
| 73 |
|
| 74 |
AC_DEFUN([gl_SYS_IOCTL_H_DEFAULTS], |
| 75 |
[ |
| 76 |
dnl Assume proper GNU behavior unless another module says otherwise. |
| 77 |
SYS_IOCTL_H_HAVE_WINSOCK2_H=0; AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H]) |
| 78 |
SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0; |
| 79 |
AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS]) |
| 80 |
REPLACE_IOCTL=0; AC_SUBST([REPLACE_IOCTL]) |
| 81 |
]) |