summaryrefslogtreecommitdiff
path: root/third_party/nss_wrapper/wscript
blob: fb9710636c429a079e18c81b437d6d60a0f1253b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python

import os

VERSION="1.1.5"

def configure(conf):
    if conf.CHECK_NSS_WRAPPER():
        conf.DEFINE('USING_SYSTEM_NSS_WRAPPER', 1)
        libnss_wrapper_so_path = 'libnss_wrapper.so'
    else:
        conf.CHECK_HEADERS('nss.h')

        if conf.CONFIG_SET("HAVE___THREAD"):
            conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)

        # check HAVE_ATTRIBUTE_PRINTF_FORMAT
        conf.CHECK_CODE('''
            void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));

            int main(void) {
                return 0;
            }
            ''',
            'HAVE_ATTRIBUTE_PRINTF_FORMAT',
            addmain=False,
            strict=True,
            msg='Checking for printf format validation support')

        conf.CHECK_FUNCS('gethostbyaddr_r gethostbyname_r')
        # Solaris
        conf.CHECK_FUNCS('__posix_getpwnam_r __posix_getpwuid_r')
        conf.CHECK_FUNCS('__posix_getgrgid_r __posix_getgrnam_r')

        conf.CHECK_FUNCS_IN('gethostname',
                            'nsl',
                            checklibc=True,
                            headers='unistd.h')

        # Prototype checks
        conf.CHECK_C_PROTOTYPE('getpwent_r',
                               'struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)',
                               define='HAVE_SOLARIS_GETPWENT_R', headers='unistd.h pwd.h')
        conf.CHECK_C_PROTOTYPE('getpwnam_r',
                               'int getpwnam_r(const char *name, struct passwd *pwd, char *buf, int buflen, struct passwd **ppwd)',
                               define='HAVE_SOLARIS_GETPWNAM_R', headers='unistd.h pwd.h')
        conf.CHECK_C_PROTOTYPE('getpwuid_r',
                               'int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, int buflen, struct passwd **ppwd)',
                               define='HAVE_SOLARIS_GETPWUID_R', headers='unistd.h pwd.h')
        conf.CHECK_C_PROTOTYPE('getgrent_r',
                               'struct group *getgrent_r(struct group *src, char *buf, int buflen)',
                               define='HAVE_SOLARIS_GETGRENT_R', headers='unistd.h grp.h')
        conf.CHECK_C_PROTOTYPE('getgrnam_r',
                               'int getgrnam_r(const char *name, struct group *grp, char *buf, int buflen, struct group **pgrp)',
                               define='HAVE_SOLARIS_GETGRNAM_R', headers='unistd.h grp.h')
        conf.CHECK_C_PROTOTYPE('getgrgid_r',
                               'int getgrgid_r(gid_t gid, struct group *grp, char *buf, int buflen, struct group **pgrp)',
                               define='HAVE_SOLARIS_GETGRGID_R', headers='unistd.h grp.h')
        conf.CHECK_C_PROTOTYPE('sethostent',
                               'int sethostent(int stayopen)',
                               define='HAVE_SOLARIS_SETHOSTENT', headers='unistd.h netdb.h')
        conf.CHECK_C_PROTOTYPE('endhostent',
                               'int endhostent(void)',
                               define='HAVE_SOLARIS_ENDHOSTENT', headers='unistd.h netdb.h')
        conf.CHECK_C_PROTOTYPE('gethostname',
                               'int gethostname(char *name, int len)',
                               define='HAVE_SOLARIS_GETHOSTNAME', headers='unistd.h netdb.h')
        conf.CHECK_C_PROTOTYPE('setgrent',
                               'int setgrent(void)',
                               define='HAVE_BSD_SETGRENT', headers='unistd.h grp.h')
        conf.CHECK_C_PROTOTYPE('getnameinfo',
                               'int getnameinfo (const struct sockaddr *sa, socklen_t salen, char *host, socklen_t __hostlen, char *serv, socklen_t servlen, int flags)',
                               define='HAVE_LINUX_GETNAMEINFO', headers='unistd.h netdb.h')
        conf.CHECK_C_PROTOTYPE('getnameinfo',
                               'int getnameinfo (const struct sockaddr *sa, socklen_t salen, char *host, socklen_t __hostlen, char *serv, socklen_t servlen, unsigned int flags)',
                               define='HAVE_LINUX_GETNAMEINFO_UNSIGNED', headers='unistd.h netdb.h')

        # Create full path to nss_wrapper
        blddir = os.path.realpath(conf.bldnode.abspath())
        libnss_wrapper_so_path = blddir + '/default/third_party/nss_wrapper/libnss-wrapper.so'

    conf.DEFINE('LIBNSS_WRAPPER_SO_PATH', libnss_wrapper_so_path)
    conf.DEFINE('NSS_WRAPPER', 1)

def build(bld):
    if bld.CONFIG_SET("HAVE_NSS_H") and not bld.CONFIG_SET("USING_SYSTEM_NSS_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('nss_wrapper',
                          source='nss_wrapper.c',
                          deps='dl',
                          install=False,
                          realname='libnss-wrapper.so')