third_party: Update socket_wrapper to version 1.3.3
[samba.git] / third_party / socket_wrapper / wscript
1 #!/usr/bin/env python
2
3 import os
4
5 VERSION="1.3.3"
6
7 def configure(conf):
8     if conf.CHECK_SOCKET_WRAPPER():
9         conf.DEFINE('USING_SYSTEM_SOCKET_WRAPPER', 1)
10         libsocket_wrapper_so_path = 'libsocket_wrapper.so'
11     else:
12
13         if conf.CONFIG_SET("HAVE___THREAD"):
14             conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)
15
16         # check HAVE_FUNCTION_ATTRIBUTE_FORMAT
17         conf.CHECK_CODE('''
18             void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
19
20             int main(void) {
21                 return 0;
22             }
23             ''',
24             'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
25             addmain=False,
26             strict=True,
27             msg='Checking for printf format validation support')
28
29         conf.CHECK_HEADERS('sys/signalfd.h')
30         conf.CHECK_HEADERS('sys/eventfd.h')
31         conf.CHECK_HEADERS('sys/timerfd.h')
32         conf.CHECK_HEADERS('gnu/lib-names.h')
33         conf.CHECK_HEADERS('rpc/rpc.h')
34         conf.CHECK_HEADERS('netinet/tcp_fsm.h')
35
36         conf.CHECK_STRUCTURE_MEMBER('struct msghdr',
37                                     'msg_control',
38                                     headers='sys/types.h sys/socket.h',
39                                     define='HAVE_STRUCT_MSGHDR_MSG_CONTROL')
40
41         conf.CHECK_STRUCTURE_MEMBER('struct in_pktinfo',
42                                     'ipi_addr',
43                                     headers='sys/types.h sys/socket.h netinet/in.h',
44                                     define='HAVE_STRUCT_IN_PKTINFO')
45
46         conf.CHECK_STRUCTURE_MEMBER('struct in6_pktinfo',
47                                     'ipi6_addr',
48                                     headers='sys/types.h sys/socket.h netinet/in.h',
49                                     define='HAVE_STRUCT_IN6_PKTINFO')
50
51         conf.CHECK_FUNCS('getaddrinfo')
52         conf.CHECK_FUNCS('signalfd eventfd timerfd_create')
53         conf.CHECK_FUNCS('bindresvport')
54         conf.CHECK_FUNCS('pledge')
55         conf.CHECK_FUNCS('accept4')
56         conf.CHECK_FUNCS('__close_nocancel')
57
58         conf.CHECK_FUNCS_IN('bind',
59                             'socket',
60                             checklibc=True,
61                             headers='sys/types.h sys/socket.h')
62
63         conf.CHECK_C_PROTOTYPE('accept',
64                                'int accept(int s, struct sockaddr *addr, Psocklen_t addrlen)',
65                                define='HAVE_ACCEPT_PSOCKLEN_T', headers='sys/types.h sys/socket.h')
66
67         conf.CHECK_C_PROTOTYPE('ioctl',
68                                'int ioctl(int s, int r, ...)',
69                                define='HAVE_IOCTL_INT', headers='unistd.h sys/ioctl.h')
70
71         if conf.CONFIG_SET("HAVE_EVENTFD"):
72             conf.CHECK_C_PROTOTYPE('eventfd',
73                                    'int eventfd(unsigned int count, int flags)',
74                                    define='HAVE_EVENTFD_UNSIGNED_INT', headers='sys/eventfd.h')
75
76         # FreeBSD exports each syscall also with '_' as prefix
77         # and these symbols are used if called by system libraries itself.
78         # That means socket_wrapper needs to implement these too
79         # in order to inject itself into system libraries,
80         # we just check for _socket and _close and assume the rest
81         # is also there...
82         conf.CHECK_FUNCS('_socket _close')
83
84         # Create full path to socket_wrapper
85         blddir = os.path.realpath(conf.bldnode.abspath())
86         libsocket_wrapper_so_path = blddir + '/default/third_party/socket_wrapper/libsocket-wrapper.so'
87
88     conf.DEFINE('LIBSOCKET_WRAPPER_SO_PATH', libsocket_wrapper_so_path)
89     conf.DEFINE('SOCKET_WRAPPER', 1)
90
91 def build(bld):
92     if not bld.CONFIG_SET("USING_SYSTEM_SOCKET_WRAPPER"):
93         # We need to do it this way or the library wont work.
94         # Using private_library=True will add symbol version which
95         # breaks preloading!
96         bld.SAMBA_LIBRARY('socket_wrapper',
97                           source='socket_wrapper.c',
98                           cflags='-D%s="%s" -D%s="%s"' % (
99                               "SOCKET_WRAPPER_PACKAGE",
100                               "samba_socket_wrapper",
101                               "SOCKET_WRAPPER_VERSION",
102                               VERSION),
103                           deps='dl pthread tirpc',
104                           install=False,
105                           realname='libsocket-wrapper.so')