10 from optparse
import SUPPRESS_HELP
11 sys
.path
.insert(0, srcdir
+"/buildtools/wafsamba")
12 import wafsamba
, Options
17 def load_version(env
=None):
18 '''load samba versions either from ./VERSION or git
19 return a version object for detailed breakdown'''
20 import samba_utils
, Utils
22 env
= samba_utils
.LOAD_ENVIRONMENT()
24 version
= wafsamba
.samba_version_file("./VERSION", "..", env
=env
)
25 Utils
.g_module
.VERSION
= version
.STRING
29 opt
.BUILTIN_DEFAULT('NONE')
30 opt
.PRIVATE_EXTENSION_DEFAULT('s3')
31 opt
.RECURSE('../lib/replace')
33 opt
.RECURSE('selftest')
34 opt
.RECURSE('../lib/nss_wrapper')
35 opt
.RECURSE('../lib/socket_wrapper')
36 opt
.RECURSE('../lib/tevent')
37 opt
.RECURSE('../lib/tdb')
39 opt
.add_option('--with-static-modules',
40 help=("Comma-separated list of names of modules to statically link in"),
41 action
="store", dest
='static_modules', default
=None)
42 opt
.add_option('--with-shared-modules',
43 help=("Comma-separated list of names of modules to build shared"),
44 action
="store", dest
='shared_modules', default
=None)
45 opt
.add_option('--enable-selftest',
46 help=("enable options necessary for selftest"),
47 action
="store_true", dest
='enable_selftest', default
=False)
49 opt
.SAMBA3_ADD_OPTION('winbind')
50 opt
.SAMBA3_ADD_OPTION('swat')
51 opt
.SAMBA3_ADD_OPTION('ads')
52 opt
.SAMBA3_ADD_OPTION('krb5')
53 opt
.SAMBA3_ADD_OPTION('ldap')
54 opt
.SAMBA3_ADD_OPTION('cups', with_name
="enable", without_name
="disable")
55 opt
.SAMBA3_ADD_OPTION('merged-build', with_name
="enable", without_name
="disable")
56 opt
.SAMBA3_ADD_OPTION('pam')
57 opt
.SAMBA3_ADD_OPTION('quotas')
58 opt
.SAMBA3_ADD_OPTION('sys-quotas')
59 opt
.SAMBA3_ADD_OPTION('sendfile-support')
60 opt
.SAMBA3_ADD_OPTION('utmp')
61 opt
.SAMBA3_ADD_OPTION('pthreadpool', with_name
="enable", without_name
="disable")
62 opt
.SAMBA3_ADD_OPTION('avahi', with_name
="enable", without_name
="disable")
63 opt
.SAMBA3_ADD_OPTION('iconv')
64 opt
.SAMBA3_ADD_OPTION('acl-support')
65 opt
.SAMBA3_ADD_OPTION('dnsupdate')
69 from samba_utils
import TO_LIST
71 version
= load_version(env
=conf
.env
)
73 conf
.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
74 conf
.DEFINE('_SAMBA_BUILD_', version
.MAJOR
, add_to_cflags
=True)
75 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
77 if Options
.options
.developer
:
78 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
79 conf
.env
['developer'] = True
81 if Options
.options
.with_swat
:
82 conf
.env
['build_swat'] = True
84 conf
.ADD_EXTRA_INCLUDES('''#source3 #source3/include #lib/replace #lib/talloc
85 #lib/tevent #source3/libaddns #source3/librpc
86 #source3/lib #lib/tdb/include #lib/popt #source4''')
88 conf
.RECURSE('../lib/replace')
90 conf
.RECURSE('../lib/tdb')
91 conf
.RECURSE('../lib/talloc')
92 conf
.RECURSE('../lib/tevent')
93 conf
.RECURSE('../lib/popt')
94 conf
.RECURSE('../lib/nss_wrapper')
95 conf
.RECURSE('../lib/socket_wrapper')
96 conf
.RECURSE('../lib/zlib')
97 conf
.RECURSE('../libcli/smbreadline')
99 conf
.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
101 conf
.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
102 conf
.CHECK_FUNCS('strtol strchr strupr chflags')
103 conf
.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
104 conf
.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
105 conf
.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
106 conf
.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
107 conf
.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf stat64 fstat64')
108 conf
.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64')
109 conf
.CHECK_FUNCS('fseek64 fseeko64 ftell64 ftello64 setluid')
110 conf
.CHECK_FUNCS('getpwnam', headers
='sys/types.h pwd.h')
111 conf
.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
112 conf
.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
113 conf
.CHECK_FUNCS('syslog vsyslog timegm setlocale nl_langinfo')
114 conf
.CHECK_FUNCS_IN('nanosleep', 'rt')
115 conf
.CHECK_FUNCS('lutimes futimes utimensat futimens')
116 conf
.CHECK_FUNCS('mlock munlock mlockall munlockall')
117 conf
.CHECK_FUNCS('memalign posix_memalign hstrerror')
118 conf
.CHECK_FUNCS('shmget')
119 conf
.CHECK_FUNCS_IN('shm_open', 'rt', checklibc
=True)
120 conf
.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain')
121 #FIXME: for some reason this one still fails
122 conf
.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
123 conf
.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
125 # Check for inotify support
126 conf
.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
127 conf
.CHECK_FUNCS('inotify_init')
128 if "HAVE_LINUX_INOTIFY_H" in conf
.env
and "HAVE_INOTIFY_INIT" in conf
.env
:
129 conf
.DEFINE('HAVE_INOTIFY', 1)
131 # Check for kernel change notify support
134 #define F_NOTIFY 1026
137 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
138 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain
=False, execute
=True,
139 headers
='fcntl.h signal.h',
140 msg
="Checking for kernel change notify support")
142 # Check for Linux kernel oplocks
144 #include <sys/types.h>
148 #define F_NOTIFY 1026
151 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
152 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain
=False, execute
=True,
153 msg
="Checking for Linux kernel oplocks")
155 # Check for IRIX kernel oplock types
156 conf
.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
157 'HAVE_KERNEL_OPLOCKS_IRIX', headers
='fcntl.h',
158 msg
="Checking for IRIX kernel oplock types")
160 # Check for krenel share modes
162 #include <sys/types.h>
165 #include <sys/file.h>
171 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
172 }''', 'HAVE_KERNEL_SHARE_MODES', addmain
=False, execute
=True,
173 msg
="Checking for krenel share modes")
175 # Check for various members of the stat structure
176 conf
.CHECK_TYPES('blksize_t blkcnt_t')
177 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define
='HAVE_STAT_ST_BLOCKS',
178 headers
='sys/stat.h')
179 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define
='HAVE_STAT_ST_BLKSIZE',
180 headers
='sys/stat.h')
182 # Check for POSIX capability support
183 conf
.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers
='sys/capability.h')
185 if "HAVE_SYS_CAPABILITY_H" in conf
.env
:
189 if (!(cap = cap_get_proc())) exit(1);
191 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
192 cap_set_proc(cap);''',
193 'HAVE_POSIX_CAPABILITIES', execute
=True, lib
="cap",
194 headers
='sys/capability.h',
195 msg
="Checking whether POSIX capabilities are available")
197 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
198 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
200 if conf
.CONFIG_SET("HAVE_RPC_RPC_H"):
201 conf
.CHECK_TYPE('int16', headers
='rpc/rpc.h',
202 define
='HAVE_INT16_FROM_RPC_RPC_H',
203 msg
="Checking for int16 typedef included by rpc/rpc.h")
204 conf
.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
205 headers
='sys/types.h rpc/rpc.h',
206 msg
="Checking for uint16 typedef included by rpc/rpc.h")
207 conf
.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
208 headers
='sys/types.h rpc/rpc.h',
209 msg
="Checking for int32 typedef included by rpc/rpc.h")
210 conf
.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
211 headers
='sys/types.h rpc/rpc.h',
212 msg
="Checking for uint32 typedef included by rpc/rpc.h")
213 conf
.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
214 headers
='sys/types.h sys/acl.h rpcsvc/nis.h',
215 msg
="Checking for broken nisplus include files")
217 # Check if the compiler will optimize out functions
220 this_function_does_not_exist();
223 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
224 msg
="Checking if the compiler will optimize out functions")
226 # Check if the compiler supports the LL suffix on long long integers
228 conf
.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
230 msg
="Checking for LL suffix on long long integers")
233 _acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
234 attropen attr_remove attr_removef attr_set attr_setf backtrace_symbols
235 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
236 __closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
237 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
238 extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
239 extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
240 extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
241 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
242 fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
243 _fork __fork fremoveea fremovexattr fseek64 fseeko64 fsetea
244 fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
245 ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
246 getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
247 getgrent getgrnam getgrouplist getmntent getpagesize
248 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
249 glob grantpt hstrerror initgroups innetgr
250 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
251 llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
252 lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
253 __lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
254 nl_langinfo _open __open open64 _open64 __open64 _opendir __opendir
255 opendir64 pathconf poll posix_fallocate posix_fallocate64
256 posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
257 pwrite _pwrite __pwrite pwrite64 _pwrite64
258 __pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
259 __readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
260 seekdir64 select setea setenv setgidx setgroups setlocale setluid
261 setmntent setpgid setpriv setproplist setsid setuidx
262 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
263 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
264 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
265 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
266 utimensat vsyslog _write __write __xstat
269 conf
.CHECK_TYPE('struct timespec', headers
='sys/time.h time.h')
271 conf
.CHECK_SAMBA3_CHARSET() # see build/charset.py
273 # FIXME: these should be tests for features, but the old build system just
276 host_os
= sys
.platform
278 # Python doesn't have case switches... :/
279 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
280 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
281 if (host_os
.rfind('linux') > -1) or (host_os
.rfind('gnu') > -1) or (host_os
.rfind('qnx') > -1):
282 if host_os
.rfind('linux') > -1:
283 conf
.DEFINE('LINUX', '1')
284 elif host_os
.rfind('qnx') > -1:
285 conf
.DEFINE('QNX', '1')
286 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
287 elif (host_os
.rfind('darwin') > -1):
288 conf
.DEFINE('DARWINOS', 1)
289 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
290 conf
.ADD_CFLAGS('-fno-common')
291 # FIXME: Add more checks here.
293 print "Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os
295 #FIXME: add more checks
296 if Options
.options
.with_acl_support
:
297 if host_os
.rfind('linux') > -1:
298 conf
.CHECK_FUNCS_IN('acl_get_file', 'acl')
299 conf
.CHECK_FUNCS_IN('getxattr', 'attr')
300 if conf
.CHECK_CODE('''
303 acl_entry_t *entry_p;
304 return acl_get_entry(acl, entry_id, entry_p);
307 headers
='sys/types.h sys/acl.h', link
=False,
308 msg
="Checking for POSIX ACL support") :
310 acl_permset_t permset_d;
312 return acl_get_perm_np(permset_d, perm);
314 'HAVE_ACL_GET_PERM_NP',
315 headers
='sys/types.h sys/acl.h', link
=True,
316 msg
="Checking whether acl_get_perm_np() is available")
318 conf
.DEFINE('HAVE_NO_ACLS', 1)
319 conf
.SET_TARGET_TYPE('acl', 'EMPTY')
320 conf
.SET_TARGET_TYPE('attr', 'EMPTY')
322 if conf
.CHECK_FUNCS('dirfd'):
323 conf
.DEFINE('HAVE_DIRFD_DECL', 1)
325 conf
.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
326 'HAVE_STATFS_F_FSID',
327 msg
="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
328 headers
='sys/types.h sys/statfs.h',
331 default_static_modules
=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam pdb_ldap rpc_lsarpc rpc_samr
332 rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl
333 rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss
334 rpc_eventlog auth_sam auth_unix auth_winbind auth_wbc auth_server
335 auth_domain auth_builtin auth_netlogond vfs_default
336 nss_info_template idmap_ldap idmap_tdb idmap_passdb
339 default_shared_modules
=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
340 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
341 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850
342 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb
343 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
344 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
345 vfs_crossrename vfs_linux_xfs_sgid
346 vfs_time_audit idmap_autorid''')
348 if Options
.options
.developer
:
349 default_static_modules
.extend(TO_LIST('rpc_rpcecho pdb_ads'))
350 default_shared_modules
.extend(TO_LIST('charset_weird perfcount_test'))
352 if Options
.options
.with_acl_support
:
353 default_static_modules
.extend(TO_LIST('vfs_posixacl'))
355 if conf
.CONFIG_SET('HAVE_DIRFD_DECL'):
356 default_shared_modules
.extend(TO_LIST('vfs_syncops vfs_dirsort'))
358 if conf
.CONFIG_SET('HAVE_STATFS_F_FSID'):
359 default_shared_modules
.extend(TO_LIST('vfs_fileid'))
361 explicit_shared_modules
= TO_LIST(Options
.options
.shared_modules
, delimiter
=',')
362 explicit_static_modules
= TO_LIST(Options
.options
.static_modules
, delimiter
=',')
364 final_static_modules
= default_static_modules
365 final_shared_modules
= default_shared_modules
367 for m
in explicit_static_modules
:
368 if m
in final_shared_modules
:
369 final_shared_modules
.remove(m
)
370 final_static_modules
.append(m
)
371 for m
in explicit_shared_modules
:
372 if m
in final_static_modules
:
373 final_static_modules
.remove(m
)
374 final_shared_modules
.append(m
)
376 conf
.env
['static_modules'] = final_static_modules
377 conf
.env
['shared_modules'] = final_shared_modules
379 conf
.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules
), quote
=True)
384 prefixes
= ['vfs', 'pdb', 'rpc', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
385 conf
.env
['MODULE_PREFIXES'] = prefixes
387 for m
in final_static_modules
:
389 if not p
in static_list
:
391 static_list
[p
].append(m
)
392 for m
in final_shared_modules
:
394 if not p
in shared_list
:
396 shared_list
[p
].append(m
)
399 static_env
= "%s_STATIC" % p
.upper()
400 shared_env
= "%s_SHARED" % p
.upper()
401 conf
.env
[static_env
] = []
402 conf
.env
[shared_env
] = []
406 for entry
in static_list
[p
]:
407 decl_list
+= "extern NTSTATUS %s_init(const struct rpc_srv_callbacks *rpc_srv_cb); " % entry
408 conf
.env
[static_env
].append('%s' % entry
)
409 decl_list
= decl_list
.rstrip()
410 conf
.DEFINE('static_decl_%s' % p
, decl_list
)
411 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(NULL); }' % '_init(NULL); '.join(static_list
[p
]))
413 for entry
in static_list
[p
]:
414 decl_list
+= "extern NTSTATUS %s_init(void); " % entry
415 conf
.env
[static_env
].append('%s' % entry
)
416 decl_list
= decl_list
.rstrip()
417 conf
.DEFINE('static_decl_%s' % p
, decl_list
)
418 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(); }' % '_init(); '.join(static_list
[p
]))
420 conf
.DEFINE('static_decl_%s' % p
, '')
421 conf
.DEFINE('static_init_%s' % p
, '{}')
423 for entry
in shared_list
[p
]:
424 conf
.DEFINE('%s_init' % entry
, 'init_samba_module')
425 conf
.env
[shared_env
].append('%s' % entry
)
427 if Options
.options
.with_winbind
:
428 conf
.env
.build_winbind
= True
429 conf
.DEFINE('WITH_WINBIND', '1')
431 conf
.find_program('awk', var
='AWK')
432 conf
.find_program('perl', var
='PERL')
434 # Darwin has extra options to xattr-family functions
435 conf
.CHECK_CODE('getxattr(0, 0, 0, 0, 0, 0);',
437 msg
="Checking whether xattr interface takes additional options",
438 headers
='sys/types.h attr/xattr.h sys/xattr.h')
440 conf
.CHECK_HEADERS('asm/types.h')
442 conf
.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
443 headers
='unistd.h sys/types.h',
444 msg
="Checking for major macro")
446 conf
.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
447 headers
='unistd.h sys/types.h',
448 msg
="Checking for minor macro")
450 conf
.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
451 headers
='unistd.h sys/types.h dirent.h',
452 define
='HAVE_DIRENT_D_OFF')
454 conf
.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
455 conf
.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
456 msg
="Checking for setnetgrent prototype",
457 headers
='netdb.h netgroup.h',
458 cflags
="-Werror-implicit-function-declaration")
459 conf
.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
460 msg
="Checking for getnetgrent prototype",
461 headers
='netdb.h netgroup.h',
462 cflags
="-Werror-implicit-function-declaration")
463 conf
.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
464 msg
="Checking for endnetgrent prototype",
465 headers
='netdb.h netgroup.h',
466 cflags
="-Werror-implicit-function-declaration")
468 #FIXME: Should just be set when krb5 and ldap requirements are fulfilled
469 if Options
.options
.with_ads
:
470 conf
.DEFINE('WITH_ADS', '1')
473 conf
.find_program('cups-config', var
='CUPS_CONFIG')
474 if conf
.env
.CUPS_CONFIG
and Options
.options
.with_cups
:
475 conf
.check_cfg(path
="cups-config", args
="--cflags --ldflags --libs",
476 package
="", uselib_store
="cups")
477 conf
.CHECK_HEADERS('cups/cups.h cups/language.h', lib
='cups')
478 conf
.CHECK_LIB('cups')
479 conf
.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
481 # define an empty subsystem for cups, to allow it to be used as an empty dependency
482 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
485 if Options
.options
.with_ldap
:
486 conf
.CHECK_HEADERS('ldap.h lber.h')
487 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
488 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
489 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
490 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
491 # SASL wrapping hooks
492 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
493 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
494 conf
.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
496 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
498 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
499 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
501 conf
.CHECK_FUNCS_IN('ldap_init ldap_initialize ldap_set_rebind_proc', 'ldap')
502 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
504 # Check if ldap_set_rebind_proc() takes three arguments
505 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
506 'LDAP_SET_REBIND_PROC_ARGS',
507 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
508 headers
='ldap.h lber.h', link
=False):
509 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
511 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
513 # last but not least, if ldap_init() exists, we want to use ldap
514 if conf
.CONFIG_SET('HAVE_LDAP_INIT'):
515 conf
.DEFINE('HAVE_LDAP', '1')
516 conf
.DEFINE('LDAP_DEPRECATED', '1')
517 conf
.env
['SMBLDAP'] = 'lib/smbldap.c'
518 conf
.env
['SMBLDAPUTIL'] = 'lib/smbldap_util.c'
520 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
521 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
524 conf
.find_program('krb5-config', var
='KRB5_CONFIG')
525 if conf
.env
.KRB5_CONFIG
and Options
.options
.with_krb5
:
526 conf
.check_cfg(path
="krb5-config", args
="--cflags --libs",
527 package
="gssapi", uselib_store
="krb5")
528 conf
.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib
='krb5')
529 conf
.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h', lib
='krb5')
531 if conf
.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
532 conf
.env
['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
534 conf
.CHECK_FUNCS_IN('_et_list', 'com_err')
535 conf
.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
536 conf
.CHECK_FUNCS_IN('crypto', 'des_set_key')
537 conf
.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
538 conf
.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
539 if conf
.CHECK_FUNCS_IN('gss_display_status', 'gssapi gssapi_krb5'):
540 conf
.DEFINE('HAVE_GSSAPI', '1')
541 conf
.CHECK_FUNCS_IN('gss_wrap_iov', 'gssapi gssapi_krb5 krb5')
542 conf
.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
544 krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
545 krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
546 krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
547 krb5_auth_con_setuseruserkey krb5_locate_kdc krb5_get_permitted_enctypes
548 krb5_get_default_in_tkt_etypes krb5_free_data_contents
549 krb5_principal_get_comp_string krb5_free_unparsed_name
550 krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
551 krb5_krbhst_get_addrinfo krb5_c_enctype_compare krb5_enctypes_compatible_keys
552 krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
553 krb5_verify_checksum krb5_c_verify_checksum krb5_principal_compare_any_realm
554 krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
555 krb5_get_renewed_creds krb5_get_kdc_cred krb5_free_error_contents
556 initialize_krb5_error_table krb5_get_init_creds_opt_alloc
557 krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
558 krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
559 krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
560 krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
562 conf
.CHECK_DECLS('''krb5_get_credentials_for_user
563 krb5_auth_con_set_req_cksumtype''',
564 headers
='krb5.h', always
=True)
565 conf
.CHECK_VARIABLE('AP_OPTS_USE_SUBKEY', headers
='krb5.h')
566 conf
.CHECK_VARIABLE('KV5M_KEYTAB', headers
='krb5.h')
567 conf
.CHECK_VARIABLE('KRB5_KU_OTHER_CKSUM', headers
='krb5.h')
568 conf
.CHECK_VARIABLE('KRB5_KEYUSAGE_APP_DATA_CKSUM', headers
='krb5.h')
569 conf
.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'key', headers
='krb5.h',
570 define
='HAVE_KRB5_KEYTAB_ENTRY_KEY')
571 conf
.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'keyblock', headers
='krb5.h',
572 define
='HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK')
573 conf
.CHECK_STRUCTURE_MEMBER('krb5_address', 'magic', headers
='krb5.h',
574 define
='HAVE_MAGIC_IN_KRB5_ADDRESS')
575 conf
.CHECK_STRUCTURE_MEMBER('krb5_address', 'addrtype', headers
='krb5.h',
576 define
='HAVE_ADDRTYPE_IN_KRB5_ADDRESS')
577 conf
.CHECK_STRUCTURE_MEMBER('krb5_ticket', 'enc_part2', headers
='krb5.h',
578 define
='HAVE_KRB5_TKT_ENC_PART2')
579 conf
.CHECK_STRUCTURE_MEMBER('krb5_creds', 'keyblock', headers
='krb5.h',
580 define
='HAVE_KRB5_KEYBLOCK_IN_CREDS')
581 conf
.CHECK_STRUCTURE_MEMBER('krb5_creds', 'session', headers
='krb5.h',
582 define
='HAVE_KRB5_SESSION_IN_CREDS')
583 conf
.CHECK_STRUCTURE_MEMBER('krb5_ap_req', 'ticket', headers
='krb5.h',
584 define
='HAVE_TICKET_POINTER_IN_KRB5_AP_REQ')
586 conf
.CHECK_TYPE('krb5_encrypt_block', headers
='krb5.h')
591 krb5_enctype enctype;
592 enctype = ticket.enc_part.enctype;
593 kvno = ticket.enc_part.kvno;
595 'KRB5_TICKET_HAS_KEYINFO',
596 headers
='krb5.h', link
=False,
597 msg
="Checking whether the krb5_ticket structure contains the kvno and enctype")
600 krb5_get_init_creds_opt *opt = NULL;
601 krb5_get_init_creds_opt_free(ctx, opt);
603 'KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT',
604 headers
='krb5.h', link
=False,
605 msg
="Checking whether krb5_get_init_creds_opt_free takes a context argument")
606 conf
.CHECK_CODE('krb5_mk_error(0,0,0)',
607 'HAVE_SHORT_KRB5_MK_ERROR_INTERFACE',
608 headers
='krb5.h', link
=False,
609 msg
="Checking whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal")
611 const krb5_data *pkdata;
612 krb5_context context;
613 krb5_principal principal;
614 pkdata = krb5_princ_component(context, principal, 0);
616 'HAVE_KRB5_PRINC_COMPONENT',
617 headers
='krb5.h', lib
='krb5',
618 msg
="Checking whether krb5_princ_component is available")
623 krb5_enctype_to_string(1, buf, 256);
626 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG',
627 headers
='krb5.h', lib
='krb5',
628 addmain
=False, cflags
='-Werror',
629 msg
="Checking whether krb5_enctype_to_string takes size_t argument")
633 krb5_context context = NULL;
635 krb5_enctype_to_string(context, 1, &str);
639 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG',
640 headers
='krb5.h stdlib.h', lib
='krb5',
641 addmain
=False, cflags
='-Werror',
642 msg
="Checking whether krb5_enctype_to_string takes krb5_context argument")
645 krb5_context ctx = NULL;
646 krb5_principal princ = NULL;
647 const char *str = krb5_princ_realm(ctx, princ)->data;
650 'HAVE_KRB5_PRINC_REALM',
651 headers
='krb5.h', lib
='krb5',
653 msg
="Checking whether the macro krb5_princ_realm is defined")
654 if conf
.CHECK_CODE('''krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);''',
655 'KRB5_VERIFY_CHECKSUM_ARGS',
656 headers
='krb5.h', lib
='krb5',
657 msg
="Checking whether krb5_verify_checksum takes 7 arguments"):
658 conf
.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '7')
660 conf
.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '6')
663 krb5_enctype enctype;
664 enctype = ENCTYPE_ARCFOUR_HMAC_MD5;
666 '_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5',
667 headers
='krb5.h', lib
='krb5',
668 msg
="Checking whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available");
670 krb5_keytype keytype;
671 keytype = KEYTYPE_ARCFOUR_56;
673 '_HAVE_KEYTYPE_ARCFOUR_56',
674 headers
='krb5.h', lib
='krb5',
675 msg
="Checking whether the HAVE_KEYTYPE_ARCFOUR_56 key type definition is available");
676 if conf
.CONFIG_SET('_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and conf
.CONFIG_SET('_HAVE_KEYTYPE_ARCFOUR_56'):
677 conf
.DEFINE('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', '1')
680 krb5_enctype enctype;
681 enctype = ENCTYPE_ARCFOUR_HMAC;
683 'HAVE_ENCTYPE_ARCFOUR_HMAC',
684 headers
='krb5.h', lib
='krb5',
685 msg
="Checking whether the ENCTYPE_ARCFOUR_HMAC key type definition is available");
688 krb5_context context;
690 krb5_init_context(&context);
691 return krb5_kt_resolve(context, "WRFILE:api", &keytab);
693 'HAVE_WRFILE_KEYTAB',
694 headers
='krb5.h', lib
='krb5', execute
=True,
695 msg
="Checking whether the WRFILE:-keytab is supported");
697 conf
.DEFINE('HAVE_KRB5', '1')
700 conf
.SET_TARGET_TYPE('krb5', 'EMPTY')
701 conf
.SET_TARGET_TYPE('gssapi', 'EMPTY')
702 conf
.SET_TARGET_TYPE('gssapi_krb5', 'EMPTY')
703 conf
.SET_TARGET_TYPE('com_err', 'EMPTY')
704 conf
.SET_TARGET_TYPE('k5crypto', 'EMPTY')
706 if Options
.options
.with_utmp
:
707 conf
.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
708 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers
='utmp.h',
709 define
='HAVE_UT_UT_NAME')
710 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers
='utmp.h',
711 define
='HAVE_UT_UT_USER')
712 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers
='utmp.h',
713 define
='HAVE_UT_UT_ID')
714 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers
='utmp.h',
715 define
='HAVE_UT_UT_HOST')
716 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers
='utmp.h',
717 define
='HAVE_UT_UT_TIME')
718 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers
='utmp.h',
719 define
='HAVE_UT_UT_TV')
720 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers
='utmp.h',
721 define
='HAVE_UT_UT_TYPE')
722 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers
='utmp.h',
723 define
='HAVE_UT_UT_PID')
724 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers
='utmp.h',
725 define
='HAVE_UT_UT_EXIT')
726 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers
='utmp.h',
727 define
='HAVE_UT_UT_ADDR_V6')
728 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers
='utmp.h',
729 define
='HAVE_UT_UT_ADDR')
730 conf
.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers
='utmpx.h',
731 define
='HAVE_UX_UT_SYSLEN')
732 conf
.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
733 'PUTUTLINE_RETURNS_UTMP', headers
='utmp.h',
734 msg
="Checking whether pututline returns pointer")
735 conf
.DEFINE('WITH_UTMP', 1)
737 if Options
.options
.with_avahi
:
738 conf
.env
.with_avahi
= True
739 if not conf
.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf
.env
.with_avahi
= False
740 if not conf
.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf
.env
.with_avahi
= False
741 if not conf
.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf
.env
.with_avahi
= False
742 if conf
.env
.with_avahi
:
743 conf
.DEFINE('WITH_AVAHI_SUPPORT', 1)
745 conf
.SET_TARGET_TYPE('avahi-common', 'EMPTY')
746 conf
.SET_TARGET_TYPE('avahi-client', 'EMPTY')
748 if Options
.options
.with_iconv
:
749 conf
.env
.with_iconv
= True
750 if not conf
.CHECK_FUNCS_IN('iconv_open', 'iconv', headers
='iconv.h'):
751 conf
.env
.with_iconv
= False
752 if conf
.env
.with_iconv
:
753 conf
.DEFINE('HAVE_ICONV', 1)
755 if Options
.options
.with_pam
:
756 conf
.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
757 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
758 print "--with-pam=yes but pam_appl.h not found"
760 conf
.CHECK_FUNCS_IN('pam_get_data', 'pam', mandatory
=True)
761 conf
.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
762 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
763 print "--with-pam=yes but pam_modules.h not found"
765 conf
.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
766 conf
.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
767 conf
.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
769 #if defined(HAVE_SECURITY_PAM_APPL_H)
770 #include <security/pam_appl.h>
771 #elif defined(HAVE_PAM_PAM_APPL_H)
772 #include <pam/pam_appl.h>
774 pam_set_item(0, PAM_RHOST, 0);
778 msg
="Checking whether PAM_RHOST is available");
780 #if defined(HAVE_SECURITY_PAM_APPL_H)
781 #include <security/pam_appl.h>
782 #elif defined(HAVE_PAM_PAM_APPL_H)
783 #include <pam/pam_appl.h>
785 pam_set_item(0, PAM_TTY, 0);
789 msg
="Checking whether PAM_TTY is available");
791 #if (!defined(LINUX))
793 #define PAM_EXTERN extern
794 #if defined(HAVE_SECURITY_PAM_APPL_H)
795 #include <security/pam_appl.h>
796 #elif defined(HAVE_PAM_PAM_APPL_H)
797 #include <pam/pam_appl.h>
802 #if defined(HAVE_SECURITY_PAM_MODULES_H)
803 #include <security/pam_modules.h>
804 #elif defined(HAVE_PAM_PAM_MODULES_H)
805 #include <pam/pam_modules.h>
808 #if defined(HAVE_SECURITY__PAM_MACROS_H)
809 #include <security/_pam_macros.h>
810 #elif defined(HAVE_PAM__PAM_MACROS_H)
811 #include <pam/_pam_macros.h>
814 #ifdef HAVE_SECURITY_PAM_EXT_H
815 #include <security/pam_ext.h>
818 int i; i = PAM_RADIO_TYPE;
820 'HAVE_PAM_RADIO_TYPE',
822 msg
="Checking whether PAM_RADIO_TYPE is available");
823 conf
.DEFINE('WITH_PAM', 1)
824 conf
.DEFINE('WITH_PAM_MODULES', 1)
828 seteuid
= conf
.CHECK_CODE('''
829 #define AUTOCONF_TEST 1
830 #define USE_SETREUID 1
831 #include "./lib/util_sec.c"
836 msg
="Checking whether setreuid is available")
838 seteuid
= conf
.CHECK_CODE('''
839 #define AUTOCONF_TEST 1
840 #define USE_SETRESUID 1
841 #include "./lib/util_sec.c"
846 msg
="Checking whether setresuid is available")
848 seteuid
= conf
.CHECK_CODE('''
849 #define AUTOCONF_TEST 1
850 #define USE_SETEUID 1
851 #include "./lib/util_sec.c"
856 msg
="Checking whether seteuid is available")
858 seteuid
= conf
.CHECK_CODE('''
859 #define AUTOCONF_TEST 1
860 #define USE_SETUIDX 1
861 #include "./lib/util_sec.c"
867 msg
="Checking whether setuidx is available")
868 if Options
.options
.with_dnsupdate
:
869 conf
.CHECK_HEADERS('uuid/uuid.h')
870 conf
.CHECK_FUNCS_IN('uuid_generate', 'uuid')
871 if not conf
.CONFIG_SET('HAVE_UUID_UUID_H') and not conf
.CONFIG_SET('HAVE_UUID_GENERATE'):
872 print "--with-dnsupdate=yes but uuid support not sufficient"
874 conf
.DEFINE('WITH_DNS_UPDATES', 1)
876 conf
.SET_TARGET_TYPE('uuid', 'EMPTY')
878 conf
.SAMBA_CONFIG_H('include/config.h')
881 "build 'tags' file using ctags"
883 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
884 cmd
= 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
885 print("Running: %s" % cmd
)