Blame m4/sys_ioctl_h.m4

Packit 33f14e
# sys_ioctl_h.m4 serial 10
Packit 33f14e
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
Packit 33f14e
dnl This file is free software; the Free Software Foundation
Packit 33f14e
dnl gives unlimited permission to copy and/or distribute it,
Packit 33f14e
dnl with or without modifications, as long as this notice is preserved.
Packit 33f14e
Packit 33f14e
dnl Written by Bruno Haible.
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_SYS_IOCTL_H],
Packit 33f14e
[
Packit 33f14e
  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
Packit 33f14e
  dnl once only, before all statements that occur in other macros.
Packit 33f14e
  AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
Packit 33f14e
Packit 33f14e
  AC_CHECK_HEADERS_ONCE([sys/ioctl.h])
Packit 33f14e
  if test $ac_cv_header_sys_ioctl_h = yes; then
Packit 33f14e
    HAVE_SYS_IOCTL_H=1
Packit 33f14e
    dnl Test whether <sys/ioctl.h> declares ioctl(), or whether some other
Packit 33f14e
    dnl header file, such as <unistd.h> or <stropts.h>, is needed for that.
Packit 33f14e
    AC_CACHE_CHECK([whether <sys/ioctl.h> declares ioctl],
Packit 33f14e
      [gl_cv_decl_ioctl_in_sys_ioctl_h],
Packit 33f14e
      [dnl We cannot use AC_CHECK_DECL because it produces its own messages.
Packit 33f14e
       AC_COMPILE_IFELSE(
Packit 33f14e
         [AC_LANG_PROGRAM(
Packit 33f14e
            [AC_INCLUDES_DEFAULT([#include <sys/ioctl.h>])],
Packit 33f14e
            [(void) ioctl;])],
Packit 33f14e
         [gl_cv_decl_ioctl_in_sys_ioctl_h=yes],
Packit 33f14e
         [gl_cv_decl_ioctl_in_sys_ioctl_h=no])
Packit 33f14e
      ])
Packit 33f14e
  else
Packit 33f14e
    HAVE_SYS_IOCTL_H=0
Packit 33f14e
  fi
Packit 33f14e
  AC_SUBST([HAVE_SYS_IOCTL_H])
Packit 33f14e
  dnl <sys/ioctl.h> is always overridden, because of GNULIB_POSIXCHECK.
Packit 33f14e
  gl_CHECK_NEXT_HEADERS([sys/ioctl.h])
Packit 33f14e
Packit 33f14e
  dnl Check for declarations of anything we want to poison if the
Packit 33f14e
  dnl corresponding gnulib module is not in use.
Packit 33f14e
  gl_WARN_ON_USE_PREPARE([[#include <sys/ioctl.h>
Packit 33f14e
/* Some platforms declare ioctl in the wrong header.  */
Packit 33f14e
#if !(defined __GLIBC__ && !defined __UCLIBC__)
Packit 33f14e
# include <unistd.h>
Packit 33f14e
#endif
Packit 33f14e
    ]], [ioctl])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_SYS_IOCTL_MODULE_INDICATOR],
Packit 33f14e
[
Packit 33f14e
  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
Packit 33f14e
  AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
Packit 33f14e
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
Packit 33f14e
  dnl Define it also as a C macro, for the benefit of the unit tests.
Packit 33f14e
  gl_MODULE_INDICATOR_FOR_TESTS([$1])
Packit 33f14e
])
Packit 33f14e
Packit 33f14e
AC_DEFUN([gl_SYS_IOCTL_H_DEFAULTS],
Packit 33f14e
[
Packit 33f14e
  GNULIB_IOCTL=0;         AC_SUBST([GNULIB_IOCTL])
Packit 33f14e
  dnl Assume proper GNU behavior unless another module says otherwise.
Packit 33f14e
  SYS_IOCTL_H_HAVE_WINSOCK2_H=0; AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H])
Packit 33f14e
  SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
Packit 33f14e
                        AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
Packit 33f14e
  REPLACE_IOCTL=0;      AC_SUBST([REPLACE_IOCTL])
Packit 33f14e
])