2010-03-28 01:48:49 +03:00
#!/usr/bin/env python
2014-04-07 18:12:21 +04:00
import os
2010-03-07 15:48:57 +03:00
2016-05-20 11:20:28 +03:00
VERSION="1.1.7"
2010-03-07 15:48:57 +03:00
def configure(conf):
2014-04-07 18:12:21 +04:00
if conf.CHECK_BUNDLED_SYSTEM('socket_wrapper', minversion=VERSION, set_target=False):
conf.DEFINE('USING_SYSTEM_SOCKET_WRAPPER', 1)
libsocket_wrapper_so_path = 'libsocket_wrapper.so'
else:
# check HAVE_GCC_THREAD_LOCAL_STORAGE
conf.CHECK_CODE('''
__thread int tls;
2010-03-07 15:48:57 +03:00
2014-04-07 18:12:21 +04:00
int main(void) {
return 0;
}
''',
'HAVE_GCC_THREAD_LOCAL_STORAGE',
addmain=False,
msg='Checking for thread local storage')
# check HAVE_DESTRUCTOR_ATTRIBUTE
conf.CHECK_CODE('''
void test_destructor_attribute(void) __attribute__ ((destructor));
void test_destructor_attribute(void)
{
return;
}
int main(void) {
return 0;
}
''',
'HAVE_DESTRUCTOR_ATTRIBUTE',
addmain=False,
msg='Checking for library destructor support')
2014-07-31 12:22:10 +04:00
# check HAVE_FUNCTION_ATTRIBUTE_FORMAT
conf.CHECK_CODE('''
void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int main(void) {
return 0;
}
''',
'HAVE_FUNCTION_ATTRIBUTE_FORMAT',
addmain=False,
msg='Checking for printf format validation support')
2014-04-07 18:12:21 +04:00
conf.CHECK_HEADERS('sys/signalfd.h')
conf.CHECK_HEADERS('sys/eventfd.h')
conf.CHECK_HEADERS('sys/timerfd.h')
2014-06-03 16:50:05 +04:00
conf.CHECK_HEADERS('gnu/lib-names.h')
2014-06-03 17:11:46 +04:00
conf.CHECK_HEADERS('rpc/rpc.h')
2014-04-07 18:12:21 +04:00
conf.CHECK_STRUCTURE_MEMBER('struct msghdr',
'msg_control',
headers='sys/types.h sys/socket.h',
define='HAVE_STRUCT_MSGHDR_MSG_CONTROL')
2014-06-03 17:01:34 +04:00
conf.CHECK_STRUCTURE_MEMBER('struct in_pktinfo',
'ipi_addr',
headers='sys/types.h sys/socket.h netinet/in.h',
define='HAVE_STRUCT_IN_PKTINFO')
2014-06-03 16:53:19 +04:00
conf.CHECK_STRUCTURE_MEMBER('struct in6_pktinfo',
'ipi6_addr',
headers='sys/types.h sys/socket.h netinet/in.h',
define='HAVE_STRUCT_IN6_PKTINFO')
2014-04-07 18:12:21 +04:00
conf.CHECK_FUNCS('getaddrinfo')
conf.CHECK_FUNCS('signalfd eventfd timerfd_create')
2014-06-03 17:10:19 +04:00
conf.CHECK_FUNCS('bindresvport')
2016-05-20 11:20:28 +03:00
conf.CHECK_FUNCS('pledge')
conf.CHECK_FUNCS('accept4')
2014-04-07 18:12:21 +04:00
conf.CHECK_FUNCS_IN('bind',
'socket',
checklibc=True,
headers='sys/types.h sys/socket.h')
conf.CHECK_C_PROTOTYPE('accept',
'int accept(int s, struct sockaddr *addr, Psocklen_t addrlen)',
define='HAVE_ACCEPT_PSOCKLEN_T', headers='sys/types.h sys/socket.h')
conf.CHECK_C_PROTOTYPE('ioctl',
'int ioctl(int s, int r, ...)',
define='HAVE_IOCTL_INT', headers='unistd.h sys/ioctl.h')
2014-11-26 12:18:34 +03:00
if conf.CONFIG_SET("HAVE_EVENTFD"):
conf.CHECK_C_PROTOTYPE('eventfd',
'int eventfd(unsigned int count, int flags)',
define='HAVE_EVENTFD_UNSIGNED_INT', headers='sys/eventfd.h')
2014-04-07 18:12:21 +04:00
# Create full path to socket_wrapper
2016-07-08 16:37:18 +03:00
blddir = os.path.realpath(conf.blddir)
libsocket_wrapper_so_path = blddir + '/default/lib/socket_wrapper/libsocket-wrapper.so'
2014-04-07 18:12:21 +04:00
conf.DEFINE('LIBSOCKET_WRAPPER_SO_PATH', libsocket_wrapper_so_path)
conf.DEFINE('SOCKET_WRAPPER', 1)
def build(bld):
if not bld.CONFIG_SET("USING_SYSTEM_SOCKET_WRAPPER"):
# We need to do it this way or the library wont work.
# Using private_library=True will add symbol version which
# breaks preloading!
bld.SAMBA_LIBRARY('socket_wrapper',
source='socket_wrapper.c',
deps='dl',
install=False,
realname='libsocket-wrapper.so')