10 from optparse
import SUPPRESS_HELP
11 sys
.path
.insert(0, srcdir
+"/buildtools/wafsamba")
12 import wafsamba
, Options
14 import samba_utils
, samba_version
18 opt
.BUILTIN_DEFAULT('NONE')
19 opt
.PRIVATE_EXTENSION_DEFAULT('s3')
20 opt
.RECURSE('../lib/replace')
22 opt
.RECURSE('selftest')
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
=None)
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
=None)
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')
53 opt
.SAMBA3_ADD_OPTION('acl-support')
54 opt
.SAMBA3_ADD_OPTION('dnsupdate')
58 from samba_utils
import TO_LIST
60 version
= samba_version
.load_version(env
=conf
.env
)
62 conf
.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
63 conf
.DEFINE('_SAMBA_BUILD_', version
.MAJOR
, add_to_cflags
=True)
64 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
66 if Options
.options
.developer
:
67 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
68 conf
.env
['developer'] = True
70 if Options
.options
.with_swat
:
71 conf
.env
['build_swat'] = True
73 conf
.ADD_EXTRA_INCLUDES('''#source3 #source3/include #lib/replace #lib/talloc
74 #lib/tevent #lib/addns #source3/librpc
75 #source3/lib #lib/tdb/include #lib/popt''')
77 conf
.RECURSE('../lib/replace')
79 conf
.RECURSE('../lib/tdb')
80 conf
.RECURSE('../lib/talloc')
81 conf
.RECURSE('../lib/tevent')
82 conf
.RECURSE('../lib/popt')
83 conf
.RECURSE('../lib/nss_wrapper')
84 conf
.RECURSE('../lib/socket_wrapper')
85 conf
.RECURSE('../lib/zlib')
86 conf
.RECURSE('../libcli/smbreadline')
88 conf
.ADD_LDFLAGS("-Wl,--export-dynamic", testflags
=True)
90 conf
.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
91 conf
.CHECK_HEADERS('linux/falloc.h')
93 conf
.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
94 conf
.CHECK_FUNCS('strtol strchr strupr chflags')
95 conf
.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
96 conf
.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
97 conf
.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
98 conf
.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
99 conf
.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf stat64 fstat64')
100 conf
.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 fallocate fallocate64 posix_fallocate posix_fallocate64')
101 conf
.CHECK_FUNCS('fseek64 fseeko64 ftell64 ftello64 setluid')
102 conf
.CHECK_FUNCS('getpwnam', headers
='sys/types.h pwd.h')
103 conf
.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
104 conf
.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
105 conf
.CHECK_FUNCS('syslog vsyslog timegm setlocale nl_langinfo')
106 conf
.CHECK_FUNCS_IN('nanosleep', 'rt')
107 conf
.CHECK_FUNCS('lutimes futimes utimensat futimens')
108 conf
.CHECK_FUNCS('mlock munlock mlockall munlockall')
109 conf
.CHECK_FUNCS('memalign posix_memalign hstrerror')
110 conf
.CHECK_FUNCS('shmget')
111 conf
.CHECK_FUNCS_IN('shm_open', 'rt', checklibc
=True)
112 conf
.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain')
113 #FIXME: for some reason this one still fails
114 conf
.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
115 conf
.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
116 conf
.CHECK_DECLS('fdatasync', reverse
=True)
117 conf
.CHECK_DECLS('readahead', reverse
=True, headers
='fcntl.h')
119 if conf
.CONFIG_SET('HAVE_LONG_LONG'):
120 conf
.DEFINE('HAVE_LONGLONG', 1)
122 if conf
.CHECK_CODE('''
123 #if defined(HAVE_UNISTD_H)
126 long ret = splice(0,0,1,0,400,0);
130 conf
.CHECK_DECLS('splice', reverse
=True, headers
='fcntl.h')
132 # Check for inotify support
133 conf
.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
134 conf
.CHECK_FUNCS('inotify_init')
135 if "HAVE_LINUX_INOTIFY_H" in conf
.env
and "HAVE_INOTIFY_INIT" in conf
.env
:
136 conf
.DEFINE('HAVE_INOTIFY', 1)
138 # Check for kernel change notify support
141 #define F_NOTIFY 1026
144 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
145 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain
=False, execute
=True,
146 headers
='fcntl.h signal.h',
147 msg
="Checking for kernel change notify support")
149 # Check for Linux kernel oplocks
151 #include <sys/types.h>
155 #define F_NOTIFY 1026
158 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
159 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain
=False, execute
=True,
160 msg
="Checking for Linux kernel oplocks")
162 # Check for IRIX kernel oplock types
163 conf
.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
164 'HAVE_KERNEL_OPLOCKS_IRIX', headers
='fcntl.h',
165 msg
="Checking for IRIX kernel oplock types")
167 # Check for krenel share modes
169 #include <sys/types.h>
172 #include <sys/file.h>
178 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
179 }''', 'HAVE_KERNEL_SHARE_MODES', addmain
=False, execute
=True,
180 msg
="Checking for krenel share modes")
182 # Check for various members of the stat structure
183 conf
.CHECK_TYPES('blksize_t blkcnt_t')
184 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define
='HAVE_STAT_ST_BLOCKS',
185 headers
='sys/stat.h')
186 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define
='HAVE_STAT_ST_BLKSIZE',
187 headers
='sys/stat.h')
189 # Check for POSIX capability support
190 conf
.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers
='sys/capability.h')
192 if "HAVE_SYS_CAPABILITY_H" in conf
.env
:
196 if (!(cap = cap_get_proc())) exit(1);
198 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
199 cap_set_proc(cap);''',
200 'HAVE_POSIX_CAPABILITIES', execute
=True, lib
="cap",
201 headers
='sys/capability.h',
202 msg
="Checking whether POSIX capabilities are available")
204 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
205 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
207 if conf
.CONFIG_SET("HAVE_RPC_RPC_H"):
208 conf
.CHECK_TYPE('int16', headers
='rpc/rpc.h',
209 define
='HAVE_INT16_FROM_RPC_RPC_H',
210 msg
="Checking for int16 typedef included by rpc/rpc.h")
211 conf
.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
212 headers
='sys/types.h rpc/rpc.h',
213 msg
="Checking for uint16 typedef included by rpc/rpc.h")
214 conf
.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
215 headers
='sys/types.h rpc/rpc.h',
216 msg
="Checking for int32 typedef included by rpc/rpc.h")
217 conf
.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
218 headers
='sys/types.h rpc/rpc.h',
219 msg
="Checking for uint32 typedef included by rpc/rpc.h")
220 conf
.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
221 headers
='sys/types.h sys/acl.h rpcsvc/nis.h',
222 msg
="Checking for broken nisplus include files")
224 # Check if the compiler will optimize out functions
227 this_function_does_not_exist();
230 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
231 msg
="Checking if the compiler will optimize out functions")
233 # Check if the compiler supports the LL suffix on long long integers
235 conf
.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
237 msg
="Checking for LL suffix on long long integers")
240 _acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
241 attropen attr_remove attr_removef attr_set attr_setf backtrace_symbols
242 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
243 __closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
244 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
245 extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
246 extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
247 extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
248 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
249 fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
250 _fork __fork fremoveea fremovexattr fseek64 fseeko64 fsetea
251 fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
252 ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
253 getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
254 getgrent getgrnam getgrouplist getmntent getpagesize
255 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
256 glob grantpt hstrerror initgroups innetgr
257 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
258 llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
259 lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
260 __lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
261 nl_langinfo _open __open open64 _open64 __open64 _opendir __opendir
262 opendir64 pathconf poll posix_fallocate posix_fallocate64
263 posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
264 pwrite _pwrite __pwrite pwrite64 _pwrite64
265 __pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
266 __readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
267 seekdir64 select setea setenv setgidx setgroups setlocale setluid
268 setmntent setpgid setpriv setproplist setsid setuidx
269 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
270 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
271 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
272 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
273 utimensat vsyslog _write __write __xstat
276 conf
.CHECK_TYPE('struct timespec', headers
='sys/time.h time.h')
278 conf
.CHECK_SAMBA3_CHARSET() # see build/charset.py
280 # FIXME: these should be tests for features, but the old build system just
283 host_os
= sys
.platform
285 # Python doesn't have case switches... :/
286 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
287 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
289 conf
.SET_TARGET_TYPE('sunacl', 'EMPTY')
290 if (host_os
.rfind('linux') > -1) or (host_os
.rfind('gnu') > -1) or (host_os
.rfind('qnx') > -1):
291 if host_os
.rfind('linux') > -1:
292 conf
.DEFINE('LINUX', '1')
293 elif host_os
.rfind('qnx') > -1:
294 conf
.DEFINE('QNX', '1')
295 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
296 elif (host_os
.rfind('darwin') > -1):
297 conf
.DEFINE('DARWINOS', 1)
298 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
299 conf
.ADD_CFLAGS('-fno-common')
300 elif (host_os
.rfind('freebsd') > -1):
301 if conf
.CHECK_HEADERS('sunacl.h'):
302 conf
.define('HAVE_FREEBSD_SUNACL_H', '1')
303 conf
.CHECK_FUNCS_IN('acl', 'sunacl')
304 # FIXME: Add more checks here.
306 print "Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os
308 #FIXME: add more checks
309 if Options
.options
.with_acl_support
:
310 if host_os
.rfind('linux') > -1:
311 conf
.CHECK_FUNCS_IN('acl_get_file', 'acl')
312 conf
.CHECK_FUNCS_IN('getxattr', 'attr')
313 if conf
.CHECK_CODE('''
316 acl_entry_t *entry_p;
317 return acl_get_entry(acl, entry_id, entry_p);
320 headers
='sys/types.h sys/acl.h', link
=False,
321 msg
="Checking for POSIX ACL support") :
323 acl_permset_t permset_d;
325 return acl_get_perm_np(permset_d, perm);
327 'HAVE_ACL_GET_PERM_NP',
328 headers
='sys/types.h sys/acl.h', link
=True,
329 msg
="Checking whether acl_get_perm_np() is available")
331 conf
.DEFINE('HAVE_NO_ACLS', 1)
332 conf
.SET_TARGET_TYPE('acl', 'EMPTY')
333 conf
.SET_TARGET_TYPE('attr', 'EMPTY')
335 conf
.DEFINE('HAVE_NO_ACLS', 1)
336 conf
.SET_TARGET_TYPE('acl', 'EMPTY')
337 conf
.SET_TARGET_TYPE('attr', 'EMPTY')
339 if conf
.CHECK_FUNCS('dirfd'):
340 conf
.DEFINE('HAVE_DIRFD_DECL', 1)
342 conf
.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
343 'HAVE_STATFS_F_FSID',
344 msg
="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
345 headers
='sys/types.h sys/statfs.h',
348 if conf
.CONFIG_SET('HAVE_FALLOCATE'):
350 #if defined(HAVE_UNISTD_H)
353 #include <sys/types.h>
356 #if defined(HAVE_LINUX_FALLOC_H)
357 #include <linux/falloc.h>
359 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
360 'HAVE_LINUX_FALLOCATE',
361 msg
="Checking whether the Linux 'fallocate' function is available")
362 if conf
.CONFIG_SET('HAVE_FALLOCATE64'):
364 #if defined(HAVE_UNISTD_H)
367 #include <sys/types.h>
370 #if defined(HAVE_LINUX_FALLOC_H)
371 #include <linux/falloc.h>
373 int ret = fallocate64(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
374 'HAVE_LINUX_FALLOCATE64',
375 msg
="Checking whether the Linux 'fallocate64' function is available")
377 #if defined(HAVE_UNISTD_H)
381 ssize_t err = readahead(0,0,0x80000);''',
382 'HAVE_LINUX_READAHEAD',
383 msg
="Checking whether Linux readahead is available")
384 conf
.CHECK_DECLS('readahead', headers
='fcntl.h', always
=True)
387 #include <sys/types.h>
388 #include <sys/socket.h>],
391 int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);''',
393 msg
="Checking whether we can use SO_PEERCRED to get socket credentials")
396 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
397 #include <sys/types.h>
402 'HAVE_EXPLICIT_LARGEFILE_SUPPORT',
403 msg
="Checking whether large file support can be enabled")
405 default_static_modules
=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam pdb_ldap
406 auth_sam auth_unix auth_winbind auth_wbc auth_server
407 auth_domain auth_builtin auth_netlogond vfs_default
408 nss_info_template idmap_ldap idmap_tdb idmap_passdb
411 default_shared_modules
=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
412 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
413 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850
414 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb
415 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
416 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
417 vfs_crossrename vfs_linux_xfs_sgid
418 vfs_time_audit idmap_autorid''')
420 if Options
.options
.developer
:
421 default_static_modules
.extend(TO_LIST('pdb_ads'))
422 default_shared_modules
.extend(TO_LIST('charset_weird perfcount_test'))
424 if Options
.options
.with_acl_support
and conf
.CONFIG_SET('HAVE_POSIX_ACLS'):
425 default_static_modules
.extend(TO_LIST('vfs_posixacl'))
427 if conf
.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
428 default_shared_modules
.extend(TO_LIST('vfs_zfsacl'))
430 if conf
.CONFIG_SET('HAVE_DIRFD_DECL'):
431 default_shared_modules
.extend(TO_LIST('vfs_syncops vfs_dirsort'))
433 if conf
.CONFIG_SET('HAVE_STATFS_F_FSID'):
434 default_shared_modules
.extend(TO_LIST('vfs_fileid'))
436 explicit_shared_modules
= TO_LIST(Options
.options
.shared_modules
, delimiter
=',')
437 explicit_static_modules
= TO_LIST(Options
.options
.static_modules
, delimiter
=',')
439 final_static_modules
= default_static_modules
440 final_shared_modules
= default_shared_modules
442 for m
in explicit_static_modules
:
443 if m
in final_shared_modules
:
444 final_shared_modules
.remove(m
)
445 final_static_modules
.append(m
)
446 for m
in explicit_shared_modules
:
447 if m
in final_static_modules
:
448 final_static_modules
.remove(m
)
449 final_shared_modules
.append(m
)
451 conf
.env
['static_modules'] = final_static_modules
452 conf
.env
['shared_modules'] = final_shared_modules
454 conf
.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules
), quote
=True)
459 prefixes
= ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
460 conf
.env
['MODULE_PREFIXES'] = prefixes
462 for m
in final_static_modules
:
464 if not p
in static_list
:
466 static_list
[p
].append(m
)
467 for m
in final_shared_modules
:
469 if not p
in shared_list
:
471 shared_list
[p
].append(m
)
474 static_env
= "%s_STATIC" % p
.upper()
475 shared_env
= "%s_SHARED" % p
.upper()
476 conf
.env
[static_env
] = []
477 conf
.env
[shared_env
] = []
480 for entry
in static_list
[p
]:
481 decl_list
+= "extern NTSTATUS %s_init(void); " % entry
482 conf
.env
[static_env
].append('%s' % entry
)
483 decl_list
= decl_list
.rstrip()
484 conf
.DEFINE('static_decl_%s' % p
, decl_list
)
485 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(); }' % '_init(); '.join(static_list
[p
]))
487 conf
.DEFINE('static_decl_%s' % p
, '')
488 conf
.DEFINE('static_init_%s' % p
, '{}')
490 for entry
in shared_list
[p
]:
491 conf
.DEFINE('%s_init' % entry
, 'init_samba_module')
492 conf
.env
[shared_env
].append('%s' % entry
)
494 if Options
.options
.with_winbind
:
495 conf
.env
.build_winbind
= True
496 conf
.DEFINE('WITH_WINBIND', '1')
498 conf
.find_program('awk', var
='AWK')
499 conf
.find_program('perl', var
='PERL')
501 # Darwin has extra options to xattr-family functions
502 conf
.CHECK_CODE('getxattr(0, 0, 0, 0, 0, 0);',
504 msg
="Checking whether xattr interface takes additional options",
505 headers
='sys/types.h attr/xattr.h sys/xattr.h')
507 conf
.CHECK_HEADERS('asm/types.h')
509 conf
.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
510 headers
='unistd.h sys/types.h',
511 msg
="Checking for major macro")
513 conf
.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
514 headers
='unistd.h sys/types.h',
515 msg
="Checking for minor macro")
517 conf
.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
518 headers
='unistd.h sys/types.h dirent.h',
519 define
='HAVE_DIRENT_D_OFF')
521 conf
.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
522 conf
.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
523 msg
="Checking for setnetgrent prototype",
524 headers
='netdb.h netgroup.h',
525 cflags
="-Werror-implicit-function-declaration")
526 conf
.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
527 msg
="Checking for getnetgrent prototype",
528 headers
='netdb.h netgroup.h',
529 cflags
="-Werror-implicit-function-declaration")
530 conf
.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
531 msg
="Checking for endnetgrent prototype",
532 headers
='netdb.h netgroup.h',
533 cflags
="-Werror-implicit-function-declaration")
535 #FIXME: Should just be set when krb5 and ldap requirements are fulfilled
536 if Options
.options
.with_ads
:
537 conf
.DEFINE('WITH_ADS', '1')
540 conf
.find_program('cups-config', var
='CUPS_CONFIG')
541 if conf
.env
.CUPS_CONFIG
and Options
.options
.with_cups
:
542 conf
.check_cfg(path
="cups-config", args
="--cflags --ldflags --libs",
543 package
="", uselib_store
="cups")
544 conf
.CHECK_HEADERS('cups/cups.h cups/language.h', lib
='cups')
545 conf
.CHECK_LIB('cups')
546 conf
.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
548 # define an empty subsystem for cups, to allow it to be used as an empty dependency
549 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
552 if Options
.options
.with_ldap
:
553 conf
.CHECK_HEADERS('ldap.h lber.h')
554 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
555 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
556 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
557 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
558 # SASL wrapping hooks
559 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
560 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
561 conf
.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
563 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
565 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
566 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
568 conf
.CHECK_FUNCS_IN('ldap_init ldap_initialize ldap_set_rebind_proc', 'ldap')
569 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
571 # Check if ldap_set_rebind_proc() takes three arguments
572 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
573 'LDAP_SET_REBIND_PROC_ARGS',
574 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
575 headers
='ldap.h lber.h', link
=False):
576 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
578 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
580 # last but not least, if ldap_init() exists, we want to use ldap
581 if conf
.CONFIG_SET('HAVE_LDAP_INIT'):
582 conf
.DEFINE('HAVE_LDAP', '1')
583 conf
.DEFINE('LDAP_DEPRECATED', '1')
584 conf
.env
['SMBLDAP'] = 'lib/smbldap.c'
585 conf
.env
['SMBLDAPUTIL'] = 'lib/smbldap_util.c'
587 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
588 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
591 conf
.find_program('krb5-config', var
='KRB5_CONFIG')
592 if conf
.env
.KRB5_CONFIG
and Options
.options
.with_krb5
:
593 conf
.check_cfg(path
="krb5-config", args
="--cflags --libs",
594 package
="gssapi", uselib_store
="krb5")
595 conf
.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib
='krb5')
596 conf
.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h', lib
='krb5')
598 if conf
.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
599 conf
.env
['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
601 conf
.CHECK_FUNCS_IN('_et_list', 'com_err')
602 conf
.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
603 conf
.CHECK_FUNCS_IN('crypto', 'des_set_key')
604 conf
.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
605 conf
.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
606 if conf
.CHECK_FUNCS_IN('gss_display_status', 'gssapi gssapi_krb5'):
607 conf
.DEFINE('HAVE_GSSAPI', '1')
608 conf
.CHECK_FUNCS_IN('gss_wrap_iov', 'gssapi gssapi_krb5 krb5')
609 conf
.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
611 krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
612 krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
613 krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
614 krb5_auth_con_setuseruserkey krb5_locate_kdc krb5_get_permitted_enctypes
615 krb5_get_default_in_tkt_etypes krb5_free_data_contents
616 krb5_principal_get_comp_string krb5_free_unparsed_name
617 krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
618 krb5_krbhst_get_addrinfo krb5_c_enctype_compare krb5_enctypes_compatible_keys
619 krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
620 krb5_verify_checksum krb5_c_verify_checksum krb5_principal_compare_any_realm
621 krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
622 krb5_get_renewed_creds krb5_get_kdc_cred krb5_free_error_contents
623 initialize_krb5_error_table krb5_get_init_creds_opt_alloc
624 krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
625 krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
626 krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
627 krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
629 conf
.CHECK_DECLS('''krb5_get_credentials_for_user
630 krb5_auth_con_set_req_cksumtype''',
631 headers
='krb5.h', always
=True)
632 conf
.CHECK_VARIABLE('AP_OPTS_USE_SUBKEY', headers
='krb5.h')
633 conf
.CHECK_VARIABLE('KV5M_KEYTAB', headers
='krb5.h')
634 conf
.CHECK_VARIABLE('KRB5_KU_OTHER_CKSUM', headers
='krb5.h')
635 conf
.CHECK_VARIABLE('KRB5_KEYUSAGE_APP_DATA_CKSUM', headers
='krb5.h')
636 conf
.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'key', headers
='krb5.h',
637 define
='HAVE_KRB5_KEYTAB_ENTRY_KEY')
638 conf
.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'keyblock', headers
='krb5.h',
639 define
='HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK')
640 conf
.CHECK_STRUCTURE_MEMBER('krb5_address', 'magic', headers
='krb5.h',
641 define
='HAVE_MAGIC_IN_KRB5_ADDRESS')
642 conf
.CHECK_STRUCTURE_MEMBER('krb5_address', 'addrtype', headers
='krb5.h',
643 define
='HAVE_ADDRTYPE_IN_KRB5_ADDRESS')
644 conf
.CHECK_STRUCTURE_MEMBER('krb5_ticket', 'enc_part2', headers
='krb5.h',
645 define
='HAVE_KRB5_TKT_ENC_PART2')
646 conf
.CHECK_STRUCTURE_MEMBER('krb5_creds', 'keyblock', headers
='krb5.h',
647 define
='HAVE_KRB5_KEYBLOCK_IN_CREDS')
648 conf
.CHECK_STRUCTURE_MEMBER('krb5_creds', 'session', headers
='krb5.h',
649 define
='HAVE_KRB5_SESSION_IN_CREDS')
650 conf
.CHECK_STRUCTURE_MEMBER('krb5_ap_req', 'ticket', headers
='krb5.h',
651 define
='HAVE_TICKET_POINTER_IN_KRB5_AP_REQ')
653 conf
.CHECK_TYPE('krb5_encrypt_block', headers
='krb5.h')
658 krb5_enctype enctype;
659 enctype = ticket.enc_part.enctype;
660 kvno = ticket.enc_part.kvno;
662 'KRB5_TICKET_HAS_KEYINFO',
663 headers
='krb5.h', link
=False,
664 msg
="Checking whether the krb5_ticket structure contains the kvno and enctype")
667 krb5_get_init_creds_opt *opt = NULL;
668 krb5_get_init_creds_opt_free(ctx, opt);
670 'KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT',
671 headers
='krb5.h', link
=False,
672 msg
="Checking whether krb5_get_init_creds_opt_free takes a context argument")
673 conf
.CHECK_CODE('krb5_mk_error(0,0,0)',
674 'HAVE_SHORT_KRB5_MK_ERROR_INTERFACE',
675 headers
='krb5.h', link
=False,
676 msg
="Checking whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal")
678 const krb5_data *pkdata;
679 krb5_context context;
680 krb5_principal principal;
681 pkdata = krb5_princ_component(context, principal, 0);
683 'HAVE_KRB5_PRINC_COMPONENT',
684 headers
='krb5.h', lib
='krb5',
685 msg
="Checking whether krb5_princ_component is available")
690 krb5_enctype_to_string(1, buf, 256);
693 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG',
694 headers
='krb5.h', lib
='krb5',
695 addmain
=False, cflags
='-Werror',
696 msg
="Checking whether krb5_enctype_to_string takes size_t argument")
700 krb5_context context = NULL;
702 krb5_enctype_to_string(context, 1, &str);
706 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG',
707 headers
='krb5.h stdlib.h', lib
='krb5',
708 addmain
=False, cflags
='-Werror',
709 msg
="Checking whether krb5_enctype_to_string takes krb5_context argument")
712 krb5_context ctx = NULL;
713 krb5_principal princ = NULL;
714 const char *str = krb5_princ_realm(ctx, princ)->data;
717 'HAVE_KRB5_PRINC_REALM',
718 headers
='krb5.h', lib
='krb5',
720 msg
="Checking whether the macro krb5_princ_realm is defined")
721 if conf
.CHECK_CODE('''krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);''',
722 'KRB5_VERIFY_CHECKSUM_ARGS',
723 headers
='krb5.h', lib
='krb5',
724 msg
="Checking whether krb5_verify_checksum takes 7 arguments"):
725 conf
.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '7')
727 conf
.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '6')
730 krb5_enctype enctype;
731 enctype = ENCTYPE_ARCFOUR_HMAC_MD5;
733 '_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5',
734 headers
='krb5.h', lib
='krb5',
735 msg
="Checking whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available");
737 krb5_keytype keytype;
738 keytype = KEYTYPE_ARCFOUR_56;
740 '_HAVE_KEYTYPE_ARCFOUR_56',
741 headers
='krb5.h', lib
='krb5',
742 msg
="Checking whether the HAVE_KEYTYPE_ARCFOUR_56 key type definition is available");
743 if conf
.CONFIG_SET('_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and conf
.CONFIG_SET('_HAVE_KEYTYPE_ARCFOUR_56'):
744 conf
.DEFINE('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', '1')
747 krb5_enctype enctype;
748 enctype = ENCTYPE_ARCFOUR_HMAC;
750 'HAVE_ENCTYPE_ARCFOUR_HMAC',
751 headers
='krb5.h', lib
='krb5',
752 msg
="Checking whether the ENCTYPE_ARCFOUR_HMAC key type definition is available");
755 krb5_context context;
757 krb5_init_context(&context);
758 return krb5_kt_resolve(context, "WRFILE:api", &keytab);
760 'HAVE_WRFILE_KEYTAB',
761 headers
='krb5.h', lib
='krb5', execute
=True,
762 msg
="Checking whether the WRFILE:-keytab is supported");
764 conf
.DEFINE('HAVE_KRB5', '1')
767 conf
.SET_TARGET_TYPE('krb5', 'EMPTY')
768 conf
.SET_TARGET_TYPE('gssapi', 'EMPTY')
769 conf
.SET_TARGET_TYPE('gssapi_krb5', 'EMPTY')
770 conf
.SET_TARGET_TYPE('com_err', 'EMPTY')
771 conf
.SET_TARGET_TYPE('k5crypto', 'EMPTY')
773 if Options
.options
.with_utmp
:
774 conf
.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
775 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers
='utmp.h',
776 define
='HAVE_UT_UT_NAME')
777 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers
='utmp.h',
778 define
='HAVE_UT_UT_USER')
779 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers
='utmp.h',
780 define
='HAVE_UT_UT_ID')
781 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers
='utmp.h',
782 define
='HAVE_UT_UT_HOST')
783 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers
='utmp.h',
784 define
='HAVE_UT_UT_TIME')
785 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers
='utmp.h',
786 define
='HAVE_UT_UT_TV')
787 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers
='utmp.h',
788 define
='HAVE_UT_UT_TYPE')
789 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers
='utmp.h',
790 define
='HAVE_UT_UT_PID')
791 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers
='utmp.h',
792 define
='HAVE_UT_UT_EXIT')
793 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers
='utmp.h',
794 define
='HAVE_UT_UT_ADDR_V6')
795 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers
='utmp.h',
796 define
='HAVE_UT_UT_ADDR')
797 conf
.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers
='utmpx.h',
798 define
='HAVE_UX_UT_SYSLEN')
799 conf
.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
800 'PUTUTLINE_RETURNS_UTMP', headers
='utmp.h',
801 msg
="Checking whether pututline returns pointer")
802 conf
.DEFINE('WITH_UTMP', 1)
804 if Options
.options
.with_avahi
:
805 conf
.env
.with_avahi
= True
806 if not conf
.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf
.env
.with_avahi
= False
807 if not conf
.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf
.env
.with_avahi
= False
808 if not conf
.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf
.env
.with_avahi
= False
809 if conf
.env
.with_avahi
:
810 conf
.DEFINE('WITH_AVAHI_SUPPORT', 1)
812 conf
.SET_TARGET_TYPE('avahi-common', 'EMPTY')
813 conf
.SET_TARGET_TYPE('avahi-client', 'EMPTY')
815 if Options
.options
.with_iconv
:
816 conf
.env
.with_iconv
= True
817 if not conf
.CHECK_FUNCS_IN('iconv_open', 'iconv', headers
='iconv.h'):
818 conf
.env
.with_iconv
= False
819 if conf
.env
.with_iconv
:
820 conf
.DEFINE('HAVE_ICONV', 1)
822 if Options
.options
.with_pam
:
823 conf
.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
824 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
825 print "--with-pam=yes but pam_appl.h not found"
827 conf
.CHECK_FUNCS_IN('pam_get_data', 'pam', mandatory
=True)
828 conf
.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
829 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
830 print "--with-pam=yes but pam_modules.h not found"
832 conf
.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
833 conf
.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
834 conf
.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
836 #if defined(HAVE_SECURITY_PAM_APPL_H)
837 #include <security/pam_appl.h>
838 #elif defined(HAVE_PAM_PAM_APPL_H)
839 #include <pam/pam_appl.h>
841 pam_set_item(0, PAM_RHOST, 0);
845 msg
="Checking whether PAM_RHOST is available");
847 #if defined(HAVE_SECURITY_PAM_APPL_H)
848 #include <security/pam_appl.h>
849 #elif defined(HAVE_PAM_PAM_APPL_H)
850 #include <pam/pam_appl.h>
852 pam_set_item(0, PAM_TTY, 0);
856 msg
="Checking whether PAM_TTY is available");
858 #if (!defined(LINUX))
860 #define PAM_EXTERN extern
861 #if defined(HAVE_SECURITY_PAM_APPL_H)
862 #include <security/pam_appl.h>
863 #elif defined(HAVE_PAM_PAM_APPL_H)
864 #include <pam/pam_appl.h>
869 #if defined(HAVE_SECURITY_PAM_MODULES_H)
870 #include <security/pam_modules.h>
871 #elif defined(HAVE_PAM_PAM_MODULES_H)
872 #include <pam/pam_modules.h>
875 #if defined(HAVE_SECURITY__PAM_MACROS_H)
876 #include <security/_pam_macros.h>
877 #elif defined(HAVE_PAM__PAM_MACROS_H)
878 #include <pam/_pam_macros.h>
881 #ifdef HAVE_SECURITY_PAM_EXT_H
882 #include <security/pam_ext.h>
885 int i; i = PAM_RADIO_TYPE;
887 'HAVE_PAM_RADIO_TYPE',
889 msg
="Checking whether PAM_RADIO_TYPE is available");
890 conf
.DEFINE('WITH_PAM', 1)
891 conf
.DEFINE('WITH_PAM_MODULES', 1)
895 seteuid
= conf
.CHECK_CODE('''
896 #define AUTOCONF_TEST 1
897 #define USE_SETREUID 1
898 #include "./lib/util_sec.c"
903 msg
="Checking whether setreuid is available")
905 seteuid
= conf
.CHECK_CODE('''
906 #define AUTOCONF_TEST 1
907 #define USE_SETRESUID 1
908 #include "./lib/util_sec.c"
913 msg
="Checking whether setresuid is available")
915 seteuid
= conf
.CHECK_CODE('''
916 #define AUTOCONF_TEST 1
917 #define USE_SETEUID 1
918 #include "./lib/util_sec.c"
923 msg
="Checking whether seteuid is available")
925 seteuid
= conf
.CHECK_CODE('''
926 #define AUTOCONF_TEST 1
927 #define USE_SETUIDX 1
928 #include "./lib/util_sec.c"
934 msg
="Checking whether setuidx is available")
935 if Options
.options
.with_dnsupdate
:
936 conf
.CHECK_HEADERS('uuid/uuid.h')
937 conf
.CHECK_FUNCS_IN('uuid_generate', 'uuid')
938 if not conf
.CONFIG_SET('HAVE_UUID_UUID_H') and not conf
.CONFIG_SET('HAVE_UUID_GENERATE'):
939 print "--with-dnsupdate=yes but uuid support not sufficient"
941 conf
.DEFINE('WITH_DNS_UPDATES', 1)
943 conf
.SET_TARGET_TYPE('uuid', 'EMPTY')
944 conf
.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
945 if Options
.options
.developer
:
946 if conf
.CONFIG_SET('HAVE_VALGRIND_H') or conf
.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
947 conf
.DEFINE('VALGRIND', '1')
949 conf
.SAMBA_CONFIG_H('include/config.h')
952 "build 'tags' file using ctags"
954 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
955 cmd
= 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
956 print("Running: %s" % cmd
)