14080fa1b0cc7c3add4ff37c9e5b8acab06c5317
[garming/samba-autobuild/.git] / source4 / lib / socket / SConscript
1 #!/usr/bin/env python
2 Import('hostenv defines')
3 if hostenv['configure']:
4         conf = hostenv.Configure()
5         for h in ['sys/socket.h','sys/sockio.h','sys/un.h']:
6                 if conf.CheckCHeader(h):
7                         defines['HAVE_' + h.upper().replace('/','_').replace('.','_')] = 1
8         #HAVE_SOCK_SIN_LEN
9         conf.TryCompile("""
10 #include <sys/types.h>
11 #include <sys/socket.h>
12 #include <netinet/in.h>
13
14 int main(void)
15 {
16         struct sockaddr_in sock; sock.sin_len = sizeof(sock);
17         return 0;
18 }""", '.c')
19
20         #HAVE_UNIXSOCKET
21         conf.TryCompile("""
22 #include <sys/types.h>
23 #include <stdlib.h>
24 #include <stddef.h>
25 #include <sys/socket.h>
26 #include <sys/un.h>],
27
28 int main(void)
29 {
30   struct sockaddr_un sunaddr; 
31   sunaddr.sun_family = AF_UNIX;
32   return 0;
33 }""", '.c')
34
35         # HAVE_IPV6
36         conf.CheckFunc('gethostbyname2')
37
38         # The following test taken from the cvs sources
39         # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
40         # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
41         # libsocket.so which has a bad implementation of gethostbyname (it
42         # only looks in /etc/hosts), so we only look for -lsocket if we need
43         # it.
44         
45         connect_libs = []
46
47         if not conf.CheckFunc('connect'):
48                 for l in ['nsl_s','nsl','socket','inet']:
49                         if conf.CheckLib(l, 'connect'):
50                                 connect_libs.append(l)
51                                 break
52
53         # HAVE_WORKING_AF_LOCAL
54         # FIXME: Try compiling build/tests/unixsock.c
55
56
57         conf.Finish()
58
59 hostenv.Library('socket_ipv4.c')
60 hostenv.Library('socket_ipv6.c')
61 hostenv.Library('socket_unix.c')
62 hostenv.Library('socket', ['socket.c','access.c','connect.c'])
63