summaryrefslogtreecommitdiff
path: root/source4/lib/replace/SConscript
blob: f45d0e7d5acded55e610dfcb34056b2d1082b949 (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
65
66
67
68
69
70
71
#!/usr/bin/env python
Import('hostenv defines')

rep_files = ['replace.c', 'snprintf.c','dlfcn.c']

if hostenv['configure']:
	conf = Configure(hostenv)
	for f in ['memset','syslog','setnetgrent','getnetgrent','endnetgrent', \
			'mktemp', 'memcpy']:
		if not conf.CheckFunc(f,'c'):
			print "Required function `%s' not found" % f
			exit(1)
	
	for f in ['strtoull','__strtoull','strtouq','strtoll','__strtoll','strtoq',
			  'seteuid','setresuid','setegid','setresgid','dlsym','dlopen',
			  'dlerror','dlclose','waitpid','getcwd','strdup','strndup',
			  'strnlen','strerror','bzero','chroot','strlcpy','strlcat',
			  'memmove','vsnprintf','asprintf','snprintf','vasprintf',
			  'innetgr','mktime','rename','ftruncate','chsize','setlinebuf',
			  'setenv','vsyslog','pread','pwrite']:
		if conf.CheckFunc(f,'c'):
			defines['HAVE_' + f.upper()] = 1

	# Check for errno declaration
	if conf.TryCompile("""
#include <errno.h>

int main() {
	int i = (int)errno;
	return 0;
}""", '.c'):
		defines['HAVE_ERRNO_DECL'] = 1

	for h in ['dlfcn.h']:
		if conf.CheckCHeader('dlfcn.h'):
			defines['HAVE_' + h.upper().replace('.','_').replace('/','_')] = 1

	if not conf.CheckType('socklen_t', "#include <sys/socket.h>"):
		defines['socklen_t'] = 'int'

	needed_types = { 
		'uint_t': 'unsigned int',
		'int8_t': 'signed char',
		'uint8_t': 'unsigned char',
		'u_int8_t': 'unsigned char',
		'int16_t': 'short',
		'uint16_t': 'unsigned short',
		'u_int16_t': 'unsigned short',
		'int32_t': 'long',
		'uint32_t': 'unsigned long',
		'u_int32_t': 'unsigned long',
		'int64_t': 'long long',
		'uint64_t': 'unsigned long long',
		'ssize_t': 'int'
	}

	type_headers = """
#include <stdint.h>
#include <sys/types.h>
"""	
	for t in needed_types:
		if not conf.CheckType(t,type_headers):
			defines[t] = needed_types[t]

	if not conf.TryRun(open("../../build/tests/os2_delete.c").read(), '.c'):
		rep_files += ['repdir/repdir.c']

	conf.Finish()

hostenv.StaticLibrary('replace', rep_files)
SConscript(dirs=['win32'])