r10509: Some more sconscript fixes. Now getting to link stage for smbclient
[bbaumbach/samba-autobuild/.git] / source4 / lib / replace / SConscript
1 #!/usr/bin/env python
2 Import('hostenv defines')
3
4 rep_files = ['replace.c', 'snprintf.c','dlfcn.c']
5
6 if hostenv['configure']:
7         conf = Configure(hostenv)
8         for f in ['memset','syslog','setnetgrent','getnetgrent','endnetgrent', \
9                         'mktemp', 'memcpy']:
10                 if not conf.CheckFunc(f,'c'):
11                         print "Required function `%s' not found" % f
12                         exit(1)
13         
14         for f in ['strtoull','__strtoull','strtouq','strtoll','__strtoll','strtoq',
15                           'seteuid','setresuid','setegid','setresgid','dlsym','dlopen',
16                           'dlerror','dlclose','waitpid','getcwd','strdup','strndup',
17                           'strnlen','strerror','bzero','chroot','strlcpy','strlcat',
18                           'memmove','vsnprintf','asprintf','snprintf','vasprintf',
19                           'innetgr','mktime','rename','ftruncate','chsize','setlinebuf',
20                           'setenv','vsyslog','pread','pwrite']:
21                 if conf.CheckFunc(f,'c'):
22                         defines['HAVE_' + f.upper()] = 1
23
24         # Check for errno declaration
25         if conf.TryCompile("""
26 #include <errno.h>
27
28 int main() {
29         int i = (int)errno;
30         return 0;
31 }""", '.c'):
32                 defines['HAVE_ERRNO_DECL'] = 1
33
34         for h in ['dlfcn.h']:
35                 if conf.CheckCHeader('dlfcn.h'):
36                         defines['HAVE_' + h.upper().replace('.','_').replace('/','_')] = 1
37
38         if not conf.CheckType('socklen_t', "#include <sys/socket.h>"):
39                 defines['socklen_t'] = 'int'
40
41         needed_types = { 
42                 'uint_t': 'unsigned int',
43                 'int8_t': 'signed char',
44                 'uint8_t': 'unsigned char',
45                 'u_int8_t': 'unsigned char',
46                 'int16_t': 'short',
47                 'uint16_t': 'unsigned short',
48                 'u_int16_t': 'unsigned short',
49                 'int32_t': 'long',
50                 'uint32_t': 'unsigned long',
51                 'u_int32_t': 'unsigned long',
52                 'int64_t': 'long long',
53                 'uint64_t': 'unsigned long long',
54         }
55
56         type_headers = """
57 #include <stdint.h>
58 #include <sys/types.h>
59 """     
60         for t in needed_types:
61                 if not conf.CheckType(t,type_headers):
62                         defines[t] = needed_types[t]
63
64         if not conf.TryRun(open("../../build/tests/os2_delete.c").read(), '.c'):
65                 rep_files += ['repdir/repdir.c']
66
67         conf.Finish()
68
69 hostenv.StaticLibrary('replace', rep_files)
70 SConscript(dirs=['win32'])