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