4
0

sockpfaf.m4 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # sockpfaf.m4 serial 6
  2. dnl Copyright (C) 2004, 2006, 2009 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_TRY_COMPILE([#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_TRY_COMPILE([#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. [int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
  47. if (&x && &y && &z) return 0;],
  48. gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
  49. AC_MSG_RESULT([$gl_cv_socket_ipv6])
  50. if test $gl_cv_socket_ipv6 = yes; then
  51. AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
  52. fi
  53. ])