sockpfaf.m4 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # sockpfaf.m4 serial 8
  2. dnl Copyright (C) 2004, 2006, 2009-2017 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 Test for some common socket protocol families (PF_INET, PF_INET6, ...)
  7. dnl and some common address families (AF_INET, AF_INET6, ...).
  8. dnl This test assumes that a system supports an address family if and only if
  9. dnl it supports the corresponding protocol family.
  10. dnl From Bruno Haible.
  11. AC_DEFUN([gl_SOCKET_FAMILIES],
  12. [
  13. AC_REQUIRE([gl_HEADER_SYS_SOCKET])
  14. AC_CHECK_HEADERS_ONCE([netinet/in.h])
  15. AC_MSG_CHECKING([for IPv4 sockets])
  16. AC_CACHE_VAL([gl_cv_socket_ipv4],
  17. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  18. #ifdef HAVE_SYS_SOCKET_H
  19. #include <sys/socket.h>
  20. #endif
  21. #ifdef HAVE_NETINET_IN_H
  22. #include <netinet/in.h>
  23. #endif
  24. #ifdef HAVE_WINSOCK2_H
  25. #include <winsock2.h>
  26. #endif]],
  27. [[int x = AF_INET; struct in_addr y; struct sockaddr_in z;
  28. if (&x && &y && &z) return 0;]])],
  29. gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)])
  30. AC_MSG_RESULT([$gl_cv_socket_ipv4])
  31. if test $gl_cv_socket_ipv4 = yes; then
  32. AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.])
  33. fi
  34. AC_MSG_CHECKING([for IPv6 sockets])
  35. AC_CACHE_VAL([gl_cv_socket_ipv6],
  36. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  37. #ifdef HAVE_SYS_SOCKET_H
  38. #include <sys/socket.h>
  39. #endif
  40. #ifdef HAVE_NETINET_IN_H
  41. #include <netinet/in.h>
  42. #endif
  43. #ifdef HAVE_WINSOCK2_H
  44. #include <winsock2.h>
  45. #endif
  46. #ifdef HAVE_WS2TCPIP_H
  47. #include <ws2tcpip.h>
  48. #endif]],
  49. [[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
  50. if (&x && &y && &z) return 0;]])],
  51. gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
  52. AC_MSG_RESULT([$gl_cv_socket_ipv6])
  53. if test $gl_cv_socket_ipv6 = yes; then
  54. AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
  55. fi
  56. ])
  57. AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
  58. [
  59. AC_REQUIRE([gl_HEADER_SYS_SOCKET])
  60. AC_CHECK_HEADERS_ONCE([sys/un.h])
  61. AC_MSG_CHECKING([for UNIX domain sockets])
  62. AC_CACHE_VAL([gl_cv_socket_unix],
  63. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  64. #ifdef HAVE_SYS_SOCKET_H
  65. #include <sys/socket.h>
  66. #endif
  67. #ifdef HAVE_SYS_UN_H
  68. #include <sys/un.h>
  69. #endif
  70. #ifdef HAVE_WINSOCK2_H
  71. #include <winsock2.h>
  72. #endif]],
  73. [[int x = AF_UNIX; struct sockaddr_un y;
  74. if (&x && &y) return 0;]])],
  75. gl_cv_socket_unix=yes, gl_cv_socket_unix=no)])
  76. AC_MSG_RESULT([$gl_cv_socket_unix])
  77. if test $gl_cv_socket_unix = yes; then
  78. AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.])
  79. fi
  80. ])