sockpfaf.m4 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # sockpfaf.m4 serial 10
  2. dnl Copyright (C) 2004, 2006, 2009-2023 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_SYS_SOCKET_H])
  14. AC_CHECK_HEADERS_ONCE([netinet/in.h])
  15. AC_CACHE_CHECK([for IPv4 sockets],
  16. [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. if test $gl_cv_socket_ipv4 = yes; then
  31. AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.])
  32. fi
  33. AC_CACHE_CHECK([for IPv6 sockets],
  34. [gl_cv_socket_ipv6],
  35. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  36. #ifdef HAVE_SYS_SOCKET_H
  37. #include <sys/socket.h>
  38. #endif
  39. #ifdef HAVE_NETINET_IN_H
  40. #include <netinet/in.h>
  41. #endif
  42. #ifdef HAVE_WINSOCK2_H
  43. #include <winsock2.h>
  44. #endif
  45. #ifdef HAVE_WS2TCPIP_H
  46. #include <ws2tcpip.h>
  47. #endif]],
  48. [[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
  49. if (&x && &y && &z) return 0;]])],
  50. gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
  51. if test $gl_cv_socket_ipv6 = yes; then
  52. AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
  53. fi
  54. ])
  55. AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
  56. [
  57. AC_REQUIRE([gl_SYS_SOCKET_H])
  58. AC_CHECK_HEADERS_ONCE([sys/un.h])
  59. AC_CACHE_CHECK([for UNIX domain sockets],
  60. [gl_cv_socket_unix],
  61. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
  62. #ifdef HAVE_SYS_SOCKET_H
  63. #include <sys/socket.h>
  64. #endif
  65. #ifdef HAVE_SYS_UN_H
  66. #include <sys/un.h>
  67. #endif
  68. #ifdef HAVE_WINSOCK2_H
  69. #include <winsock2.h>
  70. #endif]],
  71. [[int x = AF_UNIX; struct sockaddr_un y;
  72. if (&x && &y) return 0;]])],
  73. gl_cv_socket_unix=yes, gl_cv_socket_unix=no)])
  74. if test $gl_cv_socket_unix = yes; then
  75. AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.])
  76. fi
  77. ])