build: Move nss_wrapper to third_party
[bbaumbach/samba-autobuild/.git] / lib / resolv_wrapper / wscript
1 #!/usr/bin/env python
2
3 import os
4
5 VERSION="1.1.4"
6
7 def configure(conf):
8     if conf.CHECK_BUNDLED_SYSTEM('resolv_wrapper', minversion=VERSION, set_target=False):
9         conf.DEFINE('USING_SYSTEM_RESOLV_WRAPPER', 1)
10         libresolv_wrapper_so_path = 'libresolv_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_ATTRIBUTE_PRINTF_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_ATTRIBUTE_PRINTF_FORMAT',
50             addmain=False,
51             msg='Checking for printf format validation support')
52
53         conf.CHECK_HEADERS('resolv.h')
54
55         conf.CHECK_STRUCTURE_MEMBER('struct _res_state',
56                                     '_u._ext.nsaddrs',
57                                     headers='resolv.h',
58                                     define='HAVE_RESOLV_IPV6_NSADDRS')
59
60         conf.CHECK_FUNCS_IN('res_ninit', 'resolv')
61         if conf.CONFIG_SET('HAVE_RES_NINIT'):
62             conf.DEFINE('HAVE_RES_NINIT_IN_LIBRESOLV', 1)
63
64         conf.CHECK_FUNCS_IN('res_nclose', 'resolv')
65         if conf.CONFIG_SET('HAVE_RES_NCLOSE'):
66             conf.DEFINE('HAVE_RES_NCLOSE_IN_LIBRESOLV', 1)
67
68         conf.CHECK_FUNCS_IN('res_init __res_init', 'resolv', checklibc=True)
69         conf.CHECK_FUNCS_IN('res_ninit __res_ninit', 'resolv', checklibc=True)
70         conf.CHECK_FUNCS_IN('res_close __res_close', 'resolv', checklibc=True)
71         conf.CHECK_FUNCS_IN('res_nclose __res_nclose', 'resolv', checklibc=True)
72         conf.CHECK_FUNCS_IN('res_query __res_query', 'resolv', checklibc=True)
73         conf.CHECK_FUNCS_IN('res_nquery __res_nquery', 'resolv', checklibc=True)
74         conf.CHECK_FUNCS_IN('res_search __res_search', 'resolv', checklibc=True)
75         conf.CHECK_FUNCS_IN('res_nsearch __res_nsearch', 'resolv', checklibc=True)
76
77         conf.CHECK_DECLS('ns_name_compress', headers='sys/types.h arpa/nameser.h')
78         if (conf.CONFIG_SET("HAVE_DECL_NS_NAME_COMPRESS")):
79             conf.DEFINE("HAVE_NS_NAME_COMPRESS", 1)
80
81         # Create full path to resolv_wrapper
82         blddir = os.path.realpath(conf.blddir)
83         libresolv_wrapper_so_path = blddir + '/default/lib/resolv_wrapper/libresolv-wrapper.so'
84
85     conf.DEFINE('LIBRESOLV_WRAPPER_SO_PATH', libresolv_wrapper_so_path)
86     conf.DEFINE('RESOLV_WRAPPER', 1)
87
88 def build(bld):
89     if bld.CONFIG_SET("HAVE_RESOLV_H") and not bld.CONFIG_SET("USING_SYSTEM_RESOLV_WRAPPER"):
90         # We need to do it this way or the library wont work.
91         # Using private_library=True will add symbol version which
92         # breaks preloading!
93         bld.SAMBA_LIBRARY('resolv_wrapper',
94                           source='resolv_wrapper.c',
95                           deps='dl resolv',
96                           install=False,
97                           realname='libresolv-wrapper.so')