1AC_CHECK_FUNCS(writev)
2AC_CHECK_FUNCS(readv)
3
4AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
5AC_TRY_COMPILE([#include <sys/types.h>
6#include <sys/socket.h>
7#include <netinet/in.h>],
8[struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
9samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
10if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
11    AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
12fi
13
14# The following test taken from the cvs sources
15# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
16# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
17# libsocket.so which has a bad implementation of gethostbyname (it
18# only looks in /etc/hosts), so we only look for -lsocket if we need
19# it.
20AC_CHECK_FUNCS(connect)
21if test x"$ac_cv_func_connect" = x"no"; then
22    AC_CHECK_LIB_EXT(nsl_s, SOCKET_LIBS, connect)
23    AC_CHECK_LIB_EXT(nsl, SOCKET_LIBS, connect)
24    AC_CHECK_LIB_EXT(socket, SOCKET_LIBS, connect)
25    AC_CHECK_LIB_EXT(inet, SOCKET_LIBS, connect)
26    SMB_ENABLE(EXT_SOCKET,YES)
27    dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
28    dnl has been cached.
29    if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
30       test x"$ac_cv_lib_ext_nsl_connect" = x"yes" ||
31       test x"$ac_cv_lib_ext_socket_connect" = x"yes" ||
32       test x"$ac_cv_lib_ext_inet_connect" = x"yes"; then
33        AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
34    else
35	AC_MSG_ERROR([no connect() function available!])
36    fi
37fi
38
39SMB_EXT_LIB(EXT_SOCKET,[${SOCKET_LIBS}],[${SOCKET_CFLAGS}],[${SOCKET_CPPFLAGS}],[${SOCKET_LDFLAGS}])
40
41AC_CHECK_FUNCS(gethostbyname)
42if test x"$ac_cv_func_gethostbyname" = x"no"; then
43    AC_CHECK_LIB_EXT(nsl_s, NSL_LIBS, gethostbyname)
44    AC_CHECK_LIB_EXT(nsl, NSl_LIBS, gethostbyname)
45    AC_CHECK_LIB_EXT(socket, NSL_LIBS, gethostbyname)
46    SMB_ENABLE(EXT_NSL,YES)
47    dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here, because the value
48    dnl has been cached.
49    if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" != x"yes" &&
50       test x"$ac_cv_lib_ext_nsl_gethostbyname" != x"yes" &&
51       test x"$ac_cv_lib_ext_socket_gethostbyname" != x"yes"; then
52		AC_MSG_ERROR([no gethostbyname() function available!])
53    fi
54fi
55
56SMB_EXT_LIB(EXT_NSL,[${NSL_LIBS}],[],[],[])
57
58############################################
59# check for unix domain sockets
60AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
61    AC_TRY_COMPILE([
62#include <sys/types.h>
63#include <stdlib.h>
64#include <stddef.h>
65#include <sys/socket.h>
66#include <sys/un.h>],
67[
68  struct sockaddr_un sunaddr;
69  sunaddr.sun_family = AF_UNIX;
70],
71	samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
72SMB_ENABLE(socket_unix, NO)
73if test x"$samba_cv_unixsocket" = x"yes"; then
74    SMB_ENABLE(socket_unix, YES)
75    AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
76fi
77
78AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
79AC_TRY_RUN([#include "${srcdir-.}/build/tests/unixsock.c"],
80	   samba_cv_HAVE_WORKING_AF_LOCAL=yes,
81	   samba_cv_HAVE_WORKING_AF_LOCAL=no,
82	   samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
83if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
84then
85    AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
86fi
87
88dnl test for ipv6 using the gethostbyname2() function. That should be sufficient
89dnl for now
90AC_CHECK_FUNCS(gethostbyname2, have_ipv6=true, have_ipv6=false)
91SMB_ENABLE(socket_ipv6, NO)
92if $have_ipv6 = true; then
93    SMB_ENABLE(socket_ipv6, YES)
94    AC_DEFINE(HAVE_SOCKET_IPV6,1,[Whether the system has ipv6 support])
95fi
96dnl don't build ipv6 by default, unless the above test enables it, or
97dnl the configure uses --with-static-modules=socket_ipv6
98
99
100##################
101# look for a method of finding the list of network interfaces
102#
103# This tests need LIBS="$NSL_LIBS $SOCKET_LIBS"
104#
105old_LIBS=$LIBS
106LIBS="$NSL_LIBS $SOCKET_LIBS"
107iface=no;
108AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
109AC_TRY_RUN([
110#define HAVE_IFACE_AIX 1
111#define AUTOCONF_TEST 1
112#undef _XOPEN_SOURCE_EXTENDED
113#include "${srcdir-.}/lib/socket/netif.c"],
114           samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
115if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
116    iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
117fi
118
119if test $iface = no; then
120AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
121AC_TRY_RUN([
122#define HAVE_IFACE_IFCONF 1
123#define AUTOCONF_TEST 1
124#include "${srcdir-.}/lib/socket/netif.c"],
125           samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
126if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
127    iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
128fi
129fi
130
131if test $iface = no; then
132AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
133AC_TRY_RUN([
134#define HAVE_IFACE_IFREQ 1
135#define AUTOCONF_TEST 1
136#include "${srcdir-.}/lib/socket/netif.c"],
137           samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
138if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
139    iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
140fi
141fi
142
143LIBS=$old_LIBS
144