xref: /netbsd-src/external/gpl2/xcvs/dist/m4/sockpfaf.m4 (revision a7c918477dd5f12c1da816ba05caf44eab2d06d6)
1# sockpfaf.m4 serial 2
2dnl Copyright (C) 2004 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Test for some common socket protocol families (PF_INET, PF_INET6, ...)
8dnl and some common address families (AF_INET, AF_INET6, ...).
9dnl This test assumes that a system supports an address family if and only if
10dnl it supports the corresponding protocol family.
11
12dnl From Bruno Haible.
13
14AC_DEFUN([gl_SOCKET_FAMILIES],
15[
16  AC_MSG_CHECKING(for IPv4 sockets)
17  AC_CACHE_VAL(gl_cv_socket_ipv4,
18    [AC_TRY_COMPILE([#include <sys/types.h>
19#include <sys/socket.h>
20#include <netinet/in.h>],
21[int x = AF_INET; struct in_addr y; struct sockaddr_in z;],
22       gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)])
23  AC_MSG_RESULT($gl_cv_socket_ipv4)
24  if test $gl_cv_socket_ipv4 = yes; then
25    AC_DEFINE(HAVE_IPV4, 1, [Define to 1 if <sys/socket.h> defines AF_INET.])
26  fi
27
28  AC_MSG_CHECKING(for IPv6 sockets)
29  AC_CACHE_VAL(gl_cv_socket_ipv6,
30    [AC_TRY_COMPILE([#include <sys/types.h>
31#include <sys/socket.h>
32#include <netinet/in.h>],
33[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;],
34       gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
35  AC_MSG_RESULT($gl_cv_socket_ipv6)
36  if test $gl_cv_socket_ipv6 = yes; then
37    AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if <sys/socket.h> defines AF_INET6.])
38  fi
39])
40