strengthen self-containedness check for sys/select.h
[gnulib.git] / m4 / sys_select_h.m4
1 # sys_select_h.m4 serial 5
2 dnl Copyright (C) 2006-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 AC_DEFUN([gl_HEADER_SYS_SELECT],
8 [
9   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
10   AC_CACHE_CHECK([whether <sys/select.h> is self-contained],
11     [gl_cv_header_sys_select_h_selfcontained],
12     [
13       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>]],
14                                          [[struct timeval b;]])],
15         [gl_cv_header_sys_select_h_selfcontained=yes],
16         [gl_cv_header_sys_select_h_selfcontained=no])
17     ])
18   if test $gl_cv_header_sys_select_h_selfcontained = yes; then
19     SYS_SELECT_H=''
20   else
21     SYS_SELECT_H='sys/select.h'
22     gl_CHECK_NEXT_HEADERS([sys/select.h])
23     if test $ac_cv_header_sys_select_h = yes; then
24       HAVE_SYS_SELECT_H=1
25     else
26       HAVE_SYS_SELECT_H=0
27     fi
28     AC_SUBST([HAVE_SYS_SELECT_H])
29     gl_PREREQ_SYS_H_WINSOCK2
30   fi
31   AC_SUBST([SYS_SELECT_H])
32   if test x$ac_cv_header_winsock2_h = xyes; then
33     AC_LIBOBJ(winsock-select)
34   fi
35 ])