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