6 from optparse
import SUPPRESS_HELP
7 sys
.path
.insert(0, srcdir
+"/buildtools/wafsamba")
8 sys
.path
.insert(0, "source3")
9 import wafsamba
, Options
, Logs
, Utils
, Scripting
11 import samba_utils
, samba_version
14 Options
.default_prefix
= '/usr/local/samba'
18 opt
.add_option('--with-static-modules',
19 help=("Comma-separated list of names of modules to statically link in"),
20 action
="store", dest
='static_modules', default
=None)
21 opt
.add_option('--with-shared-modules',
22 help=("Comma-separated list of names of modules to build shared"),
23 action
="store", dest
='shared_modules', default
=None)
25 opt
.SAMBA3_ADD_OPTION('winbind')
26 opt
.SAMBA3_ADD_OPTION('ads')
27 opt
.SAMBA3_ADD_OPTION('ldap')
28 opt
.SAMBA3_ADD_OPTION('cups', with_name
="enable", without_name
="disable")
29 opt
.SAMBA3_ADD_OPTION('iprint', with_name
="enable", without_name
="disable")
30 opt
.SAMBA3_ADD_OPTION('pam')
31 opt
.SAMBA3_ADD_OPTION('pam_smbpass')
32 opt
.SAMBA3_ADD_OPTION('quotas')
33 opt
.SAMBA3_ADD_OPTION('sendfile-support')
34 opt
.SAMBA3_ADD_OPTION('utmp')
35 opt
.SAMBA3_ADD_OPTION('pthreadpool', with_name
="enable", without_name
="disable", default
=True)
36 opt
.SAMBA3_ADD_OPTION('avahi', with_name
="enable", without_name
="disable")
37 opt
.SAMBA3_ADD_OPTION('iconv')
38 opt
.SAMBA3_ADD_OPTION('acl-support')
39 opt
.SAMBA3_ADD_OPTION('dnsupdate')
40 opt
.SAMBA3_ADD_OPTION('syslog')
41 opt
.SAMBA3_ADD_OPTION('automount')
42 opt
.SAMBA3_ADD_OPTION('aio-support')
43 opt
.SAMBA3_ADD_OPTION('dmapi', default
=None) # None means autodetection
44 opt
.SAMBA3_ADD_OPTION('fam', default
=None) # None means autodetection
45 opt
.SAMBA3_ADD_OPTION('profiling-data', default
=False)
46 opt
.SAMBA3_ADD_OPTION('libarchive', default
=None)
48 opt
.SAMBA3_ADD_OPTION('cluster-support', default
=None)
50 opt
.SAMBA3_ADD_OPTION('regedit', default
=None)
52 opt
.SAMBA3_ADD_OPTION('fake-kaserver',
53 help=("Include AFS fake-kaserver support"), default
=False)
55 opt
.add_option('--with-ctdb-dir',
56 help=("Directory under which ctdb is installed"),
57 action
="store", dest
='ctdb_dir', default
=None)
58 opt
.add_option('--enable-old-ctdb',
59 help=("enable building against (too) old version of ctdb (default=false)"),
60 action
="store_true", dest
='enable_old_ctdb', default
=False)
62 opt
.add_option('--with-libcephfs',
63 help=("Directory under which libcephfs is installed"),
64 action
="store", dest
='libcephfs_dir', default
=None)
66 opt
.SAMBA3_ADD_OPTION('glusterfs', with_name
="enable", without_name
="disable", default
=True)
68 opt
.add_option('--enable-vxfs',
69 help=("enable support for VxFS (default=no)"),
70 action
="store_true", dest
='enable_vxfs', default
=False)
74 from samba_utils
import TO_LIST
76 default_static_modules
= []
77 default_shared_modules
= []
79 if Options
.options
.developer
:
80 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
81 conf
.env
.developer
= True
83 if sys
.platform
!= 'openbsd5':
84 conf
.ADD_LDFLAGS("-Wl,--export-dynamic", testflags
=True)
86 conf
.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
87 conf
.CHECK_HEADERS('linux/falloc.h')
89 conf
.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
90 conf
.CHECK_FUNCS('strtol strchr strupr chflags')
91 conf
.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
92 conf
.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
93 conf
.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
94 conf
.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
95 conf
.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
96 conf
.CHECK_FUNCS('atexit grantpt posix_openpt fallocate posix_fallocate')
97 conf
.CHECK_FUNCS('fseeko setluid')
98 conf
.CHECK_FUNCS('getpwnam', headers
='sys/types.h pwd.h')
99 conf
.CHECK_FUNCS('fdopendir')
100 conf
.CHECK_FUNCS('fstatat')
101 conf
.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
102 conf
.CHECK_FUNCS('syslog vsyslog timegm setlocale')
103 conf
.CHECK_FUNCS_IN('nanosleep', 'rt')
104 conf
.CHECK_FUNCS('lutimes futimes utimensat futimens')
105 conf
.CHECK_FUNCS('mlock munlock mlockall munlockall')
106 conf
.CHECK_FUNCS('memalign posix_memalign hstrerror')
107 conf
.CHECK_FUNCS('shmget')
108 conf
.CHECK_FUNCS_IN('shm_open', 'rt', checklibc
=True)
109 #FIXME: for some reason this one still fails
110 conf
.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
111 conf
.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
112 conf
.CHECK_FUNCS_IN('dn_expand', 'inet')
113 conf
.CHECK_DECLS('fdatasync', reverse
=True)
114 conf
.CHECK_DECLS('readahead', reverse
=True, headers
='fcntl.h')
116 if conf
.CHECK_CODE('''
117 #if defined(HAVE_UNISTD_H)
120 long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
124 conf
.CHECK_DECLS('splice', reverse
=True, headers
='fcntl.h')
126 # Check for inotify support
127 conf
.CHECK_HEADERS('sys/inotify.h')
128 if "HAVE_SYS_INOTIFY_H" 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 kernel 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 kernel share modes")
178 if Options
.options
.with_fam
is None:
180 elif Options
.options
.with_fam
== True:
183 if check_for_fam
and conf
.CHECK_HEADERS('fam.h'):
184 if conf
.CHECK_FUNCS_IN('FAMOpen2', 'fam'):
186 elif conf
.CHECK_FUNCS_IN('FAMOpen2', 'fam C'):
187 samba_fam_libs
='fam C'
188 conf
.CHECK_TYPE('enum FAMCodes', headers
='fam.h',
189 define
='HAVE_FAM_H_FAMCODES_TYPEDEF',
190 msg
='Checking whether enum FAMCodes is available')
191 conf
.CHECK_FUNCS_IN('FAMNoExists', 'fam')
193 if samba_fam_libs
is not None:
194 conf
.DEFINE('SAMBA_FAM_LIBS', samba_fam_libs
)
196 if Options
.options
.with_fam
== True:
197 conf
.fatal('FAM support requested, but no suitable FAM library found')
199 Logs
.warn('no suitable FAM library found')
201 # check for libarchive (tar command in smbclient)
202 # None means autodetect, True/False means enable/disable
203 conf
.env
['archive_lib'] = ''
204 if Options
.options
.with_libarchive
is not False:
205 libarchive_mandatory
= Options
.options
.with_libarchive
== True
206 Logs
.info("Checking for libarchive existence")
207 if conf
.CHECK_BUNDLED_SYSTEM('libarchive', minversion
='3.1.2'):
208 conf
.env
['archive_lib'] = 'libarchive'
209 elif libarchive_mandatory
:
210 conf
.fatal('libarchive support requested, but no suitable pkgconfig found')
212 # check for DMAPI libs
213 if Options
.options
.with_dmapi
== False:
217 Logs
.info("Checking for DMAPI library existence")
219 if conf
.CHECK_FUNCS_IN('dm_get_eventlist', 'dm'):
220 samba_dmapi_lib
= 'dm'
222 if conf
.CHECK_FUNCS_IN('dm_get_eventlist', 'jfsdm'):
223 samba_dmapi_lib
= 'jfsdm'
225 if conf
.CHECK_FUNCS_IN('dm_get_eventlist', 'dmapi'):
226 samba_dmapi_lib
= 'dmapi'
228 if conf
.CHECK_FUNCS_IN('dm_get_eventlist', 'xdsm'):
229 samba_dmapi_lib
= 'xdsm'
230 # only bother to test headers and compilation when a candidate
231 # library has been found
232 if samba_dmapi_lib
== '':
234 broken_dmapi
= "no suitable DMAPI library found"
237 conf
.CHECK_HEADERS('sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h dmapi.h')
239 #include <time.h> /* needed by Tru64 */
240 #include <sys/types.h> /* needed by AIX */
241 #ifdef HAVE_XFS_DMAPI_H
242 #include <xfs/dmapi.h>
243 #elif defined(HAVE_SYS_DMI_H)
245 #elif defined(HAVE_SYS_JFSDMAPI_H)
246 #include <sys/jfsdmapi.h>
247 #elif defined(HAVE_SYS_DMAPI_H)
248 #include <sys/dmapi.h>
249 #elif defined(HAVE_DMAPI_H)
253 /* This link test is designed to fail on IRI 6.4, but should
254 * succeed on Linux, IRIX 6.5 and AIX.
256 int main(int argc, char **argv)
259 dm_eventset_t events;
260 /* This doesn't take an argument on IRIX 6.4. */
261 dm_init_service(&version);
262 /* IRIX 6.4 expects events to be a pointer. */
263 DMEV_ISSET(DM_EVENT_READ, events);
268 'USEABLE_DMAPI_LIBRARY',
272 msg
='Checking whether DMAPI lib '+samba_dmapi_lib
+' can be used')
273 if not conf
.CONFIG_SET('USEABLE_DMAPI_LIBRARY'):
275 broken_dmapi
= "no usable DMAPI library found"
278 Logs
.info("Building with DMAPI support.")
279 conf
.env
['dmapi_lib'] = samba_dmapi_lib
280 conf
.DEFINE('USE_DMAPI', 1)
282 if Options
.options
.with_dmapi
== False:
283 Logs
.info("Building without DMAPI support (--without-dmapi).")
284 elif Options
.options
.with_dmapi
== True:
285 Logs
.error("DMAPI support not available: " + broken_dmapi
)
286 conf
.fatal('DMAPI support requested but not found.');
288 Logs
.warn("Building without DMAPI support: " + broken_dmapi
)
289 conf
.env
['dmapi_lib'] = ''
291 # Check for various members of the stat structure
292 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define
='HAVE_STAT_ST_BLOCKS',
293 headers
='sys/stat.h')
294 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define
='HAVE_STAT_ST_BLKSIZE',
295 headers
='sys/stat.h')
296 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define
='HAVE_STAT_ST_FLAGS',
297 headers
='sys/types.h sys/stat.h unistd.h')
299 if "HAVE_BLKCNT_T" in conf
.env
:
301 static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 4)];''',
303 headers
='replace.h sys/types.h sys/stat.h unistd.h',
304 msg
="Checking whether blkcnt_t is 32 bit")
306 # If sizeof is 4 it can't be 8
307 if "HAVE_BLKCNT_T" in conf
.env
:
308 if not conf
.CONFIG_SET('SIZEOF_BLKCNT_T_4'):
310 static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 8)];''',
312 headers
='replace.h sys/types.h sys/stat.h unistd.h',
313 msg
="Checking whether blkcnt_t is 64 bit")
315 # Check for POSIX capability support
316 conf
.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers
='sys/capability.h')
318 if "HAVE_SYS_CAPABILITY_H" in conf
.env
:
322 if (!(cap = cap_get_proc())) exit(1);
324 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
325 cap_set_proc(cap);''',
326 'HAVE_POSIX_CAPABILITIES', execute
=True, lib
="cap",
327 headers
='sys/capability.h',
328 msg
="Checking whether POSIX capabilities are available")
330 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
331 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
333 if conf
.CONFIG_SET("HAVE_RPC_RPC_H"):
334 conf
.CHECK_TYPE('int16', headers
='rpc/rpc.h',
335 define
='HAVE_INT16_FROM_RPC_RPC_H',
336 msg
="Checking for int16 typedef included by rpc/rpc.h")
337 conf
.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
338 headers
='sys/types.h rpc/rpc.h',
339 msg
="Checking for uint16 typedef included by rpc/rpc.h")
340 conf
.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
341 headers
='sys/types.h rpc/rpc.h',
342 msg
="Checking for int32 typedef included by rpc/rpc.h")
343 conf
.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
344 headers
='sys/types.h rpc/rpc.h',
345 msg
="Checking for uint32 typedef included by rpc/rpc.h")
346 conf
.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
347 headers
='sys/types.h sys/acl.h rpcsvc/nis.h',
348 msg
="Checking for broken nisplus include files")
350 # Check if the compiler will optimize out functions
352 #include <sys/types.h>
353 size_t __unsafe_string_function_usage_here_size_t__(void);
354 #define CHECK_STRING_SIZE(d, len) (sizeof(d) != (len) && sizeof(d) != sizeof(char *))
355 static size_t push_string_check_fn(void *dest, const char *src, size_t dest_len) {
359 #define push_string_check(dest, src, dest_len) \
360 (CHECK_STRING_SIZE(dest, dest_len) \
361 ? __unsafe_string_function_usage_here_size_t__() \
362 : push_string_check_fn(dest, src, dest_len))
364 int main(int argc, char **argv) {
367 const char *foo = "bar";
368 p += 31 + push_string_check(p + 31, foo, sizeof(outbuf) - (p + 31 - outbuf));
370 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
373 msg
="Checking if the compiler will optimize out functions")
375 # Check if the compiler supports the LL suffix on long long integers
377 conf
.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
379 msg
="Checking for LL suffix on long long integers")
383 _chdir __chdir chflags chmod _close __close _closedir
384 __closedir crypt16 devnm dirfd
385 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
387 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
389 fsetxattr _fstat __fstat fsync
390 futimens futimes __fxstat getauthuid
391 getcwd _getcwd __getcwd getdents __getdents getdirentries
392 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
393 getpwanam getpwent_r getrlimit
394 glob grantpt hstrerror initgroups innetgr
395 llseek _llseek __llseek _lseek __lseek
396 _lstat __lstat lutimes
397 __lxstat memalign mknod mlock mlockall munlock munlockall
398 _open __open _opendir __opendir
399 pathconf poll posix_fallocate
400 posix_memalign pread _pread __pread
401 pwrite _pwrite __pwrite
402 rdchk _read __read _readdir __readdir
404 select setenv setgidx setgroups setlocale setluid
405 setmntent setpgid setpriv setsid setuidx
406 shmget shm_open sigaction sigblock sigprocmask sigset
408 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
409 __sys_llseek syslog _telldir __telldir timegm
410 utimensat vsyslog _write __write __xstat
413 conf
.CHECK_SAMBA3_CHARSET() # see build/charset.py
415 # FIXME: these should be tests for features, but the old build system just
417 host_os
= sys
.platform
418 Logs
.info("building on %s" % host_os
)
420 # Python doesn't have case switches... :/
421 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
422 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
424 conf
.SET_TARGET_TYPE('sunacl', 'EMPTY')
425 if (host_os
.rfind('linux') > -1) or (host_os
.rfind('gnu') > -1) or (host_os
.rfind('qnx') > -1):
426 if host_os
.rfind('linux') > -1:
427 conf
.DEFINE('LINUX', '1')
428 elif host_os
.rfind('qnx') > -1:
429 conf
.DEFINE('QNX', '1')
430 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
431 elif (host_os
.rfind('darwin') > -1):
432 conf
.DEFINE('DARWINOS', 1)
433 conf
.ADD_CFLAGS('-fno-common')
434 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
435 elif (host_os
.rfind('freebsd') > -1):
436 conf
.DEFINE('FREEBSD', 1)
437 if conf
.CHECK_HEADERS('sunacl.h'):
438 conf
.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
439 conf
.CHECK_FUNCS_IN(['acl'], 'sunacl')
440 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
441 elif (host_os
.rfind('irix') > -1):
442 conf
.DEFINE('IRIX', 1)
443 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
444 elif (host_os
.rfind('aix') > -1):
445 conf
.DEFINE('AIX', 1)
446 conf
.DEFINE('STAT_ST_BLOCKSIZE', 'DEV_BSIZE')
447 elif (host_os
.rfind('hpux') > -1):
448 conf
.DEFINE('HPUX', 1)
449 conf
.DEFINE('STAT_ST_BLOCKSIZE', '8192')
450 elif (host_os
.rfind('osf') > -1):
451 conf
.DEFINE('OSF1', 1)
452 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
454 # FIXME: Add more checks here.
456 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
458 if Options
.options
.with_acl_support
:
459 if (host_os
.rfind('hpux') > -1):
460 Logs
.info('Using HPUX ACLs')
461 conf
.DEFINE('HAVE_HPUX_ACLS',1)
462 conf
.DEFINE('POSIX_ACL_NEEDS_MASK',1)
463 default_static_modules
.extend(TO_LIST('vfs_hpuxacl'))
464 elif (host_os
.rfind('aix') > -1):
465 Logs
.info('Using AIX ACLs')
466 conf
.DEFINE('HAVE_AIX_ACLS',1)
467 default_static_modules
.extend(TO_LIST('vfs_aixacl vfs_aixacl2'))
468 elif (host_os
.rfind('darwin') > -1):
469 Logs
.warn('ACLs on Darwin currently not supported')
470 conf
.fatal("ACL support not available on Darwin/MacOS. "
471 "Use --without-acl-support for building without "
473 "ACL support is required to change permissions "
474 "from Windows clients.")
476 conf
.CHECK_FUNCS_IN(['acl_get_file'], 'acl')
477 if conf
.CHECK_CODE('''
480 acl_entry_t *entry_p;
481 return acl_get_entry(acl, entry_id, entry_p);
484 headers
='sys/types.h sys/acl.h', link
=False,
485 msg
="Checking for POSIX ACL support") :
487 acl_permset_t permset_d;
489 return acl_get_perm_np(permset_d, perm);
491 'HAVE_ACL_GET_PERM_NP',
492 headers
='sys/types.h sys/acl.h', link
=True,
493 msg
="Checking whether acl_get_perm_np() is available")
494 default_static_modules
.extend(TO_LIST('vfs_posixacl'))
495 conf
.CHECK_VARIABLE('ACL_EVERYONE', headers
='sys/acl.h')
496 elif conf
.CHECK_FUNCS_IN(['facl'], 'sec'):
497 Logs
.info('Using solaris or UnixWare ACLs')
498 conf
.DEFINE('HAVE_SOLARIS_UNIXWARE_ACLS',1)
499 default_static_modules
.extend(TO_LIST('vfs_solarisacl'))
500 elif conf
.CHECK_FUNCS_IN(['acl_get_fd'], 'pacl'):
501 Logs
.info('Using Tru64 ACLs')
502 conf
.DEFINE('HAVE_TRU64_ACLS',1)
503 default_static_modules
.extend(TO_LIST('vfs_tru64acl'))
505 conf
.fatal("ACL support not found. Try installing libacl1-dev "
507 "Otherwise, use --without-acl-support to build "
508 "without ACL support. "
509 "ACL support is required to change permissions from "
512 if conf
.CHECK_FUNCS('dirfd'):
513 conf
.DEFINE('HAVE_DIRFD_DECL', 1)
515 conf
.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
516 'HAVE_STATFS_F_FSID',
517 msg
="vfs_fileid checking for statfs() and struct statfs.f_fsid",
518 headers
='sys/types.h sys/statfs.h',
521 if conf
.CONFIG_SET('HAVE_FALLOCATE'):
523 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
524 'HAVE_LINUX_FALLOCATE',
525 msg
="Checking whether the Linux 'fallocate' function is available",
526 headers
='unistd.h sys/types.h fcntl.h linux/falloc.h')
528 ssize_t err = readahead(0,0,0x80000);''',
529 'HAVE_LINUX_READAHEAD',
530 msg
="Checking whether Linux readahead is available",
531 headers
='unistd.h fcntl.h')
532 conf
.CHECK_DECLS('readahead', headers
='fcntl.h', always
=True)
534 conf
.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
536 msg
='Checking for openat',
539 if Options
.options
.with_aio_support
:
540 conf
.CHECK_FUNCS_IN('aio_read', 'aio')
541 conf
.CHECK_FUNCS_IN('aio_read', 'rt')
542 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);',
544 msg
='Checking for asynchronous io support',
545 headers
='sys/types.h aio.h',
547 if conf
.CONFIG_SET('HAVE_AIO'):
548 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg
='Checking for aio_read', headers
='aio.h', lib
='aio rt')
549 conf
.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg
='Checking for aio_write', headers
='aio.h', lib
='aio rt')
550 conf
.CHECK_CODE('struct aiocb a; return aio_fsync(1, &a);', 'HAVE_AIO_FSYNC', msg
='Checking for aio_fsync', headers
='aio.h', lib
='aio rt')
551 conf
.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg
='Checking for aio_return', headers
='aio.h', lib
='aio rt')
552 conf
.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg
='Checking for aio_error', headers
='aio.h', lib
='aio rt')
553 conf
.CHECK_CODE('struct aiocb a; return aio_cancel(1, &a);', 'HAVE_AIO_CANCEL', msg
='Checking for aio_cancel', headers
='aio.h', lib
='aio rt')
554 conf
.CHECK_CODE('const struct aiocb * const a[1]; struct timespec t; return aio_suspend(&a, 1, &t);', 'HAVE_AIO_SUSPEND', msg
='Checking for aio_suspend', headers
='aio.h', lib
='aio rt')
555 if not conf
.CONFIG_SET('HAVE_AIO'):
556 conf
.DEFINE('HAVE_NO_AIO', '1')
558 conf
.DEFINE('HAVE_NO_AIO', '1')
560 if host_os
.rfind('linux') > -1:
561 conf
.CHECK_FUNCS_IN('io_submit', 'aio')
563 struct io_event ioev;
569 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
570 io_queue_init(128,&ctx);
571 io_prep_pwrite(ioc, 1, buf, 1, 0);
572 io_prep_pread(ioc, 1, buf, 1, 0);
573 io_set_eventfd(ioc, fd);
574 io_set_callback(ioc, (io_callback_t)(0));
575 io_submit(ctx, 1, &ioc);
576 io_getevents(ctx, 1, 1, &ioev, &ts);
578 'HAVE_LINUX_KERNEL_AIO',
579 msg
='Checking for linux kernel asynchronous io support',
580 headers
='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
587 char control[CMSG_SPACE(sizeof(int))];
589 msg.msg_control = control_un.control;
590 msg.msg_controllen = sizeof(control_un.control);
592 'HAVE_STRUCT_MSGHDR_MSG_CONTROL',
593 msg
='Checking if we can use msg_control for passing file descriptors',
594 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
598 msg.msg_accrights = (caddr_t) &fd;
599 msg.msg_accrightslen = sizeof(fd);
601 'HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS',
602 msg
='Checking if we can use msg_accrights for passing file descriptors',
603 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
605 if Options
.options
.with_winbind
:
606 conf
.env
.build_winbind
= True
607 conf
.DEFINE('WITH_WINBIND', '1')
609 conf
.find_program('awk', var
='AWK')
611 conf
.CHECK_HEADERS('asm/types.h')
613 conf
.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
614 headers
='unistd.h sys/types.h',
615 msg
="Checking for major macro")
617 conf
.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
618 headers
='unistd.h sys/types.h',
619 msg
="Checking for minor macro")
621 conf
.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
622 headers
='unistd.h sys/types.h dirent.h',
623 define
='HAVE_DIRENT_D_OFF')
625 conf
.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
626 if conf
.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
627 netgrent_cflags
= '-Werror-implicit-function-declaration'
630 conf
.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
631 msg
="Checking for setnetgrent prototype",
632 headers
='netdb.h netgroup.h',
633 cflags
=netgrent_cflags
)
634 conf
.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
635 msg
="Checking for getnetgrent prototype",
636 headers
='netdb.h netgroup.h',
637 cflags
=netgrent_cflags
)
638 conf
.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
639 msg
="Checking for endnetgrent prototype",
640 headers
='netdb.h netgroup.h',
641 cflags
=netgrent_cflags
)
645 if Options
.options
.with_cups
:
646 conf
.find_program('cups-config', var
='CUPS_CONFIG')
647 if conf
.env
.CUPS_CONFIG
:
648 # we would normally use --libs here, but cups-config incorrectly adds
649 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
650 # of an in-tree heimdal kerberos
651 conf
.check_cfg(path
=conf
.env
.CUPS_CONFIG
, args
="--cflags --ldflags",
652 package
="", uselib_store
="CUPS")
653 conf
.CHECK_HEADERS('cups/cups.h cups/language.h', lib
='cups')
654 conf
.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
655 if conf
.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf
.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
656 conf
.DEFINE('HAVE_CUPS', '1')
658 conf
.undefine('HAVE_CUPS')
659 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
661 # define an empty subsystem for cups, to allow it to be used as an empty dependency
662 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
664 if Options
.options
.with_iprint
:
665 if conf
.CONFIG_SET('HAVE_CUPS'):
666 conf
.DEFINE('HAVE_IPRINT', '1')
668 Logs
.warn("--enable-iprint=yes but cups support not sufficient")
669 if Options
.options
.with_syslog
:
670 conf
.DEFINE('WITH_SYSLOG', '1')
671 if Options
.options
.with_automount
:
672 conf
.DEFINE('WITH_AUTOMOUNT', '1')
675 if Options
.options
.with_ldap
:
676 conf
.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
677 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
678 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
679 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
681 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
683 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
684 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
686 conf
.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
687 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
689 # Check if ldap_set_rebind_proc() takes three arguments
690 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
691 'LDAP_SET_REBIND_PROC_ARGS',
692 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
693 headers
='ldap.h lber.h', link
=False):
694 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
696 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
698 # last but not least, if ldap_init() exists, we want to use ldap
699 if conf
.CONFIG_SET('HAVE_LDAP_INIT') and conf
.CONFIG_SET('HAVE_LDAP_H'):
700 conf
.DEFINE('HAVE_LDAP', '1')
701 conf
.DEFINE('LDAP_DEPRECATED', '1')
702 conf
.env
['HAVE_LDAP'] = '1'
703 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
704 # SASL wrapping hooks
705 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
706 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
707 conf
.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
709 conf
.fatal("LDAP support not found. "
710 "Try installing libldap2-dev or openldap-devel. "
711 "Otherwise, use --without-ldap to build without "
713 "LDAP support is required for the LDAP passdb backend, "
714 "LDAP idmap backends and ADS. "
715 "ADS support improves communication with "
716 "Active Directory domain controllers.")
718 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
719 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
721 if Options
.options
.with_ads
== False:
729 if not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
730 not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
731 Logs
.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
733 if not conf
.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
734 Logs
.warn("krb5_mk_req_extended not found in -lkrb5")
736 if not conf
.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
737 Logs
.warn("krb5_get_host_realm not found in -lkrb5")
739 if not conf
.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
740 Logs
.warn("krb5_free_host_realm not found in -lkrb5")
742 if not conf
.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
743 Logs
.warn("krb5_fwd_tgt_creds found in -lkrb5")
745 if not conf
.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
746 Logs
.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
748 if not conf
.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
749 Logs
.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
751 if not conf
.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
752 Logs
.warn("krb5_get_renewed_creds not found in -lkrb5")
754 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
755 Logs
.warn("krb5_principal_compare_any_realm not found in -lkrb5")
757 if not conf
.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
758 not conf
.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
759 Logs
.warn("krb5_c_string_to_key not found in -lkrb5")
761 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
762 not conf
.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
763 Logs
.warn("no CREATE_KEY_FUNCTIONS detected")
765 if not conf
.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
766 not conf
.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
767 Logs
.warn("no GET_ENCTYPES_FUNCTIONS detected")
769 if not conf
.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
770 not conf
.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
771 Logs
.warn("no KT_FREE_FUNCTION detected")
773 if not conf
.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
774 Logs
.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
777 # We don't actually use
778 # gsskrb5_extract_authz_data_from_sec_context, but it is a
779 # clue that this Heimdal, which does the PAC processing we
780 # need on the standard gss_inquire_sec_context_by_oid
781 if not conf
.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
782 not (conf
.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
783 conf
.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
784 Logs
.warn("need either gss_get_name_attribute or gsskrb5_extract_authz_data_from_sec_context and gss_inquire_sec_context_by_oid in -lgssapi for PAC support")
787 if not conf
.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
788 Logs
.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
792 conf
.DEFINE('HAVE_KRB5', '1')
793 conf
.env
['HAVE_KRB5'] = '1'
795 conf
.undefine('HAVE_KRB5_H')
796 conf
.undefine('HAVE_GSSAPI_H')
797 conf
.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
798 conf
.undefine('HAVE_GSSAPI_GSSAPI_H')
801 if not conf
.CONFIG_SET('HAVE_LDAP'):
806 conf
.DEFINE('WITH_ADS', '1')
807 conf
.env
['HAVE_ADS'] = '1'
808 Logs
.info("Building with Active Directory support.")
809 elif Options
.options
.with_ads
== False:
810 Logs
.info("Building without Active Directory support (--without-ads).")
813 Logs
.warn("Active Directory support not available: krb5 libs don't have all required features")
815 Logs
.warn("Active Directory support not available: LDAP support is not available.")
816 if Options
.options
.with_ads
:
817 conf
.fatal("Active Directory support not found. Use --without-ads "
818 "for building without Active Directory support. "
819 "ADS support improves communication with "
820 "Active Directory domain controllers.")
822 # this is the auto-mode case
823 Logs
.warn("Building without Active Directory support.")
826 if Options
.options
.with_utmp
:
827 conf
.env
.with_utmp
= True
828 if not conf
.CHECK_HEADERS('utmp.h'): conf
.env
.with_utmp
= False
829 conf
.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
830 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers
='utmp.h',
831 define
='HAVE_UT_UT_NAME')
832 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers
='utmp.h',
833 define
='HAVE_UT_UT_USER')
834 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers
='utmp.h',
835 define
='HAVE_UT_UT_ID')
836 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers
='utmp.h',
837 define
='HAVE_UT_UT_HOST')
838 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers
='utmp.h',
839 define
='HAVE_UT_UT_TIME')
840 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers
='utmp.h',
841 define
='HAVE_UT_UT_TV')
842 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers
='utmp.h',
843 define
='HAVE_UT_UT_TYPE')
844 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers
='utmp.h',
845 define
='HAVE_UT_UT_PID')
846 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers
='utmp.h',
847 define
='HAVE_UT_UT_EXIT')
848 conf
.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers
='utmpx.h',
849 define
='HAVE_UX_UT_SYSLEN')
850 conf
.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
851 'PUTUTLINE_RETURNS_UTMP', headers
='utmp.h',
852 msg
="Checking whether pututline returns pointer")
853 conf
.CHECK_SIZEOF(['((struct utmp *)NULL)->ut_line'], headers
='utmp.h',
854 define
='SIZEOF_UTMP_UT_LINE', critical
=False)
855 if not conf
.CONFIG_SET('SIZEOF_UTMP_UT_LINE'):
856 conf
.env
.with_utmp
= False
857 elif int(conf
.env
.SIZEOF_UTMP_UT_LINE
) < 15:
858 conf
.env
.with_utmp
= False
859 if conf
.env
.with_utmp
:
860 conf
.DEFINE('WITH_UTMP', 1)
862 Logs
.warn("--with-utmp but utmp support not sufficient")
864 if Options
.options
.with_avahi
:
865 conf
.env
.with_avahi
= True
866 if not conf
.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf
.env
.with_avahi
= False
867 if not conf
.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf
.env
.with_avahi
= False
868 if not conf
.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf
.env
.with_avahi
= False
869 if conf
.env
.with_avahi
:
870 conf
.DEFINE('WITH_AVAHI_SUPPORT', 1)
872 conf
.SET_TARGET_TYPE('avahi-common', 'EMPTY')
873 conf
.SET_TARGET_TYPE('avahi-client', 'EMPTY')
875 if Options
.options
.with_iconv
:
876 conf
.env
.with_iconv
= True
877 if not conf
.CHECK_FUNCS_IN('iconv_open', 'iconv', headers
='iconv.h'):
878 conf
.env
.with_iconv
= False
879 if conf
.env
.with_iconv
:
880 conf
.DEFINE('HAVE_ICONV', 1)
882 if Options
.options
.with_pam
:
884 conf
.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
885 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
886 Logs
.warn("--with-pam=yes but pam_appl.h not found")
888 conf
.CHECK_FUNCS_IN('pam_get_data', 'pam')
889 conf
.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
890 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
891 Logs
.warn("--with-pam=yes but pam_modules.h not found")
893 conf
.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
894 conf
.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
895 conf
.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
897 #if defined(HAVE_SECURITY_PAM_APPL_H)
898 #include <security/pam_appl.h>
899 #elif defined(HAVE_PAM_PAM_APPL_H)
900 #include <pam/pam_appl.h>
902 pam_set_item(0, PAM_RHOST, 0);
906 msg
="Checking whether PAM_RHOST is available");
908 #if defined(HAVE_SECURITY_PAM_APPL_H)
909 #include <security/pam_appl.h>
910 #elif defined(HAVE_PAM_PAM_APPL_H)
911 #include <pam/pam_appl.h>
913 pam_set_item(0, PAM_TTY, 0);
917 msg
="Checking whether PAM_TTY is available");
919 #if (!defined(LINUX))
921 #define PAM_EXTERN extern
922 #if defined(HAVE_SECURITY_PAM_APPL_H)
923 #include <security/pam_appl.h>
924 #elif defined(HAVE_PAM_PAM_APPL_H)
925 #include <pam/pam_appl.h>
930 #if defined(HAVE_SECURITY_PAM_MODULES_H)
931 #include <security/pam_modules.h>
932 #elif defined(HAVE_PAM_PAM_MODULES_H)
933 #include <pam/pam_modules.h>
936 #if defined(HAVE_SECURITY__PAM_MACROS_H)
937 #include <security/_pam_macros.h>
938 #elif defined(HAVE_PAM__PAM_MACROS_H)
939 #include <pam/_pam_macros.h>
942 #ifdef HAVE_SECURITY_PAM_EXT_H
943 #include <security/pam_ext.h>
946 int i; i = PAM_RADIO_TYPE;
948 'HAVE_PAM_RADIO_TYPE',
950 msg
="Checking whether PAM_RADIO_TYPE is available");
952 conf
.DEFINE('WITH_PAM', 1)
953 conf
.DEFINE('WITH_PAM_MODULES', 1)
955 if Options
.options
.with_pam_smbpass
:
956 conf
.env
.with_pam_smbpass
= True
961 # Ensure we select the correct set of system calls on Linux.
963 if (host_os
.rfind('linux') > -1):
965 #if defined(HAVE_UNISTD_H)
970 #include <sys/types.h>
973 #ifdef HAVE_SYS_PRIV_H
974 #include <sys/priv.h>
980 #if defined(HAVE_SYSCALL_H)
984 #if defined(HAVE_SYS_SYSCALL_H)
985 #include <sys/syscall.h>
988 syscall(SYS_setresuid32, -1, -1, -1);
989 syscall(SYS_setresgid32, -1, -1, -1);
990 syscall(SYS_setreuid32, -1, -1);
991 syscall(SYS_setregid32, -1, -1);
992 syscall(SYS_setuid32, -1);
993 syscall(SYS_setgid32, -1);
994 syscall(SYS_setgroups32, 0, NULL);
996 'USE_LINUX_32BIT_SYSCALLS',
997 msg
="Checking whether Linux should use 32-bit credential calls");
999 if (conf
.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
1000 seteuid
= conf
.CHECK_CODE('''
1001 #define AUTOCONF_TEST 1
1002 #define USE_LINUX_THREAD_CREDENTIALS 1
1003 #define USE_LINUX_32BIT_SYSCALLS 1
1004 #include "../lib/util/setid.c"
1005 #include "./lib/util_sec.c"
1007 'USE_LINUX_THREAD_CREDENTIALS',
1010 msg
="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
1012 seteuid
= conf
.CHECK_CODE('''
1013 #define AUTOCONF_TEST 1
1014 #define USE_LINUX_THREAD_CREDENTIALS 1
1015 #include "../lib/util/setid.c"
1016 #include "./lib/util_sec.c"
1018 'USE_LINUX_THREAD_CREDENTIALS',
1021 msg
="Checking whether we can use Linux thread-specific credentials")
1023 seteuid
= conf
.CHECK_CODE('''
1024 #define AUTOCONF_TEST 1
1025 #define USE_SETREUID 1
1026 #include "../lib/util/setid.c"
1027 #include "./lib/util_sec.c"
1032 msg
="Checking whether setreuid is available")
1034 seteuid
= conf
.CHECK_CODE('''
1035 #define AUTOCONF_TEST 1
1036 #define USE_SETRESUID 1
1037 #include "../lib/util/setid.c"
1038 #include "./lib/util_sec.c"
1043 msg
="Checking whether setresuid is available")
1045 seteuid
= conf
.CHECK_CODE('''
1046 #define AUTOCONF_TEST 1
1047 #define USE_SETEUID 1
1048 #include "../lib/util/setid.c"
1049 #include "./lib/util_sec.c"
1054 msg
="Checking whether seteuid is available")
1056 seteuid
= conf
.CHECK_CODE('''
1057 #define AUTOCONF_TEST 1
1058 #define USE_SETUIDX 1
1059 #include "../lib/util/setid.c"
1060 #include "./lib/util_sec.c"
1066 msg
="Checking whether setuidx is available")
1067 if Options
.options
.with_dnsupdate
:
1068 if not conf
.CONFIG_SET('HAVE_KRB5'):
1069 Logs
.warn("--with-dnsupdate=yes but gssapi support not sufficient")
1071 conf
.DEFINE('WITH_DNS_UPDATES', 1)
1072 conf
.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
1073 if Options
.options
.developer
:
1074 if conf
.CONFIG_SET('HAVE_VALGRIND_H') or conf
.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
1075 conf
.DEFINE('VALGRIND', '1')
1077 if conf
.CHECK_CODE('''
1078 #include <bits/sockaddr.h>
1079 #include <linux/netlink.h>
1081 'HAVE_LINUX_NETLINK_H',
1082 msg
="Checking whether Linux netlink is available"):
1085 #include <bits/sockaddr.h>
1086 #include <linux/netlink.h>
1087 #include <linux/rtnetlink.h>
1089 'HAVE_LINUX_RTNETLINK_H',
1090 msg
='Checking whether Linux rtnetlink is available')
1093 #include "../tests/fcntl_lock.c"
1098 msg
='Checking whether fcntl locking is available')
1100 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
1101 if not conf
.CHECK_CODE('''
1102 #define _XOPEN_SOURCE 600
1104 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
1105 #error probably broken posix_fallocate
1108 '_HAVE_UNBROKEN_POSIX_FALLOCATE',
1109 msg
='Checking for broken posix_fallocate'):
1110 conf
.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
1113 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1114 define
='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1115 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1116 define
='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1117 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1118 define
='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1119 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1120 define
='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1121 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1122 define
='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1123 if conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1124 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1125 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1126 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1127 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1128 conf
.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1130 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1131 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1132 define
='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1133 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1134 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1135 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1136 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1139 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1141 'HAVE_POSIX_FADVISE',
1142 msg
='Checking whether posix_fadvise is available',
1143 headers
='unistd.h fcntl.h')
1145 for v
in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1148 return sysconf(%s) == -1 ? 1 : 0;
1151 msg
='Checking whether sysconf(%s) is available' % v
)
1154 #include <sys/syscall.h>
1156 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1158 'HAVE_DARWIN_INITGROUPS',
1159 msg
='Checking whether to use the Darwin-specific initgroups system call')
1161 conf
.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1163 headers
='sys/types.h utime.h',
1164 msg
='Checking whether struct utimbuf is available')
1166 if conf
.CHECK_CODE('''struct sigevent s;''',
1167 'HAVE_STRUCT_SIGEVENT',
1168 headers
='sys/types.h stdlib.h stddef.h signal.h',
1169 msg
='Checking whether we have the struct sigevent'):
1170 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1171 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1172 headers
='signal.h');
1173 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1174 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1175 headers
='signal.h');
1177 if os
.path
.exists('/proc/sys/kernel/core_pattern'):
1178 conf
.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
1180 if conf
.CHECK_CODE('''
1184 if (sizeof(time_t) == 8) {
1185 time_t max_time = 0x7fffffffffffffffll;
1186 tm = gmtime(&max_time);
1187 /* This should fail with 32-bit tm_year. */
1189 /* Max time_t that works with 32-bit int tm_year in struct tm. */
1190 max_time = 67768036191676799ll;
1191 tm = gmtime(&max_time);
1202 msg
="Checking for the maximum value of the 'time_t' type"):
1203 conf
.DEFINE('TIME_T_MAX', '67768036191676799ll')
1206 #if defined(HAVE_UNISTD_H)
1209 #include <sys/types.h>
1210 main() { dev_t dev = makedev(1,2); return 0; }
1214 msg
='Checking whether the macro for makedev is available')
1221 void exit_on_core(int ignored) {
1227 signal(SIGSEGV, exit_on_core);
1228 newpath = realpath("/tmp", NULL);
1229 exit((newpath != NULL) ? 0 : 1);
1232 'REALPATH_TAKES_NULL',
1235 msg
='Checking whether the realpath function allows a NULL argument')
1237 conf
.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1238 'HAVE_FTRUNCATE_EXTEND',
1239 msg
='Checking for ftruncate extend',
1243 if Options
.options
.with_sendfile_support
:
1244 if (host_os
.rfind('linux') > -1) or (host_os
.rfind('gnu') > -1) or (host_os
.rfind('k*bsd*-gnu') > -1) or (host_os
.rfind('kopensolaris*-gnu') > -1):
1249 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1252 headers
='sys/sendfile.h',
1253 msg
='Checking for linux sendfile support')
1255 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1256 conf
.DEFINE('HAVE_SENDFILE', '1')
1257 conf
.DEFINE('LINUX_SENDFILE_API', '1')
1258 conf
.DEFINE('WITH_SENDFILE', '1')
1259 elif (host_os
.rfind('freebsd') > -1) or (host_os
.rfind('dragonfly') > -1):
1261 #include <sys/types.h>
1263 #include <sys/socket.h>
1264 #include <sys/uio.h>
1265 int fromfd, tofd, ret, total=0;
1266 off_t offset, nwritten;
1269 hdr.headers = &hdtrl;
1271 hdr.trailers = NULL;
1273 hdtrl.iov_base = NULL;
1275 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1278 msg
='Checking for freebsd sendfile support')
1279 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1280 conf
.DEFINE('HAVE_SENDFILE', '1')
1281 conf
.DEFINE('FREEBSD_SENDFILE_API', '1')
1282 conf
.DEFINE('WITH_SENDFILE', '1')
1283 elif (host_os
.rfind('darwin') > -1):
1285 #include <sys/types.h>
1286 #include <sys/socket.h>
1287 #include <sys/uio.h>
1288 int fromfd, tofd, ret;
1289 off_t offset, nwritten;
1292 hdr.headers = &hdtrl;
1294 hdr.trailers = (void *)0;
1296 hdtrl.iov_base = (void *)0;
1298 ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1301 msg
='Checking for darwin sendfile support')
1302 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1303 conf
.DEFINE('HAVE_SENDFILE', '1')
1304 conf
.DEFINE('DARWIN_SENDFILE_API', '1')
1305 conf
.DEFINE('WITH_SENDFILE', '1')
1306 elif (host_os
.rfind('hpux') > -1) or (host_os
.rfind('osf') > -1):
1308 #include <sys/socket.h>
1309 #include <sys/uio.h>
1312 struct iovec hdtrl[2];
1315 hdtrl[0].iov_base = 0;
1316 hdtrl[0].iov_len = 0;
1317 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1320 msg
='Checking for osf/hpux sendfile support')
1321 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1322 conf
.DEFINE('HAVE_SENDFILE', '1')
1323 conf
.DEFINE('HPUX_SENDFILE_API', '1')
1324 conf
.DEFINE('WITH_SENDFILE', '1')
1325 elif (host_os
.rfind('solaris') > -1):
1326 conf
.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1328 #include <sys/sendfile.h>,
1331 struct sendfilevec vec[2];
1335 vec[0].sfv_fd = SFV_FD_SELF;
1336 vec[0].sfv_flag = 0;
1340 vec[1].sfv_flag = 0;
1343 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1346 msg
='Checking for solaris sendfilev support')
1347 if conf
.CONFIG_SET('_HAVE_SENDFILEV'):
1348 conf
.DEFINE('HAVE_SENDFILEV', '1')
1349 conf
.DEFINE('SOLARIS_SENDFILE_API', '1')
1350 conf
.DEFINE('WITH_SENDFILE', '1')
1351 elif (host_os
.rfind('aix') > -1):
1353 #include <sys/socket.h>
1356 struct sf_parms hdtrl;
1358 hdtrl.header_data = 0;
1359 hdtrl.header_length = 0;
1360 hdtrl.file_descriptor = fromfd;
1361 hdtrl.file_offset = 0;
1362 hdtrl.file_bytes = 0;
1363 hdtrl.trailer_data = 0;
1364 hdtrl.trailer_length = 0;
1365 nwritten = send_file(&tofd, &hdtrl, 0);
1368 msg
='Checking for AIX send_file support')
1369 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1370 conf
.DEFINE('HAVE_SENDFILE', '1')
1371 conf
.DEFINE('AIX_SENDFILE_API', '1')
1372 conf
.DEFINE('WITH_SENDFILE', '1')
1374 # Check for getcwd allowing a NULL arg.
1378 char *s = getcwd(NULL,0);
1379 exit(s != NULL ? 0 : 1);
1380 }''', 'GETCWD_TAKES_NULL', addmain
=False, execute
=True,
1381 msg
="getcwd takes a NULL argument")
1384 # UnixWare 7.x has its getspnam in -lgen
1385 conf
.CHECK_FUNCS_IN('getspnam', 'gen')
1386 conf
.CHECK_FUNCS_IN('getspnam', 'security')
1387 conf
.CHECK_FUNCS_IN('getspnam', 'sec')
1389 if Options
.options
.with_quotas
:
1390 # For quotas on Veritas VxFS filesystems
1391 conf
.CHECK_HEADERS('sys/fs/vx_quota.h')
1392 # For sys/quota.h and linux/quota.h
1393 conf
.CHECK_HEADERS('sys/quota.h')
1394 # For quotas on BSD systems
1395 conf
.CHECK_HEADERS('ufs/ufs/quota.h')
1396 # For quotas on Linux XFS filesystems
1397 if conf
.CHECK_HEADERS('xfs/xqm.h'):
1398 conf
.DEFINE('HAVE_XFS_QUOTAS', '1')
1402 #include "confdefs.h"
1403 #ifdef HAVE_SYS_TYPES_H
1404 #include <sys/types.h>
1406 #ifdef HAVE_ASM_TYPES_H
1407 #include <asm/types.h>
1409 #include <sys/quota.h>
1410 int i = Q_XGETQUOTA;''',
1411 define
='HAVE_XFS_QUOTAS',
1412 msg
='for XFS QUOTA in <sys/quota.h>',
1414 local_include
=False)
1416 # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
1417 conf
.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define
='HAVE_DQB_FSOFTLIMIT',
1418 headers
='sys/quota.h')
1419 #darwin style quota bytecount
1420 conf
.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_curbytes', define
='HAVE_STRUCT_DQBLK_DQB_CURBYTES',
1421 headers
='sys/quota.h')
1422 if conf
.CHECK_HEADERS('rpcsvc/rquota.h'):
1423 conf
.DEFINE('HAVE_NFS_QUOTAS', '1')
1424 conf
.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1425 define
='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1426 headers
='rpcsvc/rquota.h')
1428 if (host_os
.rfind('linux') > -1):
1429 conf
.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1430 elif not conf
.CONFIG_SET("HAVE_XFS_QUOTAS"):
1431 if not conf
.CHECK_CODE('''
1432 #define HAVE_QUOTACTL_4A 1
1433 #define AUTOCONF_TEST 1
1434 #include "../tests/sysquotas.c"
1436 cflags
=conf
.env
['WERROR_CFLAGS'],
1437 define
='HAVE_QUOTACTL_4A',
1438 msg
='for QUOTACTL_4A: long quotactl(int cmd, char *special, qid_t id, caddr_t addr)',
1443 #define HAVE_QUOTACTL_4B 1
1444 #define AUTOCONF_TEST 1
1445 #include "../tests/sysquotas.c"
1447 cflags
=conf
.env
['WERROR_CFLAGS'],
1448 define
='HAVE_QUOTACTL_4B',
1449 msg
='for QUOTACTL_4B: int quotactl(const char *path, int cmd, int id, char *addr)',
1454 clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
1456 headers
="rpc/rpc.h rpc/types.h rpcsvc/rquota.h rpc/nettype.h rpc/xdr.h",
1457 define
='HAVE_NFS_QUOTAS',
1458 msg
='for NFS QUOTAS',
1460 local_include
=False)
1462 if conf
.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1463 conf
.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1464 conf
.CONFIG_SET('HAVE_QUOTACTL_4B') or \
1465 conf
.CONFIG_SET('HAVE_XFS_QUOTAS'):
1466 conf
.DEFINE('HAVE_SYS_QUOTAS', '1')
1467 conf
.DEFINE('WITH_QUOTAS', '1')
1470 # checking for clustering extensions (CTDB)
1472 if Options
.options
.with_cluster_support
== False:
1473 # configure is called with --without-cluster-support,
1474 # so don't check for and build w/o ctdb support.
1475 have_cluster_support
= False
1479 have_cluster_support
= True
1483 srcdir
= os
.path
.realpath(conf
.srcdir
)
1484 if 'EXTRA_INCLUDES' in conf
.env
:
1485 includes
= ' '.join(conf
.env
['EXTRA_INCLUDES']).replace('#', srcdir
+ '/')
1489 if Options
.options
.ctdb_dir
:
1490 CTDB_INCLUDE
= Options
.options
.ctdb_dir
+ '/include'
1492 CTDB_INCLUDE
= conf
.srcdir
+ '/ctdb/include'
1493 includes
= includes
+ ' ' + CTDB_INCLUDE
1495 if not conf
.env
.USING_SYSTEM_TDB
:
1496 includes
= includes
+ ' ' + srcdir
+ '/lib/tdb/include'
1498 if not conf
.env
.USING_SYSTEM_TALLOC
:
1499 includes
= includes
+ ' ' + srcdir
+ '/lib/talloc'
1501 ok
= conf
.CHECK_CODE('''
1503 #include "replace.h"
1504 #include "system/wait.h"
1505 #include "system/network.h"
1506 #define private #error __USED_RESERVED_WORD_private__
1516 'HAVE_CTDB_CHECK_CODE',
1519 msg
='Checking for header ctdb.h')
1521 CTDB_CFLAGS
+= ' -DHAVE_CTDB_H=1'
1523 have_cluster_support
= False
1524 ctdb_broken
= "ctdb.h is required for cluster support"
1526 conf
.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1527 if have_cluster_support
:
1528 ok
= conf
.CHECK_CODE('''
1530 #include "replace.h"
1531 #include "system/wait.h"
1532 #include "system/network.h"
1533 #define private #error __USED_RESERVED_WORD_private__
1537 #include <ctdb_private.h>
1544 'HAVE_CTDB_CHECK_CODE',
1547 msg
='Checking for header ctdb_private.h')
1549 CTDB_CFLAGS
+= ' -DHAVE_CTDB_PRIVATE_H=1'
1551 have_cluster_support
= False
1552 ctdb_broken
= "ctdb_private.h is required for cluster support"
1554 conf
.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1555 if have_cluster_support
:
1556 ok
= conf
.CHECK_CODE('''
1558 #include "replace.h"
1559 #include "system/wait.h"
1560 #include "system/network.h"
1561 #define private #error __USED_RESERVED_WORD_private__
1565 #include <ctdb_protocol.h>
1572 'HAVE_CTDB_CHECK_CODE',
1575 msg
='Checking for header ctdb_protocol.h')
1577 CTDB_CFLAGS
+= ' -DHAVE_CTDB_PROTOCOL_H=1'
1579 conf
.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1580 if have_cluster_support
:
1581 ok
= conf
.CHECK_CODE('''
1583 #include "replace.h"
1584 #include "system/wait.h"
1585 #include "system/network.h"
1589 #include <ctdb_private.h>
1593 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1597 'HAVE_CTDB_CHECK_CODE',
1600 msg
='Checking for transaction support (TRANS3_COMMIT control)')
1602 CTDB_CFLAGS
+= ' -DHAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL=1'
1604 have_cluster_support
= False
1605 ctdb_broken
= "ctdb transaction support missing or too old"
1607 conf
.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1608 if have_cluster_support
:
1609 ok
= conf
.CHECK_CODE('''
1611 #include "replace.h"
1612 #include "system/wait.h"
1613 #include "system/network.h"
1617 #include <ctdb_private.h>
1621 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1625 'HAVE_CTDB_CHECK_CODE',
1628 msg
='Checking for SCHEDULE_FOR_DELETION control')
1630 CTDB_CFLAGS
+= ' -DHAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL=1'
1632 if not Options
.options
.enable_old_ctdb
:
1633 have_cluster_support
= False
1634 ctdb_broken
= "SCHEDULE_FOR_DELETION control missing"
1636 Logs
.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1638 conf
.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1639 if have_cluster_support
:
1640 ok
= conf
.CHECK_CODE('''
1642 #include "replace.h"
1643 #include "system/wait.h"
1644 #include "system/network.h"
1651 int i = (int)CTDB_WANT_READONLY;
1655 'HAVE_CTDB_CHECK_CODE',
1658 msg
='Checking for CTDB readonly records support')
1660 CTDB_CFLAGS
+= ' -DHAVE_CTDB_WANT_READONLY_DECL=1'
1662 if not Options
.options
.enable_old_ctdb
:
1663 have_cluster_support
= False
1664 ctdb_broken
= "support for CTDB readonly records missing"
1666 Logs
.warn("ignoring missing READONLY support (--enable-old-ctdb)")
1668 conf
.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1669 if have_cluster_support
:
1670 ok
= conf
.CHECK_CODE('''
1672 #include "replace.h"
1673 #include "system/wait.h"
1674 #include "system/network.h"
1678 #include <ctdb_private.h>
1682 struct ctdb_control_tcp _x;
1686 'HAVE_CTDB_CHECK_CODE',
1689 msg
='Checking for ctdb ipv4 support')
1691 CTDB_CFLAGS
+= ' -DHAVE_STRUCT_CTDB_CONTROL_TCP=1'
1693 have_cluster_support
= False
1694 ctdb_broken
= "missing struct ctdb_control_tcp"
1696 conf
.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1697 if have_cluster_support
:
1698 ok
= conf
.CHECK_CODE('''
1700 #include "replace.h"
1701 #include "system/wait.h"
1702 #include "system/network.h"
1706 #include <ctdb_private.h>
1710 struct ctdb_control_tcp_addr _x;
1714 'HAVE_CTDB_CHECK_CODE',
1717 msg
='Checking for ctdb ipv6 support')
1719 CTDB_CFLAGS
+= ' -DHAVE_STRUCT_CTDB_CONTROL_TCP_ADDR=1'
1721 conf
.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1722 if have_cluster_support
:
1723 ok
= conf
.CHECK_CODE('''
1725 #include "replace.h"
1726 #include "system/wait.h"
1727 #include "system/network.h"
1731 #include <ctdb_private.h>
1735 int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1739 'HAVE_CTDB_CHECK_CODE',
1742 msg
='Checking for CHECK_SRVIDS control')
1744 CTDB_CFLAGS
+= ' -DHAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL=1'
1746 if not Options
.options
.enable_old_ctdb
:
1747 have_cluster_support
= False
1748 ctdb_broken
= "CHECK_SRVIDS control missing"
1750 Logs
.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1752 conf
.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1753 conf
.undefine('HAVE_CTDB_CHECK_CODE')
1754 if have_cluster_support
:
1755 Logs
.info("building with cluster support")
1756 conf
.env
['CTDB_CFLAGS'] = CTDB_CFLAGS
1757 conf
.env
['CTDB_INCLUDE'] = CTDB_INCLUDE
1759 if Options
.options
.with_cluster_support
== False:
1760 Logs
.info("building without cluster support (--without-cluster-support)")
1761 elif Options
.options
.with_cluster_support
== True:
1762 Logs
.error("Cluster support not available: " + ctdb_broken
)
1763 conf
.fatal("Cluster support not found, but --with-cluster-support was specified")
1765 Logs
.info("building without cluster support: " + ctdb_broken
)
1766 conf
.env
['CTDB_CFLAGS'] = ''
1769 conf
.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1770 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1773 msg
='Checking whether we can compile with __attribute__((destructor))')
1775 conf
.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1776 'SEEKDIR_RETURNS_VOID',
1777 headers
='sys/types.h dirent.h',
1778 msg
='Checking whether seekdir returns void')
1780 if Options
.options
.with_profiling_data
:
1781 conf
.DEFINE('WITH_PROFILE', 1);
1783 if Options
.options
.with_pthreadpool
:
1784 if conf
.CONFIG_SET('HAVE_PTHREAD'):
1785 conf
.DEFINE('WITH_PTHREADPOOL', '1')
1787 Logs
.warn("pthreadpool support cannot be enabled when pthread support was not found")
1788 conf
.undefine('WITH_PTHREADPOOL')
1790 if conf
.CHECK_HEADERS('gpfs_gpl.h'):
1791 conf
.DEFINE('HAVE_GPFS', '1')
1793 if (conf
.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
1794 conf
.CHECK_DECLS('FS_IOC_GETFLAGS FS_COMPR_FL', headers
='linux/fs.h')):
1795 conf
.DEFINE('HAVE_LINUX_IOCTL', '1')
1797 conf
.env
['CCFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64"
1798 if Options
.options
.libcephfs_dir
:
1799 conf
.env
['CPPPATH_CEPHFS'] = Options
.options
.libcephfs_dir
+ '/include'
1800 conf
.env
['LIBPATH_CEPHFS'] = Options
.options
.libcephfs_dir
+ '/lib'
1802 if conf
.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and conf
.CHECK_LIB('cephfs'):
1803 conf
.DEFINE('HAVE_CEPH', '1')
1805 if Options
.options
.with_glusterfs
:
1806 conf
.check_cfg(package
='glusterfs-api', args
='"glusterfs-api >= 4" --cflags --libs',
1807 msg
='Checking for glusterfs-api >= 4', uselib_store
="GFAPI")
1808 conf
.CHECK_HEADERS('api/glfs.h', lib
='gfapi')
1809 conf
.CHECK_LIB('gfapi', shlib
=True)
1811 if conf
.CONFIG_SET('HAVE_API_GLFS_H'):
1812 conf
.DEFINE('HAVE_GLUSTERFS', '1')
1814 conf
.SET_TARGET_TYPE('gfapi', 'EMPTY')
1815 conf
.undefine('HAVE_GLUSTERFS')
1817 conf
.SET_TARGET_TYPE('gfapi', 'EMPTY')
1818 conf
.undefine('HAVE_GLUSTERFS')
1820 if Options
.options
.enable_vxfs
:
1821 conf
.DEFINE('HAVE_VXFS', '1')
1823 if conf
.check_cfg(package
='dbus-1', args
='--cflags --libs',
1824 msg
='Checking for dbus', uselib_store
="DBUS-1"):
1825 if (conf
.CHECK_HEADERS('dbus/dbus.h', lib
='dbus-1')
1826 and conf
.CHECK_LIB('dbus-1', shlib
=True)):
1827 conf
.DEFINE('HAVE_DBUS', '1')
1829 conf
.env
.build_regedit
= False
1830 if not Options
.options
.with_regedit
== False:
1831 conf
.PROCESS_SEPARATE_RULE('system_ncurses')
1832 if conf
.CONFIG_SET('HAVE_NCURSES'):
1833 conf
.env
.build_regedit
= True
1835 if conf
.env
.build_regedit
:
1836 Logs
.info("building regedit")
1838 if Options
.options
.with_regedit
== False:
1839 Logs
.info("not building regedit (--without-regedit)")
1840 elif Options
.options
.with_regedit
== True:
1841 Logs
.error("ncurses not available, cannot build regedit")
1842 conf
.fatal("ncurses not available, but --with-regedit was specified")
1844 Logs
.info("ncurses not available, not building regedit")
1846 conf
.CHECK_FUNCS_IN('DES_pcbc_encrypt', 'crypto')
1847 if Options
.options
.with_fake_kaserver
== True:
1848 conf
.CHECK_HEADERS('afs/param.h afs/stds.h', together
=True)
1849 conf
.CHECK_HEADERS('afs/param.h afs/stds.h', together
=True)
1850 if (conf
.CONFIG_SET('HAVE_AFS_PARAM_H') and conf
.CONFIG_SET('HAVE_AFS_STDS_H') and conf
.CONFIG_SET('HAVE_DES_PCBC_ENCRYPT')):
1851 conf
.DEFINE('WITH_FAKE_KASERVER', '1')
1853 conf
.fatal('AFS headers not available, but --with-fake-kaserver was specified')
1857 default_static_modules
.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1858 auth_sam auth_unix auth_winbind auth_wbc
1859 auth_domain auth_builtin vfs_default
1860 nss_info_template idmap_tdb idmap_passdb
1863 default_shared_modules
.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1864 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1865 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1866 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1867 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1868 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1869 vfs_media_harmony vfs_fruit
1872 vfs_crossrename vfs_linux_xfs_sgid
1873 vfs_time_audit idmap_autorid idmap_tdb2
1875 idmap_rid idmap_hash idmap_rfc2307'''))
1877 if Options
.options
.developer
:
1878 default_static_modules
.extend(TO_LIST('charset_weird'))
1879 default_shared_modules
.extend(TO_LIST('perfcount_test'))
1880 default_shared_modules
.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1881 default_shared_modules
.extend(TO_LIST('auth_skel pdb_test'))
1883 if Options
.options
.enable_selftest
or Options
.options
.developer
:
1884 default_shared_modules
.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr'))
1887 if conf
.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1888 default_static_modules
.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
1890 if conf
.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1891 default_shared_modules
.extend(TO_LIST('vfs_zfsacl'))
1893 if conf
.CONFIG_SET('HAVE_DIRFD_DECL'):
1894 default_shared_modules
.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1896 if conf
.CONFIG_SET('HAVE_STATFS_F_FSID'):
1897 default_shared_modules
.extend(TO_LIST('vfs_fileid'))
1899 if (conf
.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_CONTROL') or conf
.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS')):
1900 default_shared_modules
.extend(TO_LIST('vfs_aio_fork'))
1902 if Options
.options
.with_pthreadpool
:
1903 default_shared_modules
.extend(TO_LIST('vfs_aio_pthread'))
1905 if conf
.CONFIG_SET('HAVE_AIO'):
1906 default_shared_modules
.extend(TO_LIST('vfs_aio_posix'))
1908 if conf
.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1909 default_shared_modules
.extend(TO_LIST('vfs_aio_linux'))
1911 if conf
.CONFIG_SET('HAVE_LDAP'):
1912 default_static_modules
.extend(TO_LIST('pdb_ldapsam idmap_ldap'))
1914 if conf
.CONFIG_SET('DARWINOS'):
1915 default_static_modules
.extend(TO_LIST('charset_macosxfs'))
1917 if conf
.CONFIG_SET('HAVE_GPFS'):
1918 default_shared_modules
.extend(TO_LIST('vfs_gpfs'))
1920 if conf
.CONFIG_SET('HAVE_LINUX_IOCTL'):
1921 default_shared_modules
.extend(TO_LIST('vfs_btrfs'))
1923 if conf
.CONFIG_SET('SAMBA_FAM_LIBS'):
1924 default_shared_modules
.extend(TO_LIST('vfs_notify_fam'))
1926 if conf
.CONFIG_SET("HAVE_CEPH"):
1927 default_shared_modules
.extend(TO_LIST('vfs_ceph'))
1929 if conf
.CONFIG_SET('HAVE_GLUSTERFS'):
1930 default_shared_modules
.extend(TO_LIST('vfs_glusterfs'))
1932 if conf
.CONFIG_SET('HAVE_VXFS'):
1933 default_shared_modules
.extend(TO_LIST('vfs_vxfs'))
1935 if conf
.CONFIG_SET('HAVE_DBUS'):
1936 default_shared_modules
.extend(TO_LIST('vfs_snapper'))
1938 explicit_shared_modules
= TO_LIST(Options
.options
.shared_modules
, delimiter
=',')
1939 explicit_static_modules
= TO_LIST(Options
.options
.static_modules
, delimiter
=',')
1941 def replace_list_item(lst
, item
, value
):
1943 idx
= lst
.index(item
)
1947 # PDB module file name should have the same name as module registers itself
1948 # In Autoconf build we export LDAP passdb module as ldapsam but WAF build
1949 # was always exporting pdb_ldap. In order to support existing packages
1950 # allow referring to pdb_ldapsam as pdb_ldap but use proper name internally.
1951 replace_list_item(explicit_shared_modules
, 'pdb_ldap', 'pdb_ldapsam')
1952 replace_list_item(explicit_static_modules
, 'pdb_ldap', 'pdb_ldapsam')
1954 final_static_modules
= default_static_modules
1955 final_shared_modules
= default_shared_modules
1957 for m
in explicit_static_modules
:
1958 if m
in final_shared_modules
:
1959 final_shared_modules
.remove(m
)
1960 final_static_modules
.append(m
)
1961 for m
in explicit_shared_modules
:
1962 if m
in final_static_modules
:
1963 final_static_modules
.remove(m
)
1964 final_shared_modules
.append(m
)
1966 if ("auth_domain" not in final_static_modules
) or \
1967 ("auth_builtin" not in final_static_modules
) or \
1968 ("auth_sam" not in final_static_modules
) or \
1969 ("auth_winbind" not in final_static_modules
):
1970 raise Utils
.WafError('These auth modules MUST be configured as static modules: auth_domain, auth_builtin, auth_sam, auth_winbind')
1972 conf
.env
['static_modules'] = final_static_modules
1973 conf
.env
['shared_modules'] = final_shared_modules
1975 conf
.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules
), quote
=True)
1980 prefixes
= ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1981 conf
.env
['MODULE_PREFIXES'] = prefixes
1983 for m
in final_static_modules
:
1985 if not p
in static_list
:
1987 static_list
[p
].append(m
)
1988 for m
in final_shared_modules
:
1990 if not p
in shared_list
:
1992 shared_list
[p
].append(m
)
1995 static_env
= "%s_STATIC" % p
.upper()
1996 shared_env
= "%s_SHARED" % p
.upper()
1997 conf
.env
[static_env
] = []
1998 conf
.env
[shared_env
] = []
1999 if p
in static_list
:
2001 for entry
in static_list
[p
]:
2002 decl_list
+= "extern NTSTATUS %s_init(void); " % entry
2003 conf
.env
[static_env
].append('%s' % entry
)
2004 decl_list
= decl_list
.rstrip()
2005 conf
.DEFINE('static_decl_%s' % p
, decl_list
)
2006 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(); }' % '_init(); '.join(static_list
[p
]))
2008 conf
.DEFINE('static_decl_%s' % p
, '')
2009 conf
.DEFINE('static_init_%s' % p
, '{}')
2010 if p
in shared_list
:
2011 for entry
in shared_list
[p
]:
2012 conf
.DEFINE('%s_init' % entry
, 'samba_init_module')
2013 conf
.env
[shared_env
].append('%s' % entry
)
2015 conf
.SAMBA_CONFIG_H('include/config.h')
2018 "build 'tags' file using ctags"
2020 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
2021 cmd
= 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
2022 print("Running: %s" % cmd
)