s3-waf: Fix typo
[ira/wip.git] / source3 / wscript
1 #! /usr/bin/env python
2
3 srcdir = '..'
4 blddir = 'bin'
5
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 import samba_utils
12 import samba3
13
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')
23
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)
33
34     opt.SAMBA3_ADD_OPTION('winbind')
35     opt.SAMBA3_ADD_OPTION('swat')
36     opt.SAMBA3_ADD_OPTION('ads')
37     opt.SAMBA3_ADD_OPTION('krb5')
38     opt.SAMBA3_ADD_OPTION('ldap')
39     opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
40     opt.SAMBA3_ADD_OPTION('merged-build', with_name="enable", without_name="disable")
41     opt.SAMBA3_ADD_OPTION('pam')
42     opt.SAMBA3_ADD_OPTION('quotas')
43     opt.SAMBA3_ADD_OPTION('sys-quotas')
44     opt.SAMBA3_ADD_OPTION('sendfile-support')
45     opt.SAMBA3_ADD_OPTION('utmp')
46     opt.SAMBA3_ADD_OPTION('pthreadpool', with_name="enable", without_name="disable")
47
48
49 def configure(conf):
50     from samba_utils import TO_LIST
51
52     conf.define('PACKAGE_NAME', 'Samba')
53     conf.define('PACKAGE_STRING', 'Samba 3')
54     conf.define('PACKAGE_TARNAME', 'samba')
55     conf.define('PACKAGE_URL', '')
56     conf.define('PACKAGE_VERSION', '3')
57     conf.define('PACKAGE_BUGREPORT', 'samba-technical@samba.org')
58
59     conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
60     conf.DEFINE('_SAMBA_BUILD_', 3, add_to_cflags=True)
61     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
62     if Options.options.developer:
63         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
64         conf.env['developer'] = True
65
66     if Options.options.with_swat:
67         conf.env['build_swat'] = True
68
69     # set a limit on recursing in the waf preprocessor
70     conf.env.preprocessor_recursion_limit = 10
71
72     conf.ADD_EXTRA_INCLUDES('''#source3 #source3/include #lib/replace #lib/talloc
73                                #lib/tevent #source3/libaddns #source3/librpc
74                                #source3/lib #lib/tdb/include #lib/popt #source4''')
75
76     conf.RECURSE('../lib/replace')
77     conf.RECURSE('build')
78     conf.RECURSE('../lib/tdb')
79     conf.RECURSE('../lib/talloc')
80     conf.RECURSE('../lib/tevent')
81     conf.RECURSE('../lib/popt')
82     conf.RECURSE('../lib/nss_wrapper')
83     conf.RECURSE('../lib/socket_wrapper')
84     conf.RECURSE('../lib/zlib')
85
86     conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h')
87
88     conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
89     conf.CHECK_FUNCS('strtol strchr strupr chflags')
90     conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
91     conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
92     conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent')
93     conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
94     conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf stat64 fstat64')
95     conf.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64')
96     conf.CHECK_FUNCS('fseek64 fseeko64 ftell64 ftello64 setluid')
97     conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
98     conf.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
99     conf.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
100     conf.CHECK_FUNCS('syslog vsyslog timegm setlocale nl_langinfo')
101     conf.CHECK_FUNCS_IN('nanosleep', 'rt')
102     conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
103     conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
104     conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
105     conf.CHECK_FUNCS('shmget')
106     conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
107     conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain')
108     #FIXME: for some reason this one still fails
109     conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
110     conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
111
112     # Check for inotify support
113     conf.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
114     conf.CHECK_FUNCS('inotify_init')
115     if "HAVE_LINUX_INOTIFY_H" in conf.env and "HAVE_INOTIFY_INIT" in conf.env:
116         conf.DEFINE('HAVE_INOTIFY', 1)
117
118     # Check for kernel change notify support
119     conf.CHECK_CODE('''
120 #ifndef F_NOTIFY
121 #define F_NOTIFY 1026
122 #endif
123 main() {
124         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
125 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
126         headers='fcntl.h signal.h',
127         msg="Checking for kernel change notify support")
128
129     # Check for Linux kernel oplocks
130     conf.CHECK_CODE('''
131 #include <sys/types.h>
132 #include <fcntl.h>
133 #include <signal.h>
134 #ifndef F_NOTIFY
135 #define F_NOTIFY 1026
136 #endif
137 main() {
138         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
139 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
140         msg="Checking for Linux kernel oplocks")
141
142     # Check for IRIX kernel oplock types
143     conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
144                     'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
145                     msg="Checking for IRIX kernel oplock types")
146
147     # Check for krenel share modes
148     conf.CHECK_CODE('''
149 #include <sys/types.h>
150 #include <fcntl.h>
151 #include <signal.h>
152 #include <sys/file.h>
153 #ifndef LOCK_MAND
154 #define LOCK_MAND       32
155 #define LOCK_READ       64
156 #endif
157 main() {
158         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
159 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
160         msg="Checking for krenel share modes")
161
162     # Check for various members of the stat structure
163     conf.CHECK_TYPES('blksize_t blkcnt_t')
164     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
165                                 headers='sys/stat.h')
166     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
167                                 headers='sys/stat.h')
168
169     # Check for POSIX capability support
170     conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
171
172     if "HAVE_SYS_CAPABILITY_H" in conf.env:
173         conf.CHECK_CODE('''
174         cap_t cap;
175         cap_value_t vals[1];
176         if (!(cap = cap_get_proc())) exit(1);
177         vals[0] = CAP_CHOWN;
178         cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
179         cap_set_proc(cap);''',
180                         'HAVE_POSIX_CAPABILITIES', execute=True, lib="cap",
181                         headers='sys/capability.h',
182                         msg="Checking whether POSIX capabilities are available")
183
184     # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
185     # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
186     # -- JRA.
187     if conf.CONFIG_SET("HAVE_RPC_RPC_H"):
188         conf.CHECK_TYPE('int16', headers='rpc/rpc.h',
189                         define='HAVE_INT16_FROM_RPC_RPC_H',
190                         msg="Checking for int16 typedef included by rpc/rpc.h")
191         conf.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
192                         headers='sys/types.h rpc/rpc.h',
193                         msg="Checking for uint16 typedef included by rpc/rpc.h")
194         conf.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
195                         headers='sys/types.h rpc/rpc.h',
196                         msg="Checking for int32 typedef included by rpc/rpc.h")
197         conf.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
198                         headers='sys/types.h rpc/rpc.h',
199                         msg="Checking for uint32 typedef included by rpc/rpc.h")
200
201     # Check if the compiler will optimize out functions
202     conf.CHECK_CODE('''
203 if (0) {
204     this_function_does_not_exist();
205 } else {
206     return 1;
207 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
208         msg="Checking if the compiler will optimize out functions")
209
210     conf.CHECK_FUNCS('''
211 _acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
212 attropen attr_remove attr_removef attr_set attr_setf backtrace_symbols
213 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
214 __closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
215 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent endnetgrent execl
216 extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
217 extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
218 extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
219 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
220 fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
221 _fork __fork fremoveea fremovexattr fseek64 fseeko64 fsetea
222 fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
223 ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
224 getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
225 getgrent getgrnam getgrouplist getmntent getnetgrent getpagesize
226 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
227 getutmpx getutxent glob grantpt hstrerror initgroups innetgr
228 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
229 llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
230 lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
231 __lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
232 nl_langinfo _open __open open64 _open64 __open64 _opendir __opendir
233 opendir64 pathconf poll posix_fallocate posix_fallocate64
234 posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
235 pututline pututxline pwrite _pwrite __pwrite pwrite64 _pwrite64
236 __pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
237 __readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
238 seekdir64 select setea setenv setgidx setgroups setlocale setluid
239 setmntent setnetgrent setpgid setpriv setproplist setsid setuidx
240 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
241 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
242 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
243 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
244 updwtmp updwtmpx utimensat vsyslog _write __write __xstat
245 ''')
246
247     conf.CHECK_TYPE('struct timespec', headers='sys/time.h time.h')
248
249     conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
250
251
252     default_static_modules=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam rpc_lsarpc rpc_samr
253                                       rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl
254                                       rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss
255                                       rpc_eventlog auth_sam auth_unix auth_winbind auth_wbc auth_server
256                                       auth_domain auth_builtin auth_netlogond vfs_default
257                                       nss_info_template''')
258
259     default_shared_modules=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
260                                       vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
261                                       vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850
262                                       charset_CP437 auth_script vfs_readahead vfs_xattr_tdb
263                                       vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
264                                       vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
265                                       vfs_crossrename''')
266
267     if Options.options.developer:
268         default_static_modules.extend(TO_LIST('rpc_rpcecho pdb_ads'))
269         default_shared_modules.extend(TO_LIST('charset_weird perfcount_test'))
270
271     move_to_shared = TO_LIST(Options.options.shared_modules)
272     move_to_static = TO_LIST(Options.options.static_modules)
273
274     for m in move_to_static:
275         if m in default_shared_modules:
276             default_shared_modules.remove(m)
277             default_static_modules.append(m)
278     for m in move_to_shared:
279         if m in default_static_modules:
280             default_static_modules.remove(m)
281             default_shared_modules.append(m)
282
283     conf.DEFINE('STRING_STATIC_MODULES', ' '.join(default_static_modules), quote=True)
284
285     static_list = {}
286     shared_list = {}
287
288     prefixes = ['vfs', 'pdb', 'rpc', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
289     conf.env['MODULE_PREFIXES'] = prefixes
290     for p in prefixes:
291         for m in default_static_modules:
292             if m.find(p) == 0:
293                 if not p in static_list:
294                     static_list[p] = []
295                 static_list[p].append(m)
296         for m in default_shared_modules:
297             if m.find(p) == 0:
298                 if not p in shared_list:
299                     shared_list[p] = []
300                 shared_list[p].append(m)
301
302     for p in prefixes:
303         static_env = "%s_STATIC" % p.upper()
304         shared_env = "%s_SHARED" % p.upper()
305         conf.env[static_env] = []
306         conf.env[shared_env] = []
307         if p in static_list:
308             decl_list=""
309             for entry in static_list[p]:
310                 decl_list += "extern NTSTATUS %s_init(void); " % entry
311                 conf.env[static_env].append('%s' % entry.upper())
312             decl_list = decl_list.rstrip()
313             conf.DEFINE('static_decl_%s' % p, decl_list)
314             conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init();  '.join(static_list[p]))
315         else:
316             conf.DEFINE('static_decl_%s' % p, '')
317             conf.DEFINE('static_init_%s' % p, '{}')
318         if p in shared_list:
319             for entry in shared_list[p]:
320                 conf.DEFINE('%s_init' % entry, 'init_samba_module')
321                 conf.env[shared_env].append('%s' % entry.upper())
322
323     if Options.options.with_winbind:
324         conf.env.build_winbind = True
325         conf.DEFINE('WITH_WINBIND', '1')
326
327     conf.find_program('awk', var='AWK')
328
329     # Darwin has extra options to xattr-family functions
330     conf.CHECK_CODE('getxattr(0, 0, 0, 0, 0, 0);',
331                     'XATTR_ADD_OPT',
332                     msg="Checking whether xattr interface takes additional options",
333                     headers='sys/types.h attr/xattr.h sys/xattr.h')
334
335     #FIXME: Should just be set when krb5 and ldap requirements are fulfilled
336     if Options.options.with_ads:
337         conf.DEFINE('WITH_ADS', '1')
338
339     # Look for CUPS
340     conf.find_program('cups-config', var='CUPS_CONFIG')
341     if conf.env.CUPS_CONFIG and Options.options.with_cups:
342         conf.check_cfg(path="cups-config", args="--cflags --ldflags --libs",
343                        package="", uselib_store="cups")
344         conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
345         conf.CHECK_LIB('cups')
346     else:
347         # define an empty subsystem for cups, to allow it to be used as an empty dependency
348         conf.SET_TARGET_TYPE('cups', 'EMPTY')
349
350     # Check for LDAP
351     if Options.options.with_ldap:
352         conf.CHECK_HEADERS('ldap.h lber.h')
353         conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
354         conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
355         conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
356         # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
357         # SASL wrapping hooks
358         if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
359                 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
360             conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
361
362         # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
363         # for the samba logs
364         conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
365                             define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
366
367         conf.CHECK_FUNCS_IN('ldap_init ldap_initialize ldap_set_rebind_proc', 'ldap')
368         conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
369
370         # Check if ldap_set_rebind_proc() takes three arguments
371         if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
372                            'LDAP_SET_REBIND_PROC_ARGS',
373                            msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
374                            headers='ldap.h lber.h', link=False):
375             conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
376         else:
377             conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
378
379         # last but not least, if ldap_init() exists, we want to use ldap
380         if conf.CONFIG_SET('HAVE_LDAP_INIT'):
381             conf.DEFINE('HAVE_LDAP', '1')
382             conf.DEFINE('LDAP_DEPRECATED', '1')
383             conf.env['SMBLDAP'] = 'lib/smbldap.c'
384             conf.env['SMBLDAPUTIL'] = 'lib/smbldap_util.c'
385     else:
386         conf.SET_TARGET_TYPE('ldap', 'EMPTY')
387         conf.SET_TARGET_TYPE('lber', 'EMPTY')
388
389     # Check for kerberos
390     conf.find_program('krb5-config', var='KRB5_CONFIG')
391     if conf.env.KRB5_CONFIG and Options.options.with_krb5:
392         conf.check_cfg(path="krb5-config", args="--cflags --libs",
393                        package="gssapi", uselib_store="krb5")
394         conf.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib='krb5')
395         conf.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h', lib='krb5')
396
397         if conf.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
398             conf.env['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
399
400         conf.CHECK_FUNCS_IN('_et_list', 'com_err')
401         conf.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
402         conf.CHECK_FUNCS_IN('crypto', 'des_set_key')
403         conf.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
404         conf.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
405         conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi gssapi_krb5')
406         conf.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
407         conf.CHECK_FUNCS('''
408 krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
409 krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
410 krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
411 krb5_auth_con_setuseruserkey krb5_locate_kdc krb5_get_permitted_enctypes
412 krb5_get_default_in_tkt_etypes krb5_free_data_contents
413 krb5_principal_get_comp_string krb5_free_unparsed_name
414 krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
415 krb5_krbhst_get_addrinfo krb5_c_enctype_compare krb5_enctypes_compatible_keys
416 krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
417 krb5_verify_checksum krb5_c_verify_checksum krb5_principal_compare_any_realm
418 krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
419 krb5_get_renewed_creds krb5_get_kdc_cred krb5_free_error_contents
420 initialize_krb5_error_table krb5_get_init_creds_opt_alloc
421 krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
422 krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
423 krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
424 krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
425                          lib='krb5')
426         conf.CHECK_DECLS('''krb5_get_credentials_for_user
427                             krb5_auth_con_set_req_cksumtype''',
428                             headers='krb5.h', always=True)
429         conf.CHECK_VARIABLE('AP_OPTS_USE_SUBKEY', headers='krb5.h')
430         conf.CHECK_VARIABLE('KV5M_KEYTAB', headers='krb5.h')
431         conf.CHECK_VARIABLE('KRB5_KU_OTHER_CKSUM', headers='krb5.h')
432         conf.CHECK_VARIABLE('KRB5_KEYUSAGE_APP_DATA_CKSUM', headers='krb5.h')
433         conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'key', headers='krb5.h',
434                                     define='HAVE_KRB5_KEYTAB_ENTRY_KEY')
435         conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'keyblock', headers='krb5.h',
436                                     define='HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK')
437         conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'magic', headers='krb5.h',
438                                     define='HAVE_MAGIC_IN_KRB5_ADDRESS')
439         conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'addrtype', headers='krb5.h',
440                                     define='HAVE_ADDRTYPE_IN_KRB5_ADDRESS')
441         conf.CHECK_STRUCTURE_MEMBER('krb5_ticket', 'enc_part2', headers='krb5.h',
442                                     define='HAVE_KRB5_TKT_ENC_PART2')
443         conf.CHECK_STRUCTURE_MEMBER('krb5_creds', 'keyblock', headers='krb5.h',
444                                     define='HAVE_KRB5_KEYBLOCK_IN_CREDS')
445         conf.CHECK_STRUCTURE_MEMBER('krb5_creds', 'session', headers='krb5.h',
446                                     define='HAVE_KRB5_SESSION_IN_CREDS')
447         conf.CHECK_TYPE('krb5_encrypt_block', headers='krb5.h')
448         conf.CHECK_CODE('''
449 krb5_context ctx;
450 krb5_get_init_creds_opt *opt = NULL;
451 krb5_get_init_creds_opt_free(ctx, opt);
452 ''',
453                         'KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT',
454                         headers='krb5.h', link=False,
455                         msg="Checking whether krb5_get_init_creds_opt_free takes a context argument")
456         conf.CHECK_CODE('krb5_mk_error(0,0,0)',
457                         'HAVE_SHORT_KRB5_MK_ERROR_INTERFACE',
458                         headers='krb5.h', link=False,
459                         msg="Checking whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal")
460         conf.CHECK_CODE('''
461 const krb5_data *pkdata;
462 krb5_context context;
463 krb5_principal principal;
464 pkdata = krb5_princ_component(context, principal, 0);
465 ''',
466                         'HAVE_KRB5_PRINC_COMPONENT',
467                         headers='krb5.h', lib='krb5',
468                         msg="Checking whether krb5_princ_component is available")
469
470     else:
471         conf.SET_TARGET_TYPE('krb5', 'EMPTY')
472         conf.SET_TARGET_TYPE('gssapi', 'EMPTY')
473         conf.SET_TARGET_TYPE('gssapi_krb5', 'EMPTY')
474
475     # FIXME: these should be tests for features, but the old build system just
476     # checks for OSes.
477     import sys
478     host_os = sys.platform
479
480     # Python doesn't have case switches... :/
481     # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
482     # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
483     if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('qnx') > -1):
484         if host_os.rfind('linux') > -1:
485             conf.DEFINE('LINUX', '1')
486         elif host_os.rfind('qnx') > -1:
487             conf.DEFINE('QNX', '1')
488         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
489     elif (host_os.rfind('darwin') > -1):
490         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
491     # FIXME: Add more checks here.
492     else:
493         print "Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os
494
495     conf.SAMBA_CONFIG_H('include/config.h')
496
497 def ctags(ctx):
498     "build 'tags' file using ctags"
499     import Utils
500     source_root = os.path.dirname(Utils.g_module.root_path)
501     cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
502     print("Running: %s" % cmd)
503     os.system(cmd)