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
.add_option('--with-ctdb-dir',
53 help=("Directory under which ctdb is installed"),
54 action
="store", dest
='ctdb_dir', default
=None)
55 opt
.add_option('--enable-old-ctdb',
56 help=("enable building against (too) old version of ctdb (default=false)"),
57 action
="store_true", dest
='enable_old_ctdb', default
=False)
59 opt
.add_option('--with-libcephfs',
60 help=("Directory under which libcephfs is installed"),
61 action
="store", dest
='libcephfs_dir', default
=None)
63 opt
.SAMBA3_ADD_OPTION('glusterfs', with_name
="enable", without_name
="disable", default
=True)
67 from samba_utils
import TO_LIST
69 default_static_modules
= []
70 default_shared_modules
= []
72 if Options
.options
.developer
:
73 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
74 conf
.env
.developer
= True
76 if sys
.platform
!= 'openbsd5':
77 conf
.ADD_LDFLAGS("-Wl,--export-dynamic", testflags
=True)
79 conf
.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
80 conf
.CHECK_HEADERS('linux/falloc.h')
82 conf
.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
83 conf
.CHECK_FUNCS('strtol strchr strupr chflags')
84 conf
.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
85 conf
.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
86 conf
.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
87 conf
.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
88 conf
.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
89 conf
.CHECK_FUNCS('atexit grantpt posix_openpt fallocate posix_fallocate')
90 conf
.CHECK_FUNCS('fseeko setluid')
91 conf
.CHECK_FUNCS('getpwnam', headers
='sys/types.h pwd.h')
92 conf
.CHECK_FUNCS('fdopendir')
93 conf
.CHECK_FUNCS('fstatat')
94 conf
.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
95 conf
.CHECK_FUNCS('syslog vsyslog timegm setlocale')
96 conf
.CHECK_FUNCS_IN('nanosleep', 'rt')
97 conf
.CHECK_FUNCS('lutimes futimes utimensat futimens')
98 conf
.CHECK_FUNCS('mlock munlock mlockall munlockall')
99 conf
.CHECK_FUNCS('memalign posix_memalign hstrerror')
100 conf
.CHECK_FUNCS('shmget')
101 conf
.CHECK_FUNCS_IN('shm_open', 'rt', checklibc
=True)
102 #FIXME: for some reason this one still fails
103 conf
.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
104 conf
.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
105 conf
.CHECK_FUNCS_IN('dn_expand', 'inet')
106 conf
.CHECK_DECLS('fdatasync', reverse
=True)
107 conf
.CHECK_DECLS('readahead', reverse
=True, headers
='fcntl.h')
109 if conf
.CONFIG_SET('HAVE_LONG_LONG'):
110 conf
.DEFINE('HAVE_LONGLONG', 1)
112 if conf
.CHECK_CODE('''
113 #if defined(HAVE_UNISTD_H)
116 long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
120 conf
.CHECK_DECLS('splice', reverse
=True, headers
='fcntl.h')
122 # Check for inotify support
123 conf
.CHECK_HEADERS('sys/inotify.h')
124 if "HAVE_SYS_INOTIFY_H" in conf
.env
:
125 conf
.DEFINE('HAVE_INOTIFY', 1)
127 # Check for kernel change notify support
130 #define F_NOTIFY 1026
133 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
134 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain
=False, execute
=True,
135 headers
='fcntl.h signal.h',
136 msg
="Checking for kernel change notify support")
138 # Check for Linux kernel oplocks
140 #include <sys/types.h>
144 #define F_NOTIFY 1026
147 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
148 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain
=False, execute
=True,
149 msg
="Checking for Linux kernel oplocks")
151 # Check for IRIX kernel oplock types
152 conf
.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
153 'HAVE_KERNEL_OPLOCKS_IRIX', headers
='fcntl.h',
154 msg
="Checking for IRIX kernel oplock types")
156 # Check for kernel share modes
158 #include <sys/types.h>
161 #include <sys/file.h>
167 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
168 }''', 'HAVE_KERNEL_SHARE_MODES', addmain
=False, execute
=True,
169 msg
="Checking for kernel share modes")
174 if Options
.options
.with_fam
is None:
176 elif Options
.options
.with_fam
== True:
179 if check_for_fam
and conf
.CHECK_HEADERS('fam.h'):
180 if conf
.CHECK_FUNCS_IN('FAMOpen2', 'fam'):
182 elif conf
.CHECK_FUNCS_IN('FAMOpen2', 'fam C'):
183 samba_fam_libs
='fam C'
184 conf
.CHECK_TYPE('enum FAMCodes', headers
='fam.h',
185 define
='HAVE_FAM_H_FAMCODES_TYPEDEF',
186 msg
='Checking whether enum FAMCodes is available')
187 conf
.CHECK_FUNCS_IN('FAMNoExists', 'fam')
189 if samba_fam_libs
is not None:
190 conf
.DEFINE('SAMBA_FAM_LIBS', samba_fam_libs
)
192 if Options
.options
.with_fam
== True:
193 conf
.fatal('FAM support requested, but no suitable FAM library found')
195 Logs
.warn('no suitable FAM library found')
197 # check for libarchive (tar command in smbclient)
198 use_libarchive
= False
199 # None means autodetect
200 if Options
.options
.with_libarchive
is None:
201 Logs
.info("Checking for libarchive existence")
202 if conf
.CHECK_HEADERS('archive.h') and conf
.CHECK_LIB('archive'):
203 use_libarchive
= True
204 elif Options
.options
.with_libarchive
== True:
205 conf
.CHECK_HEADERS('archive.h', mandatory
=True)
206 conf
.CHECK_LIB('archive', mandatory
=True)
207 use_libarchive
= True
210 conf
.DEFINE('SAMBA_LIBARCHIVE_LIBS', '-larchive')
212 # check for DMAPI libs
213 Logs
.info("Checking for DMAPI library existence")
214 conf
.env
['dmapi_lib'] = ''
216 if conf
.CHECK_FUNCS_IN('dm_get_eventlist', 'dm'):
217 samba_dmapi_lib
= 'dm'
219 if conf
.CHECK_FUNCS_IN('dm_get_eventlist', 'jfsdm'):
220 samba_dmapi_lib
= 'jfsdm'
222 if conf
.CHECK_FUNCS_IN('dm_get_eventlist', 'dmapi'):
223 samba_dmapi_lib
= 'dmapi'
225 if conf
.CHECK_FUNCS_IN('dm_get_eventlist', 'xdsm'):
226 samba_dmapi_lib
= 'xdsm'
227 # only bother to test headers and compilation when a candidate
228 # library has been found
229 if Options
.options
.with_dmapi
== True and samba_dmapi_lib
== '':
230 conf
.fatal('DMAPI support requested, but no suitable DMAPI library found')
232 conf
.CHECK_HEADERS('sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h dmapi.h')
234 #include <time.h> /* needed by Tru64 */
235 #include <sys/types.h> /* needed by AIX */
236 #ifdef HAVE_XFS_DMAPI_H
237 #include <xfs/dmapi.h>
238 #elif defined(HAVE_SYS_DMI_H)
240 #elif defined(HAVE_SYS_JFSDMAPI_H)
241 #include <sys/jfsdmapi.h>
242 #elif defined(HAVE_SYS_DMAPI_H)
243 #include <sys/dmapi.h>
244 #elif defined(HAVE_DMAPI_H)
248 /* This link test is designed to fail on IRI 6.4, but should
249 * succeed on Linux, IRIX 6.5 and AIX.
251 int main(int argc, char **argv)
254 dm_eventset_t events;
255 /* This doesn't take an argument on IRIX 6.4. */
256 dm_init_service(&version);
257 /* IRIX 6.4 expects events to be a pointer. */
258 DMEV_ISSET(DM_EVENT_READ, events);
267 msg
='Checking whether DMAPI lib '+samba_dmapi_lib
+' can be used')
269 if conf
.CONFIG_SET('USE_DMAPI'):
270 conf
.env
['dmapi_lib'] = samba_dmapi_lib
272 if Options
.options
.with_dmapi
== True:
273 conf
.fatal('DMAPI support requested but not found');
275 # Check for various members of the stat structure
276 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define
='HAVE_STAT_ST_BLOCKS',
277 headers
='sys/stat.h')
278 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define
='HAVE_STAT_ST_BLKSIZE',
279 headers
='sys/stat.h')
280 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define
='HAVE_STAT_ST_FLAGS',
281 headers
='sys/types.h sys/stat.h unistd.h')
283 if "HAVE_BLKCNT_T" in conf
.env
:
285 return sizeof(blkcnt_t) == 4 ? 0 : 1''',
286 'SIZEOF_BLKCNT_T_4', execute
=True,
287 headers
='replace.h sys/types.h sys/stat.h unistd.h',
288 msg
="Checking whether blkcnt_t is 32 bit")
290 if "HAVE_BLKCNT_T" in conf
.env
:
292 return sizeof(blkcnt_t) == 8 ? 0 : 1''',
293 'SIZEOF_BLKCNT_T_8', execute
=True,
294 headers
='replace.h sys/types.h sys/stat.h unistd.h',
295 msg
="Checking whether blkcnt_t is 64 bit")
297 # Check for POSIX capability support
298 conf
.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers
='sys/capability.h')
300 if "HAVE_SYS_CAPABILITY_H" in conf
.env
:
304 if (!(cap = cap_get_proc())) exit(1);
306 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
307 cap_set_proc(cap);''',
308 'HAVE_POSIX_CAPABILITIES', execute
=True, lib
="cap",
309 headers
='sys/capability.h',
310 msg
="Checking whether POSIX capabilities are available")
312 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
313 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
315 if conf
.CONFIG_SET("HAVE_RPC_RPC_H"):
316 conf
.CHECK_TYPE('int16', headers
='rpc/rpc.h',
317 define
='HAVE_INT16_FROM_RPC_RPC_H',
318 msg
="Checking for int16 typedef included by rpc/rpc.h")
319 conf
.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
320 headers
='sys/types.h rpc/rpc.h',
321 msg
="Checking for uint16 typedef included by rpc/rpc.h")
322 conf
.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
323 headers
='sys/types.h rpc/rpc.h',
324 msg
="Checking for int32 typedef included by rpc/rpc.h")
325 conf
.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
326 headers
='sys/types.h rpc/rpc.h',
327 msg
="Checking for uint32 typedef included by rpc/rpc.h")
328 conf
.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
329 headers
='sys/types.h sys/acl.h rpcsvc/nis.h',
330 msg
="Checking for broken nisplus include files")
332 # Check if the compiler will optimize out functions
335 this_function_does_not_exist();
338 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
339 msg
="Checking if the compiler will optimize out functions")
341 # Check if the compiler supports the LL suffix on long long integers
343 conf
.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
345 msg
="Checking for LL suffix on long long integers")
349 _chdir __chdir chflags chmod _close __close _closedir
350 __closedir crypt16 devnm dirfd
351 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
353 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
355 fsetxattr _fstat __fstat fsync
356 futimens futimes __fxstat getauthuid
357 getcwd _getcwd __getcwd getdents __getdents getdirentries
358 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
359 getpwanam getpwent_r getrlimit
360 glob grantpt hstrerror initgroups innetgr
361 llseek _llseek __llseek _lseek __lseek
362 _lstat __lstat lutimes
363 __lxstat memalign mknod mlock mlockall munlock munlockall
364 _open __open _opendir __opendir
365 pathconf poll posix_fallocate
366 posix_memalign pread _pread __pread
367 pwrite _pwrite __pwrite
368 rdchk _read __read _readdir __readdir
370 select setenv setgidx setgroups setlocale setluid
371 setmntent setpgid setpriv setsid setuidx
372 shmget shm_open sigaction sigblock sigprocmask sigset
374 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
375 __sys_llseek syslog _telldir __telldir timegm
376 utimensat vsyslog _write __write __xstat
379 conf
.CHECK_SAMBA3_CHARSET() # see build/charset.py
381 # FIXME: these should be tests for features, but the old build system just
383 host_os
= sys
.platform
384 Logs
.info("building on %s" % host_os
)
386 # Python doesn't have case switches... :/
387 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
388 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
390 conf
.SET_TARGET_TYPE('sunacl', 'EMPTY')
391 if (host_os
.rfind('linux') > -1) or (host_os
.rfind('gnu') > -1) or (host_os
.rfind('qnx') > -1):
392 if host_os
.rfind('linux') > -1:
393 conf
.DEFINE('LINUX', '1')
394 elif host_os
.rfind('qnx') > -1:
395 conf
.DEFINE('QNX', '1')
396 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
397 elif (host_os
.rfind('darwin') > -1):
398 conf
.DEFINE('DARWINOS', 1)
399 conf
.ADD_CFLAGS('-fno-common')
400 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
401 elif (host_os
.rfind('freebsd') > -1):
402 conf
.DEFINE('FREEBSD', 1)
403 if conf
.CHECK_HEADERS('sunacl.h'):
404 conf
.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
405 conf
.CHECK_FUNCS_IN('acl', 'sunacl')
406 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
407 elif (host_os
.rfind('irix') > -1):
408 conf
.DEFINE('IRIX', 1)
409 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
410 elif (host_os
.rfind('aix') > -1):
411 conf
.DEFINE('AIX', 1)
412 conf
.DEFINE('STAT_ST_BLOCKSIZE', 'DEV_BSIZE')
413 elif (host_os
.rfind('hpux') > -1):
414 conf
.DEFINE('HPUX', 1)
415 conf
.DEFINE('STAT_ST_BLOCKSIZE', '8192')
416 elif (host_os
.rfind('osf') > -1):
417 conf
.DEFINE('OSF1', 1)
418 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
420 # FIXME: Add more checks here.
422 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
424 if Options
.options
.with_acl_support
:
425 if (host_os
.rfind('sysv5') > -1) and conf
.CHECK_FUNCS_IN('sec', 'facl', checklibc
=True):
426 Logs
.info('Using UnixWare ACLs')
427 conf
.DEFINE('HAVE_UNIXWARE_ACLS',1)
428 default_static_modules
.extend(TO_LIST('vfs_solarisacl'))
429 elif (host_os
.rfind('solaris') > -1) and conf
.CHECK_FUNCS_IN('sec', 'facl'):
430 Logs
.info('Using solaris ACLs')
431 conf
.DEFINE('HAVE_SOLARIS_ACLS',1)
432 default_static_modules
.extend(TO_LIST('vfs_solarisacl'))
433 elif (host_os
.rfind('hpux') > -1):
434 Logs
.info('Using HPUX ACLs')
435 conf
.DEFINE('HAVE_HPUX_ACLS',1)
436 conf
.DEFINE('POSIX_ACL_NEEDS_MASK',1)
437 default_static_modules
.extend(TO_LIST('vfs_hpuxacl'))
438 elif (host_os
.rfind('aix') > -1):
439 Logs
.info('Using AIX ACLs')
440 conf
.DEFINE('HAVE_AIX_ACLS',1)
441 default_static_modules
.extend(TO_LIST('vfs_aixacl vfs_aixacl2'))
442 elif (host_os
.rfind('osf') > -1) and conf
.CHECK_FUNCS_IN('pacl', 'acl_get_fd'):
443 Logs
.info('Using Tru64 ACLs')
444 conf
.DEFINE('HAVE_TRU64_ACLS',1)
445 default_static_modules
.extend(TO_LIST('vfs_tru64acl'))
446 elif (host_os
.rfind('darwin') > -1):
447 Logs
.warn('ACLs on Darwin currently not supported')
448 conf
.fatal("ACL support not available on Darwin/MacOS. "
449 "Use --without-acl-support for building without "
451 "ACL support is required to change permissions "
452 "from Windows clients.")
454 conf
.CHECK_FUNCS_IN('acl_get_file', 'acl')
455 if conf
.CHECK_CODE('''
458 acl_entry_t *entry_p;
459 return acl_get_entry(acl, entry_id, entry_p);
462 headers
='sys/types.h sys/acl.h', link
=False,
463 msg
="Checking for POSIX ACL support") :
465 acl_permset_t permset_d;
467 return acl_get_perm_np(permset_d, perm);
469 'HAVE_ACL_GET_PERM_NP',
470 headers
='sys/types.h sys/acl.h', link
=True,
471 msg
="Checking whether acl_get_perm_np() is available")
472 default_static_modules
.extend(TO_LIST('vfs_posixacl'))
474 conf
.fatal("ACL support not found. Try installing libacl1-dev "
476 "Otherwise, use --without-acl-support to build "
477 "without ACL support. "
478 "ACL support is required to change permissions from "
481 if conf
.CHECK_FUNCS('dirfd'):
482 conf
.DEFINE('HAVE_DIRFD_DECL', 1)
484 conf
.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
485 'HAVE_STATFS_F_FSID',
486 msg
="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
487 headers
='sys/types.h sys/statfs.h',
490 if conf
.CONFIG_SET('HAVE_FALLOCATE'):
492 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
493 'HAVE_LINUX_FALLOCATE',
494 msg
="Checking whether the Linux 'fallocate' function is available",
495 headers
='unistd.h sys/types.h fcntl.h linux/falloc.h')
497 ssize_t err = readahead(0,0,0x80000);''',
498 'HAVE_LINUX_READAHEAD',
499 msg
="Checking whether Linux readahead is available",
500 headers
='unistd.h fcntl.h')
501 conf
.CHECK_DECLS('readahead', headers
='fcntl.h', always
=True)
503 conf
.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
505 msg
='Checking for openat',
508 if Options
.options
.with_aio_support
:
509 conf
.CHECK_FUNCS_IN('aio_read', 'aio')
510 conf
.CHECK_FUNCS_IN('aio_read', 'rt')
511 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);',
513 msg
='Checking for asynchronous io support',
514 headers
='sys/types.h aio.h',
516 if conf
.CONFIG_SET('HAVE_AIO'):
517 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg
='Checking for aio_read', headers
='aio.h', lib
='aio rt')
518 conf
.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg
='Checking for aio_write', headers
='aio.h', lib
='aio rt')
519 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')
520 conf
.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg
='Checking for aio_return', headers
='aio.h', lib
='aio rt')
521 conf
.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg
='Checking for aio_error', headers
='aio.h', lib
='aio rt')
522 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')
523 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')
524 if not conf
.CONFIG_SET('HAVE_AIO'):
525 conf
.DEFINE('HAVE_NO_AIO', '1')
527 conf
.DEFINE('HAVE_NO_AIO', '1')
529 if host_os
.rfind('linux') > -1:
530 conf
.CHECK_FUNCS_IN('io_submit', 'aio')
532 struct io_event ioev;
538 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
539 io_queue_init(128,&ctx);
540 io_prep_pwrite(ioc, 1, buf, 1, 0);
541 io_prep_pread(ioc, 1, buf, 1, 0);
542 io_set_eventfd(ioc, fd);
543 io_set_callback(ioc, (io_callback_t)(0));
544 io_submit(ctx, 1, &ioc);
545 io_getevents(ctx, 1, 1, &ioev, &ts);
547 'HAVE_LINUX_KERNEL_AIO',
548 msg
='Checking for linux kernel asynchronous io support',
549 headers
='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
556 char control[CMSG_SPACE(sizeof(int))];
558 msg.msg_control = control_un.control;
559 msg.msg_controllen = sizeof(control_un.control);
561 'HAVE_MSGHDR_MSG_CONTROL',
562 msg
='Checking if we can use msg_control for passing file descriptors',
563 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
567 msg.msg_acctrights = (caddr_t) &fd;
568 msg.msg_acctrightslen = sizeof(fd);
570 'HAVE_MSGHDR_MSG_ACCTRIGHTS',
571 msg
='Checking if we can use msg_acctrights for passing file descriptors',
572 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
574 if Options
.options
.with_winbind
:
575 conf
.env
.build_winbind
= True
576 conf
.DEFINE('WITH_WINBIND', '1')
578 conf
.find_program('awk', var
='AWK')
579 conf
.find_program('perl', var
='PERL')
581 conf
.CHECK_HEADERS('asm/types.h')
583 conf
.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
584 headers
='unistd.h sys/types.h',
585 msg
="Checking for major macro")
587 conf
.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
588 headers
='unistd.h sys/types.h',
589 msg
="Checking for minor macro")
591 conf
.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
592 headers
='unistd.h sys/types.h dirent.h',
593 define
='HAVE_DIRENT_D_OFF')
595 conf
.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
596 if conf
.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
597 netgrent_cflags
= '-Werror-implicit-function-declaration'
600 conf
.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
601 msg
="Checking for setnetgrent prototype",
602 headers
='netdb.h netgroup.h',
603 cflags
=netgrent_cflags
)
604 conf
.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
605 msg
="Checking for getnetgrent prototype",
606 headers
='netdb.h netgroup.h',
607 cflags
=netgrent_cflags
)
608 conf
.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
609 msg
="Checking for endnetgrent prototype",
610 headers
='netdb.h netgroup.h',
611 cflags
=netgrent_cflags
)
615 if Options
.options
.with_cups
:
616 conf
.find_program('cups-config', var
='CUPS_CONFIG')
617 if conf
.env
.CUPS_CONFIG
:
618 # we would normally use --libs here, but cups-config incorrectly adds
619 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
620 # of an in-tree heimdal kerberos
621 conf
.check_cfg(path
=conf
.env
.CUPS_CONFIG
, args
="--cflags --ldflags",
622 package
="", uselib_store
="CUPS")
623 conf
.CHECK_HEADERS('cups/cups.h cups/language.h', lib
='cups')
624 conf
.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
625 if conf
.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf
.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
626 conf
.DEFINE('HAVE_CUPS', '1')
628 conf
.undefine('HAVE_CUPS')
629 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
631 # define an empty subsystem for cups, to allow it to be used as an empty dependency
632 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
634 if Options
.options
.with_iprint
:
635 if conf
.CONFIG_SET('HAVE_CUPS'):
636 conf
.DEFINE('HAVE_IPRINT', '1')
638 Logs
.warn("--enable-iprint=yes but cups support not sufficient")
639 if Options
.options
.with_syslog
:
640 conf
.DEFINE('WITH_SYSLOG', '1')
641 if Options
.options
.with_automount
:
642 conf
.DEFINE('WITH_AUTOMOUNT', '1')
645 if Options
.options
.with_ldap
:
646 conf
.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
647 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
648 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
649 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
651 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
653 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
654 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
656 conf
.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
657 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
659 # Check if ldap_set_rebind_proc() takes three arguments
660 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
661 'LDAP_SET_REBIND_PROC_ARGS',
662 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
663 headers
='ldap.h lber.h', link
=False):
664 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
666 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
668 # last but not least, if ldap_init() exists, we want to use ldap
669 if conf
.CONFIG_SET('HAVE_LDAP_INIT') and conf
.CONFIG_SET('HAVE_LDAP_H'):
670 conf
.DEFINE('HAVE_LDAP', '1')
671 conf
.DEFINE('LDAP_DEPRECATED', '1')
672 conf
.env
['HAVE_LDAP'] = '1'
673 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
674 # SASL wrapping hooks
675 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
676 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
677 conf
.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
679 conf
.fatal("LDAP support not found. "
680 "Try installing libldap2-dev or openldap-devel. "
681 "Otherwise, use --without-ldap to build without "
683 "LDAP support is required for the LDAP passdb backend, "
684 "LDAP idmap backends and ADS. "
685 "ADS support improves communication with "
686 "Active Directory domain controllers.")
688 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
689 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
691 if Options
.options
.with_ads
== False:
699 if not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
700 not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
701 Logs
.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
703 if not conf
.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
704 Logs
.warn("krb5_mk_req_extended not found in -lkrb5")
706 if not conf
.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
707 Logs
.warn("krb5_get_host_realm not found in -lkrb5")
709 if not conf
.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
710 Logs
.warn("krb5_free_host_realm not found in -lkrb5")
712 if not conf
.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
713 Logs
.warn("krb5_fwd_tgt_creds found in -lkrb5")
715 if not conf
.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
716 Logs
.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
718 if not conf
.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
719 Logs
.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
721 if not conf
.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
722 Logs
.warn("krb5_get_renewed_creds not found in -lkrb5")
724 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
725 Logs
.warn("krb5_principal_compare_any_realm not found in -lkrb5")
727 if not conf
.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
728 not conf
.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
729 Logs
.warn("krb5_c_string_to_key not found in -lkrb5")
731 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
732 not conf
.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
733 Logs
.warn("no CREATE_KEY_FUNCTIONS detected")
735 if not conf
.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
736 not conf
.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
737 Logs
.warn("no GET_ENCTYPES_FUNCTIONS detected")
739 if not conf
.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
740 not conf
.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
741 Logs
.warn("no KT_FREE_FUNCTION detected")
743 if not conf
.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
744 Logs
.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
747 # We don't actually use
748 # gsskrb5_extract_authz_data_from_sec_context, but it is a
749 # clue that this Heimdal, which does the PAC processing we
750 # need on the standard gss_inquire_sec_context_by_oid
751 if not conf
.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
752 not (conf
.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
753 conf
.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
754 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")
757 if not conf
.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
758 Logs
.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
762 conf
.DEFINE('HAVE_KRB5', '1')
763 conf
.env
['HAVE_KRB5'] = '1'
765 conf
.undefine('HAVE_KRB5_H')
766 conf
.undefine('HAVE_GSSAPI_H')
767 conf
.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
768 conf
.undefine('HAVE_GSSAPI_GSSAPI_H')
771 if not conf
.CONFIG_SET('HAVE_LDAP'):
776 conf
.DEFINE('WITH_ADS', '1')
777 conf
.env
['HAVE_ADS'] = '1'
778 Logs
.info("Building with Active Directory support.")
779 elif Options
.options
.with_ads
== False:
780 Logs
.info("Building without Active Directory support (--without-ads).")
783 Logs
.warn("Active Directory support not available: krb5 libs don't have all required features")
785 Logs
.warn("Active Directory support not available: LDAP support is not available.")
786 if Options
.options
.with_ads
:
787 conf
.fatal("Active Directory support not found. Use --without-ads "
788 "for building without Active Directory support. "
789 "ADS support improves communication with "
790 "Active Directory domain controllers.")
792 # this is the auto-mode case
793 Logs
.warn("Building without Active Directory support.")
796 if Options
.options
.with_utmp
:
797 conf
.env
.with_utmp
= True
798 if not conf
.CHECK_HEADERS('utmp.h'): conf
.env
.with_utmp
= False
799 conf
.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
800 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers
='utmp.h',
801 define
='HAVE_UT_UT_NAME')
802 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers
='utmp.h',
803 define
='HAVE_UT_UT_USER')
804 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers
='utmp.h',
805 define
='HAVE_UT_UT_ID')
806 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers
='utmp.h',
807 define
='HAVE_UT_UT_HOST')
808 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers
='utmp.h',
809 define
='HAVE_UT_UT_TIME')
810 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers
='utmp.h',
811 define
='HAVE_UT_UT_TV')
812 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers
='utmp.h',
813 define
='HAVE_UT_UT_TYPE')
814 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers
='utmp.h',
815 define
='HAVE_UT_UT_PID')
816 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers
='utmp.h',
817 define
='HAVE_UT_UT_EXIT')
818 conf
.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers
='utmpx.h',
819 define
='HAVE_UX_UT_SYSLEN')
820 conf
.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
821 'PUTUTLINE_RETURNS_UTMP', headers
='utmp.h',
822 msg
="Checking whether pututline returns pointer")
823 conf
.CHECK_SIZEOF(['((struct utmp *)NULL)->ut_line'], headers
='utmp.h',
824 define
='SIZEOF_UTMP_UT_LINE')
825 if not conf
.CONFIG_SET('SIZEOF_UTMP_UT_LINE'):
826 conf
.env
.with_utmp
= False
827 elif int(conf
.env
.SIZEOF_UTMP_UT_LINE
) < 15:
828 conf
.env
.with_utmp
= False
829 if conf
.env
.with_utmp
:
830 conf
.DEFINE('WITH_UTMP', 1)
832 Logs
.warn("--with-utmp but utmp support not sufficient")
834 if Options
.options
.with_avahi
:
835 conf
.env
.with_avahi
= True
836 if not conf
.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf
.env
.with_avahi
= False
837 if not conf
.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf
.env
.with_avahi
= False
838 if not conf
.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf
.env
.with_avahi
= False
839 if conf
.env
.with_avahi
:
840 conf
.DEFINE('WITH_AVAHI_SUPPORT', 1)
842 conf
.SET_TARGET_TYPE('avahi-common', 'EMPTY')
843 conf
.SET_TARGET_TYPE('avahi-client', 'EMPTY')
845 if Options
.options
.with_iconv
:
846 conf
.env
.with_iconv
= True
847 if not conf
.CHECK_FUNCS_IN('iconv_open', 'iconv', headers
='iconv.h'):
848 conf
.env
.with_iconv
= False
849 if conf
.env
.with_iconv
:
850 conf
.DEFINE('HAVE_ICONV', 1)
852 if Options
.options
.with_pam
:
854 conf
.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
855 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
856 Logs
.warn("--with-pam=yes but pam_appl.h not found")
858 conf
.CHECK_FUNCS_IN('pam_get_data', 'pam')
859 conf
.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
860 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
861 Logs
.warn("--with-pam=yes but pam_modules.h not found")
863 conf
.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
864 conf
.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
865 conf
.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
867 #if defined(HAVE_SECURITY_PAM_APPL_H)
868 #include <security/pam_appl.h>
869 #elif defined(HAVE_PAM_PAM_APPL_H)
870 #include <pam/pam_appl.h>
872 pam_set_item(0, PAM_RHOST, 0);
876 msg
="Checking whether PAM_RHOST is available");
878 #if defined(HAVE_SECURITY_PAM_APPL_H)
879 #include <security/pam_appl.h>
880 #elif defined(HAVE_PAM_PAM_APPL_H)
881 #include <pam/pam_appl.h>
883 pam_set_item(0, PAM_TTY, 0);
887 msg
="Checking whether PAM_TTY is available");
889 #if (!defined(LINUX))
891 #define PAM_EXTERN extern
892 #if defined(HAVE_SECURITY_PAM_APPL_H)
893 #include <security/pam_appl.h>
894 #elif defined(HAVE_PAM_PAM_APPL_H)
895 #include <pam/pam_appl.h>
900 #if defined(HAVE_SECURITY_PAM_MODULES_H)
901 #include <security/pam_modules.h>
902 #elif defined(HAVE_PAM_PAM_MODULES_H)
903 #include <pam/pam_modules.h>
906 #if defined(HAVE_SECURITY__PAM_MACROS_H)
907 #include <security/_pam_macros.h>
908 #elif defined(HAVE_PAM__PAM_MACROS_H)
909 #include <pam/_pam_macros.h>
912 #ifdef HAVE_SECURITY_PAM_EXT_H
913 #include <security/pam_ext.h>
916 int i; i = PAM_RADIO_TYPE;
918 'HAVE_PAM_RADIO_TYPE',
920 msg
="Checking whether PAM_RADIO_TYPE is available");
922 conf
.DEFINE('WITH_PAM', 1)
923 conf
.DEFINE('WITH_PAM_MODULES', 1)
925 if Options
.options
.with_pam_smbpass
:
926 conf
.env
.with_pam_smbpass
= True
931 # Ensure we select the correct set of system calls on Linux.
933 if (host_os
.rfind('linux') > -1):
935 #if defined(HAVE_UNISTD_H)
940 #include <sys/types.h>
943 #ifdef HAVE_SYS_PRIV_H
944 #include <sys/priv.h>
950 #if defined(HAVE_SYSCALL_H)
954 #if defined(HAVE_SYS_SYSCALL_H)
955 #include <sys/syscall.h>
958 syscall(SYS_setresuid32, -1, -1, -1);
959 syscall(SYS_setresgid32, -1, -1, -1);
960 syscall(SYS_setreuid32, -1, -1);
961 syscall(SYS_setregid32, -1, -1);
962 syscall(SYS_setuid32, -1);
963 syscall(SYS_setgid32, -1);
964 syscall(SYS_setgroups32, 0, NULL);
966 'USE_LINUX_32BIT_SYSCALLS',
967 msg
="Checking whether Linux should use 32-bit credential calls");
969 if (conf
.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
970 seteuid
= conf
.CHECK_CODE('''
971 #define AUTOCONF_TEST 1
972 #define USE_LINUX_THREAD_CREDENTIALS 1
973 #define USE_LINUX_32BIT_SYSCALLS 1
974 #include "../lib/util/setid.c"
975 #include "./lib/util_sec.c"
977 'USE_LINUX_THREAD_CREDENTIALS',
980 msg
="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
982 seteuid
= conf
.CHECK_CODE('''
983 #define AUTOCONF_TEST 1
984 #define USE_LINUX_THREAD_CREDENTIALS 1
985 #include "../lib/util/setid.c"
986 #include "./lib/util_sec.c"
988 'USE_LINUX_THREAD_CREDENTIALS',
991 msg
="Checking whether we can use Linux thread-specific credentials")
993 seteuid
= conf
.CHECK_CODE('''
994 #define AUTOCONF_TEST 1
995 #define USE_SETREUID 1
996 #include "../lib/util/setid.c"
997 #include "./lib/util_sec.c"
1002 msg
="Checking whether setreuid is available")
1004 seteuid
= conf
.CHECK_CODE('''
1005 #define AUTOCONF_TEST 1
1006 #define USE_SETRESUID 1
1007 #include "../lib/util/setid.c"
1008 #include "./lib/util_sec.c"
1013 msg
="Checking whether setresuid is available")
1015 seteuid
= conf
.CHECK_CODE('''
1016 #define AUTOCONF_TEST 1
1017 #define USE_SETEUID 1
1018 #include "../lib/util/setid.c"
1019 #include "./lib/util_sec.c"
1024 msg
="Checking whether seteuid is available")
1026 seteuid
= conf
.CHECK_CODE('''
1027 #define AUTOCONF_TEST 1
1028 #define USE_SETUIDX 1
1029 #include "../lib/util/setid.c"
1030 #include "./lib/util_sec.c"
1036 msg
="Checking whether setuidx is available")
1037 if Options
.options
.with_dnsupdate
:
1038 if not conf
.CONFIG_SET('HAVE_KRB5'):
1039 Logs
.warn("--with-dnsupdate=yes but gssapi support not sufficient")
1041 conf
.DEFINE('WITH_DNS_UPDATES', 1)
1042 conf
.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
1043 if Options
.options
.developer
:
1044 if conf
.CONFIG_SET('HAVE_VALGRIND_H') or conf
.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
1045 conf
.DEFINE('VALGRIND', '1')
1047 if conf
.CHECK_CODE('''
1048 #include <bits/sockaddr.h>
1049 #include <linux/netlink.h>
1051 'HAVE_LINUX_NETLINK_H',
1052 msg
="Checking whether Linux netlink is available"):
1055 #include <bits/sockaddr.h>
1056 #include <linux/netlink.h>
1057 #include <linux/rtnetlink.h>
1059 'HAVE_LINUX_RTNETLINK_H',
1060 msg
='Checking whether Linux rtnetlink is available')
1063 #include "../tests/fcntl_lock.c"
1068 msg
='Checking whether fcntl locking is available')
1070 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
1071 if not conf
.CHECK_CODE('''
1072 #define _XOPEN_SOURCE 600
1074 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
1075 #error probably broken posix_fallocate
1078 '_HAVE_UNBROKEN_POSIX_FALLOCATE',
1079 msg
='Checking for broken posix_fallocate'):
1080 conf
.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
1083 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1084 define
='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1085 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1086 define
='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1087 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1088 define
='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1089 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1090 define
='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1091 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1092 define
='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1093 if conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1094 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1095 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1096 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1097 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1098 conf
.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1100 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1101 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1102 define
='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1103 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1104 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1105 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1106 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1109 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1111 'HAVE_POSIX_FADVISE',
1112 msg
='Checking whether posix_fadvise is available',
1113 headers
='unistd.h fcntl.h')
1115 for v
in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1118 return sysconf(%s) == -1 ? 1 : 0;
1121 msg
='Checking whether sysconf(%s) is available' % v
)
1124 #include <sys/syscall.h>
1126 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1128 'HAVE_DARWIN_INITGROUPS',
1129 msg
='Checking whether to use the Darwin-specific initgroups system call')
1131 conf
.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1133 headers
='sys/types.h utime.h',
1134 msg
='Checking whether struct utimbuf is available')
1136 if conf
.CHECK_CODE('''struct sigevent s;''',
1137 'HAVE_STRUCT_SIGEVENT',
1138 headers
='sys/types.h stdlib.h stddef.h signal.h',
1139 msg
='Checking whether we have the struct sigevent'):
1140 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1141 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1142 headers
='signal.h');
1143 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1144 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1145 headers
='signal.h');
1147 if os
.path
.exists('/proc/sys/kernel/core_pattern'):
1148 conf
.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
1150 if conf
.CHECK_CODE('''
1154 if (sizeof(time_t) == 8) {
1155 time_t max_time = 0x7fffffffffffffffll;
1156 tm = gmtime(&max_time);
1157 /* This should fail with 32-bit tm_year. */
1159 /* Max time_t that works with 32-bit int tm_year in struct tm. */
1160 max_time = 67768036191676799ll;
1161 tm = gmtime(&max_time);
1172 msg
="Checking for the maximum value of the 'time_t' type"):
1173 conf
.DEFINE('TIME_T_MAX', '67768036191676799ll')
1176 #if defined(HAVE_UNISTD_H)
1179 #include <sys/types.h>
1180 main() { dev_t dev = makedev(1,2); return 0; }
1184 msg
='Checking whether the macro for makedev is available')
1191 void exit_on_core(int ignored) {
1197 signal(SIGSEGV, exit_on_core);
1198 newpath = realpath("/tmp", NULL);
1199 exit((newpath != NULL) ? 0 : 1);
1202 'REALPATH_TAKES_NULL',
1205 msg
='Checking whether the realpath function allows a NULL argument')
1207 conf
.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1208 'HAVE_FTRUNCATE_EXTEND',
1209 msg
='Checking for ftruncate extend',
1213 if Options
.options
.with_sendfile_support
:
1214 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):
1219 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1222 headers
='sys/sendfile.h',
1223 msg
='Checking for linux sendfile support')
1225 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1226 conf
.DEFINE('HAVE_SENDFILE', '1')
1227 conf
.DEFINE('LINUX_SENDFILE_API', '1')
1228 conf
.DEFINE('WITH_SENDFILE', '1')
1229 elif (host_os
.rfind('freebsd') > -1) or (host_os
.rfind('dragonfly') > -1):
1231 #include <sys/types.h>
1233 #include <sys/socket.h>
1234 #include <sys/uio.h>
1235 int fromfd, tofd, ret, total=0;
1236 off_t offset, nwritten;
1239 hdr.headers = &hdtrl;
1241 hdr.trailers = NULL;
1243 hdtrl.iov_base = NULL;
1245 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1248 msg
='Checking for freebsd sendfile support')
1249 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1250 conf
.DEFINE('HAVE_SENDFILE', '1')
1251 conf
.DEFINE('FREEBSD_SENDFILE_API', '1')
1252 conf
.DEFINE('WITH_SENDFILE', '1')
1253 elif (host_os
.rfind('darwin') > -1):
1255 #include <sys/types.h>
1256 #include <sys/socket.h>
1257 #include <sys/uio.h>
1258 int fromfd, tofd, ret;
1259 off_t offset, nwritten;
1262 hdr.headers = &hdtrl;
1264 hdr.trailers = (void *)0;
1266 hdtrl.iov_base = (void *)0;
1268 ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1271 msg
='Checking for darwin sendfile support')
1272 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1273 conf
.DEFINE('HAVE_SENDFILE', '1')
1274 conf
.DEFINE('DARWIN_SENDFILE_API', '1')
1275 conf
.DEFINE('WITH_SENDFILE', '1')
1276 elif (host_os
.rfind('hpux') > -1) or (host_os
.rfind('osf') > -1):
1278 #include <sys/socket.h>
1279 #include <sys/uio.h>
1282 struct iovec hdtrl[2];
1285 hdtrl[0].iov_base = 0;
1286 hdtrl[0].iov_len = 0;
1287 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1290 msg
='Checking for osf/hpux sendfile support')
1291 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1292 conf
.DEFINE('HAVE_SENDFILE', '1')
1293 conf
.DEFINE('HPUX_SENDFILE_API', '1')
1294 conf
.DEFINE('WITH_SENDFILE', '1')
1295 elif (host_os
.rfind('solaris') > -1):
1296 conf
.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1298 #include <sys/sendfile.h>,
1301 struct sendfilevec vec[2];
1305 vec[0].sfv_fd = SFV_FD_SELF;
1306 vec[0].sfv_flag = 0;
1310 vec[1].sfv_flag = 0;
1313 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1316 msg
='Checking for solaris sendfilev support')
1317 if conf
.CONFIG_SET('_HAVE_SENDFILEV'):
1318 conf
.DEFINE('HAVE_SENDFILEV', '1')
1319 conf
.DEFINE('SOLARIS_SENDFILE_API', '1')
1320 conf
.DEFINE('WITH_SENDFILE', '1')
1321 elif (host_os
.rfind('aix') > -1):
1323 #include <sys/socket.h>
1326 struct sf_parms hdtrl;
1328 hdtrl.header_data = 0;
1329 hdtrl.header_length = 0;
1330 hdtrl.file_descriptor = fromfd;
1331 hdtrl.file_offset = 0;
1332 hdtrl.file_bytes = 0;
1333 hdtrl.trailer_data = 0;
1334 hdtrl.trailer_length = 0;
1335 nwritten = send_file(&tofd, &hdtrl, 0);
1338 msg
='Checking for AIX send_file support')
1339 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1340 conf
.DEFINE('HAVE_SENDFILE', '1')
1341 conf
.DEFINE('AIX_SENDFILE_API', '1')
1342 conf
.DEFINE('WITH_SENDFILE', '1')
1344 # Check for getcwd allowing a NULL arg.
1348 char *s = getcwd(NULL,0);
1349 exit(s != NULL ? 0 : 1);
1350 }''', 'GETCWD_TAKES_NULL', addmain
=False, execute
=True,
1351 msg
="getcwd takes a NULL argument")
1354 # UnixWare 7.x has its getspnam in -lgen
1355 conf
.CHECK_FUNCS_IN('getspnam', 'gen')
1356 conf
.CHECK_FUNCS_IN('getspnam', 'security')
1357 conf
.CHECK_FUNCS_IN('getspnam', 'sec')
1359 if Options
.options
.with_quotas
:
1360 # For quotas on Veritas VxFS filesystems
1361 conf
.CHECK_HEADERS('sys/fs/vx_quota.h')
1362 # For sys/quota.h and linux/quota.h
1363 conf
.CHECK_HEADERS('sys/quota.h')
1364 # For quotas on BSD systems
1365 conf
.CHECK_HEADERS('ufs/ufs/quota.h')
1366 # For quotas on Linux XFS filesystems
1367 if conf
.CHECK_HEADERS('xfs/xqm.h'):
1368 conf
.DEFINE('HAVE_XFS_QUOTAS', '1')
1372 #include "confdefs.h"
1373 #ifdef HAVE_SYS_TYPES_H
1374 #include <sys/types.h>
1376 #ifdef HAVE_ASM_TYPES_H
1377 #include <asm/types.h>
1379 #include <sys/quota.h>
1380 int i = Q_XGETQUOTA;''',
1381 define
='HAVE_XFS_QUOTAS',
1382 msg
='for XFS QUOTA in <sys/quota.h>',
1384 local_include
=False)
1386 # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
1387 conf
.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define
='HAVE_DQB_FSOFTLIMIT',
1388 headers
='sys/quota.h')
1389 #darwin style quota bytecount
1390 conf
.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_curbytes', define
='HAVE_STRUCT_DQBLK_DQB_CURBYTES',
1391 headers
='sys/quota.h')
1392 if conf
.CHECK_HEADERS('rpcsvc/rquota.h'):
1393 conf
.DEFINE('HAVE_NFS_QUOTAS', '1')
1394 conf
.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1395 define
='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1396 headers
='rpcsvc/rquota.h')
1398 if (host_os
.rfind('linux') > -1):
1399 conf
.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1400 elif not conf
.CONFIG_SET("HAVE_XFS_QUOTAS"):
1401 if not conf
.CHECK_CODE('''
1402 #define HAVE_QUOTACTL_4A 1
1403 #define AUTOCONF_TEST 1
1404 #include "../tests/sysquotas.c"
1406 cflags
=conf
.env
['WERROR_CFLAGS'],
1407 define
='HAVE_QUOTACTL_4A',
1408 msg
='for QUOTACTL_4A: long quotactl(int cmd, char *special, qid_t id, caddr_t addr)',
1413 #define HAVE_QUOTACTL_4B 1
1414 #define AUTOCONF_TEST 1
1415 #include "../tests/sysquotas.c"
1417 cflags
=conf
.env
['WERROR_CFLAGS'],
1418 define
='HAVE_QUOTACTL_4B',
1419 msg
='for QUOTACTL_4B: int quotactl(const char *path, int cmd, int id, char *addr)',
1424 clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
1426 headers
="rpc/rpc.h rpc/types.h rpcsvc/rquota.h rpc/nettype.h rpc/xdr.h",
1427 define
='HAVE_NFS_QUOTAS',
1428 msg
='for NFS QUOTAS',
1430 local_include
=False)
1432 if conf
.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1433 conf
.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1434 conf
.CONFIG_SET('HAVE_QUOTACTL_4B') or \
1435 conf
.CONFIG_SET('HAVE_XFS_QUOTAS'):
1436 conf
.DEFINE('HAVE_SYS_QUOTAS', '1')
1437 conf
.DEFINE('WITH_QUOTAS', '1')
1440 # checking for clustering extensions (CTDB)
1442 if Options
.options
.with_cluster_support
== False:
1443 # configure is called with --without-cluster-support,
1444 # so don't check for and build w/o ctdb support.
1445 have_cluster_support
= False
1449 if Options
.options
.ctdb_dir
:
1450 conf
.ADD_EXTRA_INCLUDES(Options
.options
.ctdb_dir
+ '/include')
1452 srcdir
= os
.path
.realpath(conf
.srcdir
)
1453 if 'EXTRA_INCLUDES' in conf
.env
:
1454 includes
= ' '.join(conf
.env
['EXTRA_INCLUDES']).replace('#', srcdir
+ '/')
1458 if not conf
.env
.USING_SYSTEM_TDB
:
1459 includes
= includes
+ ' ' + srcdir
+ '/lib/tdb/include'
1461 if not conf
.env
.USING_SYSTEM_TALLOC
:
1462 includes
= includes
+ ' ' + srcdir
+ '/lib/talloc'
1464 have_cluster_support
= True
1469 #include "replace.h"
1470 #include "system/wait.h"
1471 #include "system/network.h"
1472 #define private #error __USED_RESERVED_WORD_private__
1485 msg
='Checking for header ctdb.h')
1487 if not conf
.CONFIG_SET('HAVE_CTDB_H'):
1488 have_cluster_support
= False
1489 ctdb_broken
= "ctdb.h is required for cluster support"
1491 if have_cluster_support
:
1494 #include "replace.h"
1495 #include "system/wait.h"
1496 #include "system/network.h"
1497 #define private #error __USED_RESERVED_WORD_private__
1501 #include <ctdb_private.h>
1508 'HAVE_CTDB_PRIVATE_H',
1511 msg
='Checking for header ctdb_private.h')
1513 if not conf
.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
1514 have_cluster_support
= False
1515 ctdb_broken
= "ctdb_private.h is required for cluster support"
1517 if have_cluster_support
:
1520 #include "replace.h"
1521 #include "system/wait.h"
1522 #include "system/network.h"
1523 #define private #error __USED_RESERVED_WORD_private__
1527 #include <ctdb_protocol.h>
1534 'HAVE_CTDB_PROTOCOL_H',
1537 msg
='Checking for header ctdb_protocol.h')
1539 if have_cluster_support
:
1542 #include "replace.h"
1543 #include "system/wait.h"
1544 #include "system/network.h"
1548 #include <ctdb_private.h>
1552 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1556 'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
1559 msg
='Checking for transaction support (TRANS3_COMMIT control)')
1561 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
1562 have_cluster_support
= False
1563 ctdb_broken
= "ctdb transaction support missing or too old"
1565 if have_cluster_support
:
1568 #include "replace.h"
1569 #include "system/wait.h"
1570 #include "system/network.h"
1574 #include <ctdb_private.h>
1578 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1582 'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
1585 msg
='Checking for SCHEDULE_FOR_DELETION control')
1587 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
1588 if not Options
.options
.enable_old_ctdb
:
1589 have_cluster_support
= False
1590 ctdb_broken
= "SCHEDULE_FOR_DELETION control missing"
1592 Logs
.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1594 if have_cluster_support
:
1597 #include "replace.h"
1598 #include "system/wait.h"
1599 #include "system/network.h"
1606 int i = (int)CTDB_WANT_READONLY;
1610 'HAVE_CTDB_WANT_READONLY_DECL',
1613 msg
='Checking for CTDB readonly records support')
1615 if not conf
.CONFIG_SET('HAVE_CTDB_WANT_READONLY_DECL'):
1616 if not Options
.options
.enable_old_ctdb
:
1617 have_cluster_support
= False
1618 ctdb_broken
= "support for CTDB readonly records missing"
1620 Logs
.warn("ignoring missing READONLY support (--enable-old-ctdb)")
1622 if have_cluster_support
:
1625 #include "replace.h"
1626 #include "system/wait.h"
1627 #include "system/network.h"
1631 #include <ctdb_private.h>
1635 struct ctdb_control_tcp _x;
1639 'HAVE_STRUCT_CTDB_CONTROL_TCP',
1642 msg
='Checking for ctdb ipv4 support')
1644 if not conf
.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
1645 have_cluster_support
= False
1646 ctdb_broken
= "missing struct ctdb_control_tcp"
1648 if have_cluster_support
:
1651 #include "replace.h"
1652 #include "system/wait.h"
1653 #include "system/network.h"
1657 #include <ctdb_private.h>
1661 struct ctdb_control_tcp_addr _x;
1665 'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
1668 msg
='Checking for ctdb ipv6 support')
1670 if have_cluster_support
:
1673 #include "replace.h"
1674 #include "system/wait.h"
1675 #include "system/network.h"
1679 #include <ctdb_private.h>
1683 int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1687 'HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL',
1690 msg
='Checking for CHECK_SRVIDS control')
1692 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL'):
1693 if not Options
.options
.enable_old_ctdb
:
1694 have_cluster_support
= False
1695 ctdb_broken
= "CHECK_SRVIDS control missing"
1697 Logs
.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1699 if have_cluster_support
:
1700 Logs
.info("building with cluster support")
1701 conf
.DEFINE('CLUSTER_SUPPORT', 1);
1703 if Options
.options
.with_cluster_support
== False:
1704 Logs
.info("building without cluster support (--without-cluster-support)")
1705 elif Options
.options
.with_cluster_support
== True:
1706 Logs
.error("Cluster support not available: " + ctdb_broken
)
1707 conf
.fatal("Cluster support not found, but --with-cluster-support was specified")
1709 Logs
.info("building without cluster support: " + ctdb_broken
)
1710 conf
.undefine('CLUSTER_SUPPORT')
1713 conf
.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1714 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1717 msg
='Checking whether we can compile with __attribute__((destructor))')
1719 conf
.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1720 'SEEKDIR_RETURNS_VOID',
1721 headers
='sys/types.h dirent.h',
1722 msg
='Checking whether seekdir returns void')
1724 if Options
.options
.with_profiling_data
:
1725 conf
.DEFINE('WITH_PROFILE', 1);
1727 PTHREAD_CFLAGS
='error'
1728 PTHREAD_LDFLAGS
='error'
1730 if PTHREAD_LDFLAGS
== 'error':
1731 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
1732 PTHREAD_CFLAGS
='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
1733 PTHREAD_LDFLAGS
='-lpthread'
1734 if PTHREAD_LDFLAGS
== 'error':
1735 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
1736 PTHREAD_CFLAGS
='-D_THREAD_SAFE'
1737 PTHREAD_LDFLAGS
='-lpthreads'
1738 if PTHREAD_LDFLAGS
== 'error':
1739 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
1740 PTHREAD_CFLAGS
='-D_THREAD_SAFE -pthread'
1741 PTHREAD_LDFLAGS
='-pthread'
1742 if PTHREAD_LDFLAGS
== 'error':
1743 if conf
.CHECK_FUNCS('pthread_attr_init'):
1744 PTHREAD_CFLAGS
='-D_REENTRANT'
1745 PTHREAD_LDFLAGS
='-lpthread'
1746 # especially for HP-UX, where the CHECK_FUNC macro fails to test for
1747 # pthread_attr_init. On pthread_mutex_lock it works there...
1748 if PTHREAD_LDFLAGS
== 'error':
1749 if conf
.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
1750 PTHREAD_CFLAGS
='-D_REENTRANT'
1751 PTHREAD_LDFLAGS
='-lpthread'
1753 if PTHREAD_CFLAGS
!= 'error' and PTHREAD_LDFLAGS
!= 'error':
1754 conf
.ADD_CFLAGS(PTHREAD_CFLAGS
)
1755 conf
.ADD_LDFLAGS(PTHREAD_LDFLAGS
)
1756 conf
.CHECK_HEADERS('pthread.h')
1757 conf
.DEFINE('HAVE_PTHREAD', '1')
1759 if Options
.options
.with_pthreadpool
:
1760 if conf
.CONFIG_SET('HAVE_PTHREAD'):
1761 conf
.DEFINE('WITH_PTHREADPOOL', '1')
1763 Logs
.warn("pthreadpool support cannot be enabled when pthread support was not found")
1764 conf
.undefine('WITH_PTHREADPOOL')
1766 if conf
.CHECK_HEADERS('gpfs_gpl.h'):
1767 conf
.DEFINE('HAVE_GPFS', '1')
1769 if (conf
.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
1770 conf
.CHECK_DECLS('FS_IOC_GETFLAGS FS_COMPR_FL', headers
='linux/fs.h')):
1771 conf
.DEFINE('HAVE_LINUX_IOCTL', '1')
1773 conf
.env
['CCFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64"
1774 if Options
.options
.libcephfs_dir
:
1775 conf
.env
['CPPPATH_CEPHFS'] = Options
.options
.libcephfs_dir
+ '/include'
1776 conf
.env
['LIBPATH_CEPHFS'] = Options
.options
.libcephfs_dir
+ '/lib'
1778 if conf
.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and conf
.CHECK_LIB('cephfs'):
1779 conf
.DEFINE('HAVE_CEPH', '1')
1781 if Options
.options
.with_glusterfs
:
1782 conf
.check_cfg(package
='glusterfs-api', args
='"glusterfs-api >= 4" --cflags --libs',
1783 msg
='Checking for glusterfs-api >= 4', uselib_store
="GFAPI")
1784 conf
.CHECK_HEADERS('api/glfs.h', lib
='gfapi')
1785 conf
.CHECK_LIB('gfapi', shlib
=True)
1787 if conf
.CONFIG_SET('HAVE_API_GLFS_H'):
1788 conf
.DEFINE('HAVE_GLUSTERFS', '1')
1790 conf
.SET_TARGET_TYPE('gfapi', 'EMPTY')
1791 conf
.undefine('HAVE_GLUSTERFS')
1793 conf
.SET_TARGET_TYPE('gfapi', 'EMPTY')
1794 conf
.undefine('HAVE_GLUSTERFS')
1796 conf
.env
.build_regedit
= False
1797 if not Options
.options
.with_regedit
== False:
1798 conf
.PROCESS_SEPARATE_RULE('system_ncurses')
1799 if conf
.CONFIG_SET('HAVE_NCURSES'):
1800 conf
.env
.build_regedit
= True
1802 if conf
.env
.build_regedit
:
1803 Logs
.info("building regedit")
1805 if Options
.options
.with_regedit
== False:
1806 Logs
.info("not building regedit (--without-regedit)")
1807 elif Options
.options
.with_regedit
== True:
1808 Logs
.error("ncurses not available, cannot build regedit")
1809 conf
.fatal("ncurses not available, but --with-regedit was specified")
1811 Logs
.info("ncurses not available, not building regedit")
1814 default_static_modules
.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1815 auth_sam auth_unix auth_winbind auth_wbc
1816 auth_domain auth_builtin vfs_default
1817 nss_info_template idmap_tdb idmap_passdb
1820 default_shared_modules
.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1821 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1822 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1823 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1824 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1825 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1829 vfs_crossrename vfs_linux_xfs_sgid
1830 vfs_time_audit idmap_autorid idmap_tdb2
1832 idmap_rid idmap_hash idmap_rfc2307'''))
1834 if Options
.options
.developer
:
1835 default_static_modules
.extend(TO_LIST('charset_weird'))
1836 default_shared_modules
.extend(TO_LIST('perfcount_test'))
1837 default_shared_modules
.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1838 default_shared_modules
.extend(TO_LIST('auth_skel pdb_test'))
1840 if Options
.options
.enable_selftest
or Options
.options
.developer
:
1841 default_shared_modules
.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr'))
1844 if conf
.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1845 default_static_modules
.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
1847 if conf
.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1848 default_shared_modules
.extend(TO_LIST('vfs_zfsacl'))
1850 if conf
.CONFIG_SET('HAVE_DIRFD_DECL'):
1851 default_shared_modules
.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1853 if conf
.CONFIG_SET('HAVE_STATFS_F_FSID'):
1854 default_shared_modules
.extend(TO_LIST('vfs_fileid'))
1856 if (conf
.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf
.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
1857 default_shared_modules
.extend(TO_LIST('vfs_aio_fork'))
1859 if Options
.options
.with_pthreadpool
:
1860 default_shared_modules
.extend(TO_LIST('vfs_aio_pthread'))
1862 if conf
.CONFIG_SET('HAVE_AIO'):
1863 default_shared_modules
.extend(TO_LIST('vfs_aio_posix'))
1865 if conf
.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1866 default_shared_modules
.extend(TO_LIST('vfs_aio_linux'))
1868 if conf
.CONFIG_SET('HAVE_LDAP'):
1869 default_static_modules
.extend(TO_LIST('pdb_ldapsam idmap_ldap'))
1871 if conf
.CONFIG_SET('DARWINOS'):
1872 default_static_modules
.extend(TO_LIST('charset_macosxfs'))
1874 if conf
.CONFIG_SET('HAVE_GPFS'):
1875 default_shared_modules
.extend(TO_LIST('vfs_gpfs'))
1877 if conf
.CONFIG_SET('HAVE_LINUX_IOCTL'):
1878 default_shared_modules
.extend(TO_LIST('vfs_btrfs'))
1880 if conf
.CONFIG_SET('SAMBA_FAM_LIBS'):
1881 default_shared_modules
.extend(TO_LIST('vfs_notify_fam'))
1883 if conf
.CONFIG_SET("HAVE_CEPH"):
1884 default_shared_modules
.extend(TO_LIST('vfs_ceph'))
1886 if conf
.CONFIG_SET('HAVE_GLUSTERFS'):
1887 default_shared_modules
.extend(TO_LIST('vfs_glusterfs'))
1889 explicit_shared_modules
= TO_LIST(Options
.options
.shared_modules
, delimiter
=',')
1890 explicit_static_modules
= TO_LIST(Options
.options
.static_modules
, delimiter
=',')
1892 def replace_list_item(lst
, item
, value
):
1894 idx
= lst
.index(item
)
1898 # PDB module file name should have the same name as module registers itself
1899 # In Autoconf build we export LDAP passdb module as ldapsam but WAF build
1900 # was always exporting pdb_ldap. In order to support existing packages
1901 # allow referring to pdb_ldapsam as pdb_ldap but use proper name internally.
1902 replace_list_item(explicit_shared_modules
, 'pdb_ldap', 'pdb_ldapsam')
1903 replace_list_item(explicit_static_modules
, 'pdb_ldap', 'pdb_ldapsam')
1905 final_static_modules
= default_static_modules
1906 final_shared_modules
= default_shared_modules
1908 for m
in explicit_static_modules
:
1909 if m
in final_shared_modules
:
1910 final_shared_modules
.remove(m
)
1911 final_static_modules
.append(m
)
1912 for m
in explicit_shared_modules
:
1913 if m
in final_static_modules
:
1914 final_static_modules
.remove(m
)
1915 final_shared_modules
.append(m
)
1917 if ("auth_domain" not in final_static_modules
) or \
1918 ("auth_builtin" not in final_static_modules
) or \
1919 ("auth_sam" not in final_static_modules
) or \
1920 ("auth_winbind" not in final_static_modules
):
1921 raise Utils
.WafError('These auth modules MUST be configured as static modules: auth_domain, auth_builtin, auth_sam, auth_winbind')
1923 conf
.env
['static_modules'] = final_static_modules
1924 conf
.env
['shared_modules'] = final_shared_modules
1926 conf
.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules
), quote
=True)
1931 prefixes
= ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1932 conf
.env
['MODULE_PREFIXES'] = prefixes
1934 for m
in final_static_modules
:
1936 if not p
in static_list
:
1938 static_list
[p
].append(m
)
1939 for m
in final_shared_modules
:
1941 if not p
in shared_list
:
1943 shared_list
[p
].append(m
)
1946 static_env
= "%s_STATIC" % p
.upper()
1947 shared_env
= "%s_SHARED" % p
.upper()
1948 conf
.env
[static_env
] = []
1949 conf
.env
[shared_env
] = []
1950 if p
in static_list
:
1952 for entry
in static_list
[p
]:
1953 decl_list
+= "extern NTSTATUS %s_init(void); " % entry
1954 conf
.env
[static_env
].append('%s' % entry
)
1955 decl_list
= decl_list
.rstrip()
1956 conf
.DEFINE('static_decl_%s' % p
, decl_list
)
1957 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(); }' % '_init(); '.join(static_list
[p
]))
1959 conf
.DEFINE('static_decl_%s' % p
, '')
1960 conf
.DEFINE('static_init_%s' % p
, '{}')
1961 if p
in shared_list
:
1962 for entry
in shared_list
[p
]:
1963 conf
.DEFINE('%s_init' % entry
, 'samba_init_module')
1964 conf
.env
[shared_env
].append('%s' % entry
)
1966 conf
.SAMBA_CONFIG_H('include/config.h')
1969 "build 'tags' file using ctags"
1971 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
1972 cmd
= 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1973 print("Running: %s" % cmd
)