summaryrefslogtreecommitdiff
path: root/source4/lib/socket/SConscript
blob: 26c8bf444c7e7707e5a1d16e76a175620b761463 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
Import('hostenv defines')

if hostenv['configure']:
	conf = hostenv.Configure()
	for h in ['sys/socket.h','sys/sockio.h','sys/un.h']:
		if conf.CheckCHeader(h):
			defines['HAVE_' + h.upper().replace('/','_').replace('.','_')] = 1
	#HAVE_SOCK_SIN_LEN
	conf.TryCompile("""
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

int main(void)
{
	struct sockaddr_in sock; sock.sin_len = sizeof(sock);
	return 0;
}""", '.c')

	#HAVE_UNIXSOCKET
	conf.TryCompile("""
#include <sys/types.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/socket.h>
#include <sys/un.h>],

int main(void)
{
  struct sockaddr_un sunaddr; 
  sunaddr.sun_family = AF_UNIX;
  return 0;
}""", '.c')

	# HAVE_IPV6
	conf.CheckFunc('gethostbyname2')

	# The following test taken from the cvs sources
	# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
	# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
	# libsocket.so which has a bad implementation of gethostbyname (it
	# only looks in /etc/hosts), so we only look for -lsocket if we need
	# it.
	
	connect_libs = []

	if not conf.CheckFunc('connect'):
		for l in ['nsl_s','nsl','socket','inet']:
			if conf.CheckLib(l, 'connect'):
				connect_libs.append(l)
				break

	# HAVE_WORKING_AF_LOCAL
	# FIXME: Try compiling build/tests/unixsock.c


	conf.Finish()

hostenv.StaticLibrary('socket_ipv4.c')
hostenv.StaticLibrary('socket_ipv6.c')
hostenv.StaticLibrary('socket_unix.c')
hostenv.StaticLibrary('socket', ['socket.c','access.c','connect.c'])