build: Check for kernel share modes
[kamenim/samba.git] / source3 / wscript
1 #! /usr/bin/env python
2
3 srcdir = '..'
4 blddir = 'bin'
5
6 import sys, os
7 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
8 import wafsamba, Options
9
10 def set_options(opt):
11     opt.recurse('../lib/replace')
12     opt.recurse('../lib/nss_wrapper')
13     opt.recurse('../lib/socket_wrapper')
14     opt.recurse('../lib/uid_wrapper')
15
16 def configure(conf):
17     conf.define('PACKAGE_NAME', 'samba')
18     conf.define('PACKAGE_STRING', 'samba 3')
19     conf.define('PACKAGE_TARNAME', 'samba')
20     conf.define('PACKAGE_URL', '')
21     conf.define('PACKAGE_VERSION', '3')
22     conf.define('PACKAGE_BUGREPORT', 'samba-technical@samba.org')
23
24     conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
25     conf.DEFINE('_SAMBA_BUILD_', 3, add_to_cflags=True)
26     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
27     if Options.options.developer:
28         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
29
30     # set a limit on recursing in the waf preprocessor
31     conf.env.preprocessor_recursion_limit = 10
32
33     conf.ADD_EXTRA_INCLUDES('#source3 #source3/include #lib/replace #lib/talloc #lib/tevent #source3/libaddns #source3/librpc')
34
35     conf.sub_config('../lib/replace')
36     conf.sub_config('../lib/nss_wrapper')
37     conf.sub_config('../lib/socket_wrapper')
38     conf.sub_config('../lib/uid_wrapper')
39
40     conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h')
41
42     # Check for inotify support
43     conf.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h', add_headers=False)
44     conf.CHECK_FUNCS('inotify_init')
45     if "HAVE_LINUX_INOTIFY_H" in conf.env and "HAVE_INOTIFY_INIT" in conf.env:
46         conf.DEFINE('HAVE_INOTIFY', 1)
47
48     # Check for kernel change notify support
49     conf.CHECK_CODE('''
50 #include <sys/types.h>
51 #include <fcntl.h>
52 #include <signal.h>
53 #ifndef F_NOTIFY
54 #define F_NOTIFY 1026
55 #endif
56 main() {
57         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
58 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
59         msg="Checking for kernel change notify support")
60
61     # Check for Linux kernel oplocks
62     conf.CHECK_CODE('''
63 #include <sys/types.h>
64 #include <fcntl.h>
65 #include <signal.h>
66 #ifndef F_NOTIFY
67 #define F_NOTIFY 1026
68 #endif
69 main() {
70         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
71 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
72         msg="Checking for Linux kernel oplocks")
73
74     # Check for IRIX kernel oplock types
75     conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
76                     'HAVE_KERNEL_OPLOCKS_IRIX', headers='sys/types.h fcntl.h',
77                     msg="Checking for IRIX kernel oplock types")
78
79     # Check for krenel share modes
80     conf.CHECK_CODE('''
81 #include <sys/types.h>
82 #include <fcntl.h>
83 #include <signal.h>
84 #include <sys/file.h>
85 #ifndef LOCK_MAND
86 #define LOCK_MAND       32
87 #define LOCK_READ       64
88 #endif
89 main() {
90         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
91 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
92         msg="Checking for krenel share modes")
93
94     # Look for CUPS
95     conf.find_program('cups-config', var='CUPS_CONFIG')
96     if conf.env.CUPS_CONFIG:
97         conf.check_cfg(path="cups-config", args="--cflags --ldflags --libs", package="", uselib_store="CUPS")
98         conf.CHECK_HEADERS('cups/cups.h cups/language.h', add_headers=False)
99
100     # Check for LDAP
101     conf.CHECK_HEADERS('ldap.h lber.h')
102     conf.CHECK_TYPE('ber_tag_t', 'unsigned int')
103
104     # Check for kerberos
105     conf.find_program('krb5-config', var='KRB5_CONFIG')
106     if conf.env.KRB5_CONFIG:
107         conf.check_cfg(path="krb5-config", args="--cflags --libs",
108                        package="gssapi", uselib_store="KRB5")
109         conf.CHECK_HEADERS('krb5.h krb5/locate_plugin.h')
110         conf.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h')
111
112     conf.SAMBA_CONFIG_H('include/config.h')