s3-waf: Add dummy configuration options for quotas
[Samba/gebeck_regimport.git] / source3 / wscript
blobf4b5a907637736998b77e407dc778a42df5022ab
1 #! /usr/bin/env python
3 srcdir = '..'
4 blddir = 'bin'
6 import sys, os
7 from optparse import SUPPRESS_HELP
8 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
9 import wafsamba, Options
10 import build.charset
11 from samba_utils import *
12 from samba3 import *
14 def set_options(opt):
15 opt.BUILTIN_DEFAULT('NONE')
16 opt.BUNDLED_EXTENSION_DEFAULT('s3')
17 opt.RECURSE('../lib/replace')
18 opt.RECURSE('build')
19 opt.RECURSE('../lib/nss_wrapper')
20 opt.RECURSE('../lib/socket_wrapper')
21 opt.RECURSE('../lib/tevent')
22 opt.RECURSE('../lib/tdb')
24 opt.add_option('--with-static-modules',
25 help=("Comma-separated list of names of modules to statically link in"),
26 action="store", dest='static_modules', default='')
27 opt.add_option('--with-shared-modules',
28 help=("Comma-separated list of names of modules to build shared"),
29 action="store", dest='shared_modules', default='')
30 opt.add_option('--enable-selftest',
31 help=("enable options necessary for selftest"),
32 action="store_true", dest='enable_selftest', default=False)
34 opt.SAMBA3_ADD_OPTION('winbind')
35 opt.SAMBA3_ADD_OPTION('ads')
36 opt.SAMBA3_ADD_OPTION('krb5')
37 opt.SAMBA3_ADD_OPTION('ldap')
38 opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
39 opt.SAMBA3_ADD_OPTION('merged-build', with_name="enable", without_name="disable")
40 opt.SAMBA3_ADD_OPTION('pam')
41 opt.SAMBA3_ADD_OPTION('quotas')
42 opt.SAMBA3_ADD_OPTION('sys-quotas')
45 def configure(conf):
46 conf.define('PACKAGE_NAME', 'Samba')
47 conf.define('PACKAGE_STRING', 'Samba 3')
48 conf.define('PACKAGE_TARNAME', 'samba')
49 conf.define('PACKAGE_URL', '')
50 conf.define('PACKAGE_VERSION', '3')
51 conf.define('PACKAGE_BUGREPORT', 'samba-technical@samba.org')
53 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
54 conf.DEFINE('_SAMBA_BUILD_', 3, add_to_cflags=True)
55 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
56 if Options.options.developer:
57 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
59 # set a limit on recursing in the waf preprocessor
60 conf.env.preprocessor_recursion_limit = 10
62 conf.ADD_EXTRA_INCLUDES('#source3 #source3/include #lib/replace #lib/talloc #lib/tevent #source3/libaddns #source3/librpc')
64 conf.RECURSE('../lib/replace')
65 conf.RECURSE('build')
66 conf.RECURSE('../lib/tdb')
67 conf.RECURSE('../lib/talloc')
68 conf.RECURSE('../lib/tevent')
69 conf.RECURSE('../lib/popt')
70 conf.RECURSE('../lib/nss_wrapper')
71 conf.RECURSE('../lib/socket_wrapper')
72 conf.RECURSE('../lib/zlib')
74 conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h')
76 conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
77 conf.CHECK_FUNCS('strtol strchr strupr chflags')
78 conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
79 conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
80 conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent')
81 conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
82 conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf stat64 fstat64')
83 conf.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64')
84 conf.CHECK_FUNCS('fseek64 fseeko64 ftell64 ftello64 setluid')
85 conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
86 conf.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
87 conf.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
88 conf.CHECK_FUNCS('syslog vsyslog timegm setlocale nl_langinfo')
89 conf.CHECK_FUNCS_IN('nanosleep', 'rt')
90 conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
91 conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
92 conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
93 conf.CHECK_FUNCS('shmget')
94 conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
95 conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain')
96 #FIXME: for some reason this one still fails
97 conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
98 conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
100 # Check for inotify support
101 conf.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
102 conf.CHECK_FUNCS('inotify_init')
103 if "HAVE_LINUX_INOTIFY_H" in conf.env and "HAVE_INOTIFY_INIT" in conf.env:
104 conf.DEFINE('HAVE_INOTIFY', 1)
106 # Check for kernel change notify support
107 conf.CHECK_CODE('''
108 #ifndef F_NOTIFY
109 #define F_NOTIFY 1026
110 #endif
111 main() {
112 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
113 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
114 headers='fcntl.h signal.h',
115 msg="Checking for kernel change notify support")
117 # Check for Linux kernel oplocks
118 conf.CHECK_CODE('''
119 #include <sys/types.h>
120 #include <fcntl.h>
121 #include <signal.h>
122 #ifndef F_NOTIFY
123 #define F_NOTIFY 1026
124 #endif
125 main() {
126 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
127 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
128 msg="Checking for Linux kernel oplocks")
130 # Check for IRIX kernel oplock types
131 conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
132 'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
133 msg="Checking for IRIX kernel oplock types")
135 # Check for krenel share modes
136 conf.CHECK_CODE('''
137 #include <sys/types.h>
138 #include <fcntl.h>
139 #include <signal.h>
140 #include <sys/file.h>
141 #ifndef LOCK_MAND
142 #define LOCK_MAND 32
143 #define LOCK_READ 64
144 #endif
145 main() {
146 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
147 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
148 msg="Checking for krenel share modes")
150 # Check for various members of the stat structure
151 conf.CHECK_TYPES('blksize_t blkcnt_t')
152 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
153 headers='sys/stat.h')
154 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
155 headers='sys/stat.h')
157 # Check for POSIX capability support
158 conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
160 if "HAVE_SYS_CAPABILITY_H" in conf.env:
161 conf.CHECK_CODE('''
162 cap_t cap;
163 cap_value_t vals[1];
164 if (!(cap = cap_get_proc())) exit(1);
165 vals[0] = CAP_CHOWN;
166 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
167 cap_set_proc(cap);''',
168 'HAVE_POSIX_CAPABILITIES', execute=True, lib="cap",
169 headers='sys/capability.h',
170 msg="Checking whether POSIX capabilities are available")
172 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
173 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
174 # -- JRA.
175 if conf.CONFIG_SET("HAVE_RPC_RPC_H"):
176 conf.CHECK_TYPE('int16', headers='rpc/rpc.h',
177 define='HAVE_INT16_FROM_RPC_RPC_H',
178 msg="Checking for int16 typedef included by rpc/rpc.h")
179 conf.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
180 headers='sys/types.h rpc/rpc.h',
181 msg="Checking for uint16 typedef included by rpc/rpc.h")
182 conf.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
183 headers='sys/types.h rpc/rpc.h',
184 msg="Checking for int32 typedef included by rpc/rpc.h")
185 conf.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
186 headers='sys/types.h rpc/rpc.h',
187 msg="Checking for uint32 typedef included by rpc/rpc.h")
189 # Check if the compiler will optimize out functions
190 conf.CHECK_CODE('''
191 if (0) {
192 this_function_does_not_exist();
193 } else {
194 return 1;
195 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
196 msg="Checking if the compiler will optimize out functions")
198 conf.CHECK_FUNCS('''
199 _acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
200 attropen attr_remove attr_removef attr_set attr_setf backtrace_symbols
201 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
202 __closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
203 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent endnetgrent execl
204 extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
205 extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
206 extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
207 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
208 fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
209 _fork __fork fremoveea fremovexattr fseek64 fseeko64 fsetea
210 fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
211 ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
212 getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
213 getgrent getgrnam getgrouplist getmntent getnetgrent getpagesize
214 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
215 getutmpx getutxent glob grantpt hstrerror initgroups innetgr
216 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
217 llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
218 lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
219 __lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
220 nl_langinfo _open __open open64 _open64 __open64 _opendir __opendir
221 opendir64 pathconf poll posix_fallocate posix_fallocate64
222 posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
223 pututline pututxline pwrite _pwrite __pwrite pwrite64 _pwrite64
224 __pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
225 __readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
226 seekdir64 select setea setenv setgidx setgroups setlocale setluid
227 setmntent setnetgrent setpgid setpriv setproplist setsid setuidx
228 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
229 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
230 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
231 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
232 updwtmp updwtmpx utimensat vsyslog _write __write __xstat
233 ''')
235 conf.CHECK_TYPE('struct timespec', headers='sys/time.h time.h')
237 conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
240 default_static_modules=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam rpc_lsarpc rpc_samr
241 rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl
242 rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss
243 rpc_eventlog auth_sam auth_unix auth_winbind auth_wbc auth_server
244 auth_domain auth_builtin auth_netlogond vfs_default
245 nss_info_template''')
247 default_shared_modules=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
248 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
249 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850
250 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb
251 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
252 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
253 vfs_crossrename''')
255 if Options.options.developer:
256 default_static_modules.extend(TO_LIST('rpc_rpcecho pdb_ads'))
257 default_shared_modules.extend(TO_LIST('charset_weird perfcount_test'))
259 move_to_shared = TO_LIST(Options.options.shared_modules)
260 move_to_static = TO_LIST(Options.options.static_modules)
262 for m in move_to_static:
263 if m in default_shared_modules:
264 default_shared_modules.remove(m)
265 default_static_modules.append(m)
266 for m in move_to_shared:
267 if m in default_static_modules:
268 default_static_modules.remove(m)
269 default_shared_modules.append(m)
271 conf.DEFINE('STRING_STATIC_MODULES', ' '.join(default_static_modules), quote=True)
273 static_list = {}
275 prefixes = ['vfs', 'pdb', 'rpc', 'auth', 'nss_info', 'charset', 'idmap']
276 for p in prefixes:
277 for m in default_static_modules:
278 if m.find(p) == 0:
279 if not p in static_list:
280 static_list[p] = []
281 static_list[p].append(m)
283 for p in prefixes:
284 conf.env['%s_STATIC' % p.upper()] = ''
285 conf.env['%s_SHARED' % p.upper()] = ''
286 if p in static_list:
287 conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
288 else:
289 conf.DEFINE('static_init_%s' % p, '{}')
291 if Options.options.with_winbind:
292 conf.DEFINE('WITH_WINBIND', '1')
294 #FIXME: Should just be set when krb5 and ldap requirements are fulfilled
295 if Options.options.with_ads:
296 conf.DEFINE('WITH_ADS', '1')
298 # Look for CUPS
299 conf.find_program('cups-config', var='CUPS_CONFIG')
300 if conf.env.CUPS_CONFIG and Options.options.with_cups:
301 conf.check_cfg(path="cups-config", args="--cflags --ldflags --libs",
302 package="", uselib_store="cups")
303 conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
304 conf.CHECK_LIB('cups')
305 else:
306 # define an empty subsystem for cups, to allow it to be used as an empty dependency
307 conf.SET_TARGET_TYPE('cups', 'EMPTY')
309 # Check for LDAP
310 if Options.options.with_ldap:
311 conf.CHECK_HEADERS('ldap.h lber.h')
312 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
313 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
314 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
315 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
316 # SASL wrapping hooks
317 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
318 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
319 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
321 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
322 # for the samba logs
323 conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
324 define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
326 conf.CHECK_FUNCS_IN('ldap_init ldap_initialize ldap_set_rebind_proc', 'ldap')
327 conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
329 # Check if ldap_set_rebind_proc() takes three arguments
330 if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
331 'LDAP_SET_REBIND_PROC_ARGS',
332 msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
333 headers='ldap.h lber.h', link=False):
334 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
335 else:
336 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
338 # last but not least, if ldap_init() exists, we want to use ldap
339 if conf.CONFIG_SET('HAVE_LDAP_INIT'):
340 conf.DEFINE('HAVE_LDAP', '1')
341 conf.DEFINE('LDAP_DEPRECATED', '1')
342 conf.env['SMBLDAP'] = 'lib/smbldap.c'
343 conf.env['SMBLDAPUTIL'] = 'lib/smbldap_util.c'
344 else:
345 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
346 conf.SET_TARGET_TYPE('lber', 'EMPTY')
348 # Check for kerberos
349 conf.find_program('krb5-config', var='KRB5_CONFIG')
350 if conf.env.KRB5_CONFIG and Options.options.with_krb5:
351 conf.check_cfg(path="krb5-config", args="--cflags --libs",
352 package="gssapi", uselib_store="krb5")
353 conf.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib='krb5')
354 conf.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h', lib='krb5')
356 if conf.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
357 conf.env['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
359 conf.CHECK_FUNCS_IN('_et_list', 'com_err')
360 conf.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
361 conf.CHECK_FUNCS_IN('crypto', 'des_set_key')
362 conf.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
363 conf.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
364 conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi gssapi_krb5')
365 conf.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
366 conf.CHECK_FUNCS('''
367 krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
368 krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
369 krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
370 krb5_auth_con_setuseruserkey krb5_locate_kdc krb5_get_permitted_enctypes
371 krb5_get_default_in_tkt_etypes krb5_free_data_contents
372 krb5_principal_get_comp_string krb5_free_unparsed_name
373 krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
374 krb5_krbhst_get_addrinfo krb5_c_enctype_compare krb5_enctypes_compatible_keys
375 krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
376 krb5_verify_checksum krb5_c_verify_checksum krb5_principal_compare_any_realm
377 krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
378 krb5_get_renewed_creds krb5_get_kdc_cred krb5_free_error_contents
379 initialize_krb5_error_table krb5_get_init_creds_opt_alloc
380 krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
381 krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
382 krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
383 krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
384 lib='krb5')
385 conf.CHECK_DECLS('''krb5_get_credentials_for_user
386 krb5_auth_con_set_req_cksumtype''',
387 headers='krb5.h', always=True)
388 else:
389 conf.SET_TARGET_TYPE('krb5', 'EMPTY')
390 conf.SET_TARGET_TYPE('gssapi', 'EMPTY')
391 conf.SET_TARGET_TYPE('gssapi_krb5', 'EMPTY')
393 conf.SAMBA_CONFIG_H('include/config.h')
395 def ctags(ctx):
396 "build 'tags' file using ctags"
397 import Utils
398 source_root = os.path.dirname(Utils.g_module.root_path)
399 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
400 print("Running: %s" % cmd)
401 os.system(cmd)