r25600: fix stupid typo...this should fix the build on sunX
[nivanova/samba-autobuild/.git] / source4 / lib / socket / config.m4
1 AC_CHECK_FUNCS(writev)
2 AC_CHECK_FUNCS(readv)
3
4 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
5 AC_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);],
9 samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
10 if 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])
12 fi
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.
20 AC_CHECK_FUNCS(connect)
21 if 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
37 fi
38
39 SMB_EXT_LIB(EXT_SOCKET,[${SOCKET_LIBS}],[${SOCKET_CFLAGS}],[${SOCKET_CPPFLAGS}],[${SOCKET_LDFLAGS}])
40
41 AC_CHECK_FUNCS(gethostbyname)
42 if 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
54 fi
55
56 SMB_EXT_LIB(EXT_NSL,[${NSL_LIBS}],[],[],[])
57
58 ############################################
59 # check for unix domain sockets
60 AC_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)])
72 SMB_ENABLE(socket_unix, NO)
73 if 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])
76 fi
77
78 AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
79 AC_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)])
83 if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
84 then
85     AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
86 fi
87
88 dnl test for ipv6 using the gethostbyname2() function. That should be sufficient
89 dnl for now
90 AC_CHECK_FUNCS(gethostbyname2, have_ipv6=true, have_ipv6=false)
91 SMB_ENABLE(socket_ipv6, NO)
92 if $have_ipv6 = true; then
93     SMB_ENABLE(socket_ipv6, YES)
94     AC_DEFINE(HAVE_IPV6,1,[Whether the system has ipv6 support])
95 fi
96 dnl don't build ipv6 by default, unless the above test enables it, or
97 dnl 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 #
105 old_CFLAGS=$CFLAGS
106 old_LIBS=$LIBS
107 LIBS="$NSL_LIBS $SOCKET_LIBS"
108 CFLAGS="$CFLAGS -Ilib/replace"
109 iface=no;
110 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
111 AC_TRY_RUN([
112 #define HAVE_IFACE_AIX 1
113 #define AUTOCONF_TEST 1
114 #undef _XOPEN_SOURCE_EXTENDED
115 #include "${srcdir-.}/lib/socket/netif.c"],
116            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
117 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
118     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
119 fi
120
121 if test $iface = no; then
122 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
123 AC_TRY_RUN([
124 #define HAVE_IFACE_IFCONF 1
125 #define AUTOCONF_TEST 1
126 #include "${srcdir-.}/lib/socket/netif.c"],
127            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
128 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
129     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
130 fi
131 fi
132
133 if test $iface = no; then
134 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
135 AC_TRY_RUN([
136 #define HAVE_IFACE_IFREQ 1
137 #define AUTOCONF_TEST 1
138 #include "${srcdir-.}/lib/socket/netif.c"],
139            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
140 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
141     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
142 fi
143 fi
144
145 CFLAGS=$old_CFLAGS
146 LIBS=$old_LIBS