Make <sys/select.h> self-contained, i.e. make it possible to include it
[gnulib.git] / m4 / sys_select_h.m4
1 # sys_select_h.m4 serial 2
2 dnl Copyright (C) 2006-2007 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 AC_DEFUN([gl_HEADER_SYS_SELECT],
8 [
9   AC_CACHE_CHECK([whether <sys/select.h> is self-contained],
10     [gl_cv_header_sys_select_h_selfcontained],
11     [
12       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/select.h>], [])],
13         [gl_cv_header_sys_select_h_selfcontained=yes],
14         [gl_cv_header_sys_select_h_selfcontained=no])
15     ])
16   if test $gl_cv_header_sys_select_h_selfcontained = yes; then
17     SYS_SELECT_H=''
18   else
19     SYS_SELECT_H='sys/select.h'
20     AC_CHECK_HEADERS([sys/select.h])
21     gl_ABSOLUTE_HEADER([sys/select.h])
22     ABSOLUTE_SYS_SELECT_H=\"$gl_cv_absolute_sys_select_h\"
23     AC_SUBST([ABSOLUTE_SYS_SELECT_H])
24     if test $ac_cv_header_sys_select_h = yes; then
25       HAVE_SYS_SELECT_H=1
26     else
27       HAVE_SYS_SELECT_H=0
28     fi
29     AC_SUBST([HAVE_SYS_SELECT_H])
30   fi
31   AC_SUBST([SYS_SELECT_H])
32 ])