New module 'sys_ioctl'.
[gnulib.git] / m4 / sys_ioctl_h.m4
1 # sys_ioctl_h.m4 serial 1
2 dnl Copyright (C) 2008 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 dnl Written by Bruno Haible.
8
9 AC_DEFUN([gl_SYS_IOCTL_H],
10 [
11   dnl Use AC_REQUIRE here, so that the default behavior below is expanded
12   dnl once only, before all statements that occur in other macros.
13   AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
14
15   AC_CHECK_HEADERS_ONCE([sys/ioctl.h])
16   if test $ac_cv_header_sys_ioctl_h = yes; then
17     HAVE_SYS_IOCTL_H=1
18     dnl Test whether <sys/ioctl.h> declares ioctl(), or whether some other
19     dnl header file, such as <unistd.h> or <stropts.h>, is needed for that.
20     AC_CACHE_CHECK([whether <sys/ioctl.h> declares ioctl],
21       [gl_cv_decl_ioctl_in_sys_ioctl_h],
22       [AC_CHECK_DECL([ioctl],
23          [gl_cv_decl_ioctl_in_sys_ioctl_h=yes],
24          [gl_cv_decl_ioctl_in_sys_ioctl_h=no],
25          [#include <sys/ioctl.h>])
26       ])
27     if test $gl_cv_decl_ioctl_in_sys_ioctl_h != yes; then
28       SYS_IOCTL_H='sys/ioctl.h'
29     fi
30   else
31     HAVE_SYS_IOCTL_H=0
32     SYS_IOCTL_H='sys/ioctl.h'
33   fi
34   AC_SUBST([HAVE_SYS_IOCTL_H])
35   dnl Execute this unconditionally, because SYS_IOCTL_H may be set by other
36   dnl modules, after this code is executed.
37   gl_CHECK_NEXT_HEADERS([sys/ioctl.h])
38 ])
39
40 dnl Unconditionally enables the replacement of <sys/ioctl.h>.
41 AC_DEFUN([gl_REPLACE_SYS_IOCTL_H],
42 [
43   AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
44   SYS_IOCTL_H='sys/ioctl.h'
45 ])
46
47 AC_DEFUN([gl_SYS_IOCTL_MODULE_INDICATOR],
48 [
49   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
50   AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
51   GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
52 ])
53
54 AC_DEFUN([gl_SYS_IOCTL_H_DEFAULTS],
55 [
56   GNULIB_IOCTL=0;         AC_SUBST([GNULIB_IOCTL])
57   dnl Assume proper GNU behavior unless another module says otherwise.
58   SYS_IOCTL_H_HAVE_WINSOCK2_H=0; AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H])
59   SYS_IOCTL_H='';                AC_SUBST([SYS_IOCTL_H])
60 ])