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