2010-03-28 01:48:49 +03:00
#!/usr/bin/env python
2015-01-23 17:22:18 +03:00
import Options
2014-01-17 17:43:01 +04:00
import os
2010-03-07 15:48:57 +03:00
2014-01-17 17:43:01 +04:00
VERSION="1.0.1"
2010-03-07 15:48:57 +03:00
def configure(conf):
2014-01-17 17:43:01 +04:00
if conf.CHECK_BUNDLED_SYSTEM('uid_wrapper', minversion=VERSION, set_target=False):
conf.DEFINE('USING_SYSTEM_UID_WRAPPER', 1)
libuid_wrapper_so_path = 'libuid_wrapper.so'
else:
2015-01-23 17:15:04 +03:00
# check HAVE_GCC_ATOMIC_BUILTINS
conf.CHECK_CODE('''
#include <stdbool.h>
int main(void) {
bool x;
bool *p_x = &x;
__atomic_load(p_x, &x, __ATOMIC_RELAXED);
return 0;
''',
'HAVE_GCC_ATOMIC_BUILTINS',
addmain=False,
msg='Checking for atomic builtins')
2014-01-17 17:43:01 +04:00
# check HAVE_GCC_THREAD_LOCAL_STORAGE
conf.CHECK_CODE('''
__thread int tls;
int main(void) {
return 0;
}
''',
'HAVE_GCC_THREAD_LOCAL_STORAGE',
addmain=False,
msg='Checking for thread local storage')
2015-01-23 17:10:02 +03:00
# check HAVE_CONSTRUCTOR_ATTRIBUTE
conf.CHECK_CODE('''
void test_constructor_attribute(void) __attribute__ ((constructor));
void test_constructor_attribute(void)
{
return;
}
int main(void) {
return 0;
}
''',
'HAVE_CONSTRUCTOR_ATTRIBUTE',
addmain=False,
msg='Checking for library constructor support')
2014-01-17 17:43:01 +04:00
# 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')
2015-01-23 17:22:18 +03:00
if Options.options.address_sanitizer:
# check HAVE_ADDRESS_SANITIZER_ATTRIBUTE
conf.CHECK_CODE('''
void test_address_sanitizer_attribute(void) __attribute__((no_sanitize_address));
void test_address_sanitizer_attribute(void)
{
return;
}
int main(void) {
return 0;
}
''',
'HAVE_ADDRESS_SANITIZER_ATTRIBUTE',
addmain=False,
cflags='-Wall -Wextra -Werror',
msg='Checking for address sanitizer attribute')
2014-07-31 12:18:13 +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-10-04 04:18:34 +04:00
# Prototype checks
conf.CHECK_C_PROTOTYPE('setgroups',
'int setgroups(int ngroups, const gid_t *grouplist)',
define='HAVE_SETGROUPS_INT', headers='unistd.h sys/types.h')
conf.CHECK_C_PROTOTYPE('syscall',
'int syscall(int number, ...)',
define='HAVE_SYSCALL_INT', headers='unistd.h sys/syscall.h')
2014-07-31 12:18:13 +04:00
2014-01-17 17:43:01 +04:00
# Create full path to uid_wrapper
srcdir = os.path.realpath(conf.srcdir)
libuid_wrapper_so_path = srcdir + '/bin/default/lib/uid_wrapper/libuid-wrapper.so'
conf.DEFINE('LIBUID_WRAPPER_SO_PATH', libuid_wrapper_so_path)
conf.DEFINE('UID_WRAPPER', 1)
def build(bld):
if not bld.CONFIG_SET("USING_SYSTEM_UID_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('uid_wrapper',
source='uid_wrapper.c',
cflags='-DNDEBUG',
deps='dl',
install=False,
realname='libuid-wrapper.so')
2010-03-07 15:48:57 +03:00