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