2014-12-03 17:44:58 +03:00
#!/usr/bin/env python
import os
2021-10-07 16:55:37 +03:00
from waflib import Logs
2014-12-03 17:44:58 +03:00
2020-08-25 18:39:18 +03:00
VERSION="1.1.7"
2014-12-03 17:44:58 +03:00
def configure(conf):
2017-11-07 13:55:04 +03:00
if conf.CHECK_RESOLV_WRAPPER():
2014-12-03 17:44:58 +03:00
conf.DEFINE('USING_SYSTEM_RESOLV_WRAPPER', 1)
libresolv_wrapper_so_path = 'libresolv_wrapper.so'
else:
2018-07-18 09:54:22 +03:00
if conf.CONFIG_SET("HAVE___THREAD"):
conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)
2014-12-03 17:44:58 +03:00
2016-08-08 07:13:30 +03:00
# check HAVE_ATTRIBUTE_PRINTF_FORMAT
2014-12-03 17:44:58 +03:00
conf.CHECK_CODE('''
void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
int main(void) {
return 0;
}
''',
2016-08-08 07:13:30 +03:00
'HAVE_ATTRIBUTE_PRINTF_FORMAT',
2014-12-03 17:44:58 +03:00
addmain=False,
2018-07-03 07:45:24 +03:00
strict=True,
2014-12-03 17:44:58 +03:00
msg='Checking for printf format validation support')
conf.CHECK_HEADERS('resolv.h')
2019-01-25 17:12:46 +03:00
conf.CHECK_STRUCTURE_MEMBER('struct __res_state',
2014-12-03 17:44:58 +03:00
'_u._ext.nsaddrs',
2020-03-18 16:51:12 +03:00
headers='sys/socket.h netinet/in.h resolv.h',
define='HAVE_RES_STATE_U_EXT_NSADDRS')
conf.CHECK_STRUCTURE_MEMBER('union res_sockaddr_union',
'sin',
headers='sys/socket.h netinet/in.h resolv.h',
define='HAVE_RES_SOCKADDR_UNION_SIN')
conf.CHECK_STRUCTURE_MEMBER('union res_sockaddr_union',
'sin6',
headers='sys/socket.h netinet/in.h resolv.h',
define='HAVE_RES_SOCKADDR_UNION_SIN6')
2014-12-03 17:44:58 +03:00
conf.CHECK_FUNCS_IN('res_ninit', 'resolv')
if conf.CONFIG_SET('HAVE_RES_NINIT'):
conf.DEFINE('HAVE_RES_NINIT_IN_LIBRESOLV', 1)
conf.CHECK_FUNCS_IN('res_nclose', 'resolv')
if conf.CONFIG_SET('HAVE_RES_NCLOSE'):
conf.DEFINE('HAVE_RES_NCLOSE_IN_LIBRESOLV', 1)
2021-10-07 16:55:37 +03:00
# If we find res_nquery in libc, we can't do resolv.conf redirect
conf.CHECK_FUNCS('res_nquery __res_nquery')
if (conf.CONFIG_SET('HAVE_RES_NQUERY')
or conf.CONFIG_SET('HAVE___RES_NQUERY')):
Logs.warn("Detection for resolv_wrapper: "
"Only dns faking will be available")
else:
if conf.CHECK_FUNCS('res_nquery', lib='resolv'):
conf.DEFINE('HAVE_RESOLV_CONF_SUPPORT', 1)
if conf.CHECK_FUNCS('__res_nquery', lib='resolv'):
conf.DEFINE('HAVE_RESOLV_CONF_SUPPORT', 1)
2014-12-03 17:44:58 +03:00
conf.CHECK_FUNCS_IN('res_init __res_init', 'resolv', checklibc=True)
conf.CHECK_FUNCS_IN('res_ninit __res_ninit', 'resolv', checklibc=True)
conf.CHECK_FUNCS_IN('res_close __res_close', 'resolv', checklibc=True)
conf.CHECK_FUNCS_IN('res_nclose __res_nclose', 'resolv', checklibc=True)
conf.CHECK_FUNCS_IN('res_query __res_query', 'resolv', checklibc=True)
conf.CHECK_FUNCS_IN('res_nquery __res_nquery', 'resolv', checklibc=True)
conf.CHECK_FUNCS_IN('res_search __res_search', 'resolv', checklibc=True)
conf.CHECK_FUNCS_IN('res_nsearch __res_nsearch', 'resolv', checklibc=True)
2015-01-13 17:13:40 +03:00
conf.CHECK_DECLS('ns_name_compress', headers='sys/types.h arpa/nameser.h')
if (conf.CONFIG_SET("HAVE_DECL_NS_NAME_COMPRESS")):
conf.DEFINE("HAVE_NS_NAME_COMPRESS", 1)
2015-01-12 19:32:45 +03:00
2014-12-03 17:44:58 +03:00
# Create full path to resolv_wrapper
2018-02-02 17:34:33 +03:00
blddir = os.path.realpath(conf.bldnode.abspath())
2017-11-07 13:55:04 +03:00
libresolv_wrapper_so_path = blddir + '/default/third_party/resolv_wrapper/libresolv-wrapper.so'
2014-12-03 17:44:58 +03:00
conf.DEFINE('LIBRESOLV_WRAPPER_SO_PATH', libresolv_wrapper_so_path)
conf.DEFINE('RESOLV_WRAPPER', 1)
def build(bld):
if bld.CONFIG_SET("HAVE_RESOLV_H") and not bld.CONFIG_SET("USING_SYSTEM_RESOLV_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('resolv_wrapper',
source='resolv_wrapper.c',
deps='dl resolv',
install=False,
realname='libresolv-wrapper.so')