repl_meta_data: Allow delete of an object with dangling backlinks
[metze/samba/wip.git] / lib / socket_wrapper / wscript
1 #!/usr/bin/env python
2
3 import os
4
5 VERSION="1.1.7"
6
7 def configure(conf):
8     if conf.CHECK_BUNDLED_SYSTEM('socket_wrapper', minversion=VERSION, set_target=False):
9         conf.DEFINE('USING_SYSTEM_SOCKET_WRAPPER', 1)
10         libsocket_wrapper_so_path = 'libsocket_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         conf.CHECK_HEADERS('sys/signalfd.h')
54         conf.CHECK_HEADERS('sys/eventfd.h')
55         conf.CHECK_HEADERS('sys/timerfd.h')
56         conf.CHECK_HEADERS('gnu/lib-names.h')
57         conf.CHECK_HEADERS('rpc/rpc.h')
58
59         conf.CHECK_STRUCTURE_MEMBER('struct msghdr',
60                                     'msg_control',
61                                     headers='sys/types.h sys/socket.h',
62                                     define='HAVE_STRUCT_MSGHDR_MSG_CONTROL')
63
64         conf.CHECK_STRUCTURE_MEMBER('struct in_pktinfo',
65                                     'ipi_addr',
66                                     headers='sys/types.h sys/socket.h netinet/in.h',
67                                     define='HAVE_STRUCT_IN_PKTINFO')
68
69         conf.CHECK_STRUCTURE_MEMBER('struct in6_pktinfo',
70                                     'ipi6_addr',
71                                     headers='sys/types.h sys/socket.h netinet/in.h',
72                                     define='HAVE_STRUCT_IN6_PKTINFO')
73
74         conf.CHECK_FUNCS('getaddrinfo')
75         conf.CHECK_FUNCS('signalfd eventfd timerfd_create')
76         conf.CHECK_FUNCS('bindresvport')
77         conf.CHECK_FUNCS('pledge')
78         conf.CHECK_FUNCS('accept4')
79
80         conf.CHECK_FUNCS_IN('bind',
81                             'socket',
82                             checklibc=True,
83                             headers='sys/types.h sys/socket.h')
84
85         conf.CHECK_C_PROTOTYPE('accept',
86                                'int accept(int s, struct sockaddr *addr, Psocklen_t addrlen)',
87                                define='HAVE_ACCEPT_PSOCKLEN_T', headers='sys/types.h sys/socket.h')
88
89         conf.CHECK_C_PROTOTYPE('ioctl',
90                                'int ioctl(int s, int r, ...)',
91                                define='HAVE_IOCTL_INT', headers='unistd.h sys/ioctl.h')
92
93         if conf.CONFIG_SET("HAVE_EVENTFD"):
94             conf.CHECK_C_PROTOTYPE('eventfd',
95                                    'int eventfd(unsigned int count, int flags)',
96                                    define='HAVE_EVENTFD_UNSIGNED_INT', headers='sys/eventfd.h')
97
98         # Create full path to socket_wrapper
99         blddir = os.path.realpath(conf.blddir)
100         libsocket_wrapper_so_path = blddir + '/default/lib/socket_wrapper/libsocket-wrapper.so'
101
102     conf.DEFINE('LIBSOCKET_WRAPPER_SO_PATH', libsocket_wrapper_so_path)
103     conf.DEFINE('SOCKET_WRAPPER', 1)
104
105 def build(bld):
106     if not bld.CONFIG_SET("USING_SYSTEM_SOCKET_WRAPPER"):
107         # We need to do it this way or the library wont work.
108         # Using private_library=True will add symbol version which
109         # breaks preloading!
110         bld.SAMBA_LIBRARY('socket_wrapper',
111                           source='socket_wrapper.c',
112                           deps='dl',
113                           install=False,
114                           realname='libsocket-wrapper.so')