3e73e839b1c34c5c854b17740e9fac64cf9f863d
[sfrench/samba-autobuild/.git] / lib / uid_wrapper / wscript
1 #!/usr/bin/env python
2
3 import os
4
5 VERSION="1.0.1"
6
7 def configure(conf):
8     if conf.CHECK_BUNDLED_SYSTEM('uid_wrapper', minversion=VERSION, set_target=False):
9         conf.DEFINE('USING_SYSTEM_UID_WRAPPER', 1)
10         libuid_wrapper_so_path = 'libuid_wrapper.so'
11     else:
12         # check HAVE_GCC_THREAD_LOCAL_STORAGE
13         conf.CHECK_CODE('''
14             __thread int tls;
15
16             int main(void) {
17                 return 0;
18             }
19             ''',
20             'HAVE_GCC_THREAD_LOCAL_STORAGE',
21             addmain=False,
22             msg='Checking for thread local storage')
23
24         # check HAVE_DESTRUCTOR_ATTRIBUTE
25         conf.CHECK_CODE('''
26             void test_destructor_attribute(void) __attribute__ ((destructor));
27
28             void test_destructor_attribute(void)
29             {
30                 return;
31             }
32
33             int main(void) {
34                 return 0;
35             }
36             ''',
37             'HAVE_DESTRUCTOR_ATTRIBUTE',
38             addmain=False,
39             msg='Checking for library destructor support')
40
41         # check HAVE_FUNCTION_ATTRIBUTE_FORMAT
42         conf.CHECK_CODE('''
43             void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
44
45             int main(void) {
46                 return 0;
47             }
48             ''',
49             'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
50             addmain=False,
51             msg='Checking for printf format validation support')
52
53         # Create full path to uid_wrapper
54         srcdir = os.path.realpath(conf.srcdir)
55         libuid_wrapper_so_path = srcdir + '/bin/default/lib/uid_wrapper/libuid-wrapper.so'
56
57     conf.DEFINE('LIBUID_WRAPPER_SO_PATH', libuid_wrapper_so_path)
58     conf.DEFINE('UID_WRAPPER', 1)
59
60 def build(bld):
61     if not bld.CONFIG_SET("USING_SYSTEM_UID_WRAPPER"):
62         # We need to do it this way or the library wont work.
63         # Using private_library=True will add symbol version which
64         # breaks preloading!
65         bld.SAMBA_LIBRARY('uid_wrapper',
66                           source='uid_wrapper.c',
67                           cflags='-DNDEBUG',
68                           deps='dl',
69                           install=False,
70                           realname='libuid-wrapper.so')
71