fb9710636c429a079e18c81b437d6d60a0f1253b
[gd/samba-autobuild/.git] / third_party / nss_wrapper / wscript
1 #!/usr/bin/env python
2
3 import os
4
5 VERSION="1.1.5"
6
7 def configure(conf):
8     if conf.CHECK_NSS_WRAPPER():
9         conf.DEFINE('USING_SYSTEM_NSS_WRAPPER', 1)
10         libnss_wrapper_so_path = 'libnss_wrapper.so'
11     else:
12         conf.CHECK_HEADERS('nss.h')
13
14         if conf.CONFIG_SET("HAVE___THREAD"):
15             conf.DEFINE("HAVE_GCC_THREAD_LOCAL_STORAGE", 1)
16
17         # check HAVE_ATTRIBUTE_PRINTF_FORMAT
18         conf.CHECK_CODE('''
19             void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
20
21             int main(void) {
22                 return 0;
23             }
24             ''',
25             'HAVE_ATTRIBUTE_PRINTF_FORMAT',
26             addmain=False,
27             strict=True,
28             msg='Checking for printf format validation support')
29
30         conf.CHECK_FUNCS('gethostbyaddr_r gethostbyname_r')
31         # Solaris
32         conf.CHECK_FUNCS('__posix_getpwnam_r __posix_getpwuid_r')
33         conf.CHECK_FUNCS('__posix_getgrgid_r __posix_getgrnam_r')
34
35         conf.CHECK_FUNCS_IN('gethostname',
36                             'nsl',
37                             checklibc=True,
38                             headers='unistd.h')
39
40         # Prototype checks
41         conf.CHECK_C_PROTOTYPE('getpwent_r',
42                                'struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)',
43                                define='HAVE_SOLARIS_GETPWENT_R', headers='unistd.h pwd.h')
44         conf.CHECK_C_PROTOTYPE('getpwnam_r',
45                                'int getpwnam_r(const char *name, struct passwd *pwd, char *buf, int buflen, struct passwd **ppwd)',
46                                define='HAVE_SOLARIS_GETPWNAM_R', headers='unistd.h pwd.h')
47         conf.CHECK_C_PROTOTYPE('getpwuid_r',
48                                'int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, int buflen, struct passwd **ppwd)',
49                                define='HAVE_SOLARIS_GETPWUID_R', headers='unistd.h pwd.h')
50         conf.CHECK_C_PROTOTYPE('getgrent_r',
51                                'struct group *getgrent_r(struct group *src, char *buf, int buflen)',
52                                define='HAVE_SOLARIS_GETGRENT_R', headers='unistd.h grp.h')
53         conf.CHECK_C_PROTOTYPE('getgrnam_r',
54                                'int getgrnam_r(const char *name, struct group *grp, char *buf, int buflen, struct group **pgrp)',
55                                define='HAVE_SOLARIS_GETGRNAM_R', headers='unistd.h grp.h')
56         conf.CHECK_C_PROTOTYPE('getgrgid_r',
57                                'int getgrgid_r(gid_t gid, struct group *grp, char *buf, int buflen, struct group **pgrp)',
58                                define='HAVE_SOLARIS_GETGRGID_R', headers='unistd.h grp.h')
59         conf.CHECK_C_PROTOTYPE('sethostent',
60                                'int sethostent(int stayopen)',
61                                define='HAVE_SOLARIS_SETHOSTENT', headers='unistd.h netdb.h')
62         conf.CHECK_C_PROTOTYPE('endhostent',
63                                'int endhostent(void)',
64                                define='HAVE_SOLARIS_ENDHOSTENT', headers='unistd.h netdb.h')
65         conf.CHECK_C_PROTOTYPE('gethostname',
66                                'int gethostname(char *name, int len)',
67                                define='HAVE_SOLARIS_GETHOSTNAME', headers='unistd.h netdb.h')
68         conf.CHECK_C_PROTOTYPE('setgrent',
69                                'int setgrent(void)',
70                                define='HAVE_BSD_SETGRENT', headers='unistd.h grp.h')
71         conf.CHECK_C_PROTOTYPE('getnameinfo',
72                                'int getnameinfo (const struct sockaddr *sa, socklen_t salen, char *host, socklen_t __hostlen, char *serv, socklen_t servlen, int flags)',
73                                define='HAVE_LINUX_GETNAMEINFO', headers='unistd.h netdb.h')
74         conf.CHECK_C_PROTOTYPE('getnameinfo',
75                                'int getnameinfo (const struct sockaddr *sa, socklen_t salen, char *host, socklen_t __hostlen, char *serv, socklen_t servlen, unsigned int flags)',
76                                define='HAVE_LINUX_GETNAMEINFO_UNSIGNED', headers='unistd.h netdb.h')
77
78         # Create full path to nss_wrapper
79         blddir = os.path.realpath(conf.bldnode.abspath())
80         libnss_wrapper_so_path = blddir + '/default/third_party/nss_wrapper/libnss-wrapper.so'
81
82     conf.DEFINE('LIBNSS_WRAPPER_SO_PATH', libnss_wrapper_so_path)
83     conf.DEFINE('NSS_WRAPPER', 1)
84
85 def build(bld):
86     if bld.CONFIG_SET("HAVE_NSS_H") and not bld.CONFIG_SET("USING_SYSTEM_NSS_WRAPPER"):
87         # We need to do it this way or the library wont work.
88         # Using private_library=True will add symbol version which
89         # breaks preloading!
90         bld.SAMBA_LIBRARY('nss_wrapper',
91                           source='nss_wrapper.c',
92                           deps='dl',
93                           install=False,
94                           realname='libnss-wrapper.so')