sys_socket_h.m4 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # sys_socket_h.m4 serial 4
  2. dnl Copyright (C) 2005, 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. dnl From Simon Josefsson.
  7. AC_DEFUN([gl_HEADER_SYS_SOCKET],
  8. [
  9. AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
  10. [gl_cv_header_sys_socket_h_selfcontained],
  11. [
  12. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>], [])],
  13. [gl_cv_header_sys_socket_h_selfcontained=yes],
  14. [gl_cv_header_sys_socket_h_selfcontained=no])
  15. ])
  16. if test $gl_cv_header_sys_socket_h_selfcontained = yes; then
  17. SYS_SOCKET_H=''
  18. else
  19. SYS_SOCKET_H='sys/socket.h'
  20. gl_CHECK_NEXT_HEADERS([sys/socket.h])
  21. if test $ac_cv_header_sys_socket_h = yes; then
  22. HAVE_SYS_SOCKET_H=1
  23. HAVE_WINSOCK2_H=0
  24. HAVE_WS2TCPIP_H=0
  25. else
  26. HAVE_SYS_SOCKET_H=0
  27. dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
  28. dnl the check for those headers unconditional; yet cygwin reports
  29. dnl that the headers are present but cannot be compiled (since on
  30. dnl cygwin, all socket information should come from sys/socket.h).
  31. AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
  32. if test $ac_cv_header_winsock2_h = yes; then
  33. HAVE_WINSOCK2_H=1
  34. else
  35. HAVE_WINSOCK2_H=0
  36. fi
  37. if test $ac_cv_header_ws2tcpip_h = yes; then
  38. HAVE_WS2TCPIP_H=1
  39. else
  40. HAVE_WS2TCPIP_H=0
  41. fi
  42. fi
  43. AC_SUBST([HAVE_SYS_SOCKET_H])
  44. AC_SUBST([HAVE_WINSOCK2_H])
  45. AC_SUBST([HAVE_WS2TCPIP_H])
  46. fi
  47. AC_SUBST([SYS_SOCKET_H])
  48. ])