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)
24 opt.add_option('--enable-selftest',
25 help=("enable options necessary for selftest"),
26 action="store_true", dest='enable_selftest', default=False)
28 opt.SAMBA3_ADD_OPTION('winbind')
29 opt.SAMBA3_ADD_OPTION('swat')
30 opt.SAMBA3_ADD_OPTION('ads')
31 opt.SAMBA3_ADD_OPTION('mit-krb5-checks', default=False)
32 opt.SAMBA3_ADD_OPTION('ldap')
33 opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
34 opt.SAMBA3_ADD_OPTION('iprint', with_name="enable", without_name="disable")
35 opt.SAMBA3_ADD_OPTION('pam')
36 opt.SAMBA3_ADD_OPTION('pam_smbpass')
37 opt.SAMBA3_ADD_OPTION('quotas')
38 opt.SAMBA3_ADD_OPTION('sys-quotas')
39 opt.SAMBA3_ADD_OPTION('sendfile-support')
40 opt.SAMBA3_ADD_OPTION('utmp')
41 opt.SAMBA3_ADD_OPTION('pthreadpool', with_name="enable", without_name="disable")
42 opt.SAMBA3_ADD_OPTION('avahi', with_name="enable", without_name="disable")
43 opt.SAMBA3_ADD_OPTION('iconv')
44 opt.SAMBA3_ADD_OPTION('acl-support')
45 opt.SAMBA3_ADD_OPTION('dnsupdate')
46 opt.SAMBA3_ADD_OPTION('syslog')
47 opt.SAMBA3_ADD_OPTION('automount')
48 opt.SAMBA3_ADD_OPTION('aio-support')
49 opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
51 opt.SAMBA3_ADD_OPTION('cluster-support')
53 opt.add_option('--with-ctdb-dir',
54 help=("Directory under which ctdb is installed"),
55 action="store", dest='ctdb_dir', default=None)
56 opt.add_option('--enable-old-ctdb',
57 help=("enable building against (too) old version of ctdb (default=false)"),
58 action="store_true", dest='enable_old_ctdb', default=False)
63 from samba_utils import TO_LIST
65 if Options.options.developer:
66 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
67 conf.env.developer = True
69 if Options.options.with_swat:
70 conf.env['build_swat'] = True
72 if sys.platform != 'openbsd5':
73 conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
75 conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
76 conf.CHECK_HEADERS('linux/falloc.h')
78 conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
79 conf.CHECK_FUNCS('strtol strchr strupr chflags')
80 conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
81 conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
82 conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
83 conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
84 conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf stat64 fstat64')
85 conf.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 fallocate fallocate64 posix_fallocate posix_fallocate64')
86 conf.CHECK_FUNCS('fseeko fseek64 fseeko64 ftell64 ftello64 setluid')
87 conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
88 conf.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
89 conf.CHECK_FUNCS('fdopendir fdopendir64')
90 conf.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
91 conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
92 conf.CHECK_FUNCS_IN('nanosleep', 'rt')
93 conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
94 conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
95 conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
96 conf.CHECK_FUNCS('shmget')
97 conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
98 conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain bind_textdomain_codeset')
99 #FIXME: for some reason this one still fails
100 conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
101 conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
102 conf.CHECK_DECLS('fdatasync', reverse=True)
103 conf.CHECK_DECLS('readahead', reverse=True, headers='fcntl.h')
105 if conf.CONFIG_SET('HAVE_LONG_LONG'):
106 conf.DEFINE('HAVE_LONGLONG', 1)
108 if conf.CHECK_CODE('''
109 #if defined(HAVE_UNISTD_H)
112 long ret = splice(0,0,1,0,400,0);
116 conf.CHECK_DECLS('splice', reverse=True, headers='fcntl.h')
118 # Check for inotify support
119 conf.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
120 conf.CHECK_FUNCS('inotify_init')
121 if "HAVE_INOTIFY_INIT" in conf.env:
122 if "HAVE_LINUX_INOTIFY_H" in conf.env or "HAVE_SYS_INOTIFY_H" in conf.env:
123 conf.DEFINE('HAVE_INOTIFY', 1)
125 # Check for kernel change notify support
128 #define F_NOTIFY 1026
131 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
132 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
133 headers='fcntl.h signal.h',
134 msg="Checking for kernel change notify support")
136 # Check for Linux kernel oplocks
138 #include <sys/types.h>
142 #define F_NOTIFY 1026
145 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
146 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
147 msg="Checking for Linux kernel oplocks")
149 # Check for IRIX kernel oplock types
150 conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
151 'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
152 msg="Checking for IRIX kernel oplock types")
154 # Check for kernel share modes
156 #include <sys/types.h>
159 #include <sys/file.h>
165 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
166 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
167 msg="Checking for krenel share modes")
169 # Check for various members of the stat structure
170 conf.CHECK_TYPES('blksize_t blkcnt_t')
171 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
172 headers='sys/stat.h')
173 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
174 headers='sys/stat.h')
175 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define='HAVE_STAT_ST_FLAGS',
176 headers='sys/types.h sys/stat.h unistd.h')
178 # Check for POSIX capability support
179 conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
181 if "HAVE_SYS_CAPABILITY_H" in conf.env:
185 if (!(cap = cap_get_proc())) exit(1);
187 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
188 cap_set_proc(cap);''',
189 'HAVE_POSIX_CAPABILITIES', execute=True, lib="cap",
190 headers='sys/capability.h',
191 msg="Checking whether POSIX capabilities are available")
193 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
194 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
196 if conf.CONFIG_SET("HAVE_RPC_RPC_H"):
197 conf.CHECK_TYPE('int16', headers='rpc/rpc.h',
198 define='HAVE_INT16_FROM_RPC_RPC_H',
199 msg="Checking for int16 typedef included by rpc/rpc.h")
200 conf.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
201 headers='sys/types.h rpc/rpc.h',
202 msg="Checking for uint16 typedef included by rpc/rpc.h")
203 conf.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
204 headers='sys/types.h rpc/rpc.h',
205 msg="Checking for int32 typedef included by rpc/rpc.h")
206 conf.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
207 headers='sys/types.h rpc/rpc.h',
208 msg="Checking for uint32 typedef included by rpc/rpc.h")
209 conf.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
210 headers='sys/types.h sys/acl.h rpcsvc/nis.h',
211 msg="Checking for broken nisplus include files")
213 # Check if the compiler will optimize out functions
216 this_function_does_not_exist();
219 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
220 msg="Checking if the compiler will optimize out functions")
222 # Check if the compiler supports the LL suffix on long long integers
224 conf.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
226 msg="Checking for LL suffix on long long integers")
229 _acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
230 attropen attr_remove attr_removef attr_set attr_setf
231 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
232 __closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
233 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
234 extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
235 extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
236 extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
237 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
238 fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
239 _fork __fork fremoveea fremovexattr fseeko fseek64 fseeko64 fsetea
240 fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
241 ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
242 getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
243 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
244 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
245 glob grantpt hstrerror initgroups innetgr
246 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
247 llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
248 lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
249 __lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
250 _open __open open64 _open64 __open64 _opendir __opendir
251 opendir64 pathconf poll posix_fallocate posix_fallocate64
252 posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
253 pwrite _pwrite __pwrite pwrite64 _pwrite64
254 __pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
255 __readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
256 seekdir64 select setea setenv setgidx setgroups setlocale setluid
257 setmntent setpgid setpriv setproplist setsid setuidx
258 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
259 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
260 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
261 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
262 utimensat vsyslog _write __write __xstat
265 conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
267 # FIXME: these should be tests for features, but the old build system just
269 host_os = sys.platform
270 Logs.info("building on %s" % host_os)
272 # Python doesn't have case switches... :/
273 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
274 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
276 conf.SET_TARGET_TYPE('sunacl', 'EMPTY')
277 if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('qnx') > -1):
278 if host_os.rfind('linux') > -1:
279 conf.DEFINE('LINUX', '1')
280 elif host_os.rfind('qnx') > -1:
281 conf.DEFINE('QNX', '1')
282 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
283 elif (host_os.rfind('darwin') > -1):
284 conf.DEFINE('DARWINOS', 1)
285 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
286 conf.ADD_CFLAGS('-fno-common')
287 elif (host_os.rfind('freebsd') > -1):
288 if conf.CHECK_HEADERS('sunacl.h'):
289 conf.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
290 conf.CHECK_FUNCS_IN('acl', 'sunacl')
291 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
292 elif (host_os.rfind('netbsd') > -1):
293 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
294 elif (host_os.rfind('openbsd') > -1):
295 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
296 elif (host_os.rfind('sunos') > -1):
297 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
298 # FIXME: Add more checks here.
300 Logs.warn("Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os)
302 #FIXME: add more checks
303 if Options.options.with_acl_support:
304 if host_os.rfind('linux') > -1:
305 conf.CHECK_FUNCS_IN('acl_get_file', 'acl')
306 conf.CHECK_FUNCS_IN('getxattr', 'attr')
307 if conf.CHECK_CODE('''
310 acl_entry_t *entry_p;
311 return acl_get_entry(acl, entry_id, entry_p);
314 headers='sys/types.h sys/acl.h', link=False,
315 msg="Checking for POSIX ACL support") :
317 acl_permset_t permset_d;
319 return acl_get_perm_np(permset_d, perm);
321 'HAVE_ACL_GET_PERM_NP',
322 headers='sys/types.h sys/acl.h', link=True,
323 msg="Checking whether acl_get_perm_np() is available")
325 conf.DEFINE('HAVE_NO_ACLS', 1)
326 conf.SET_TARGET_TYPE('acl', 'EMPTY')
328 conf.DEFINE('HAVE_NO_ACLS', 1)
329 conf.SET_TARGET_TYPE('acl', 'EMPTY')
331 if conf.CHECK_FUNCS('dirfd'):
332 conf.DEFINE('HAVE_DIRFD_DECL', 1)
334 conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
335 'HAVE_STATFS_F_FSID',
336 msg="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
337 headers='sys/types.h sys/statfs.h',
340 if conf.CONFIG_SET('HAVE_FALLOCATE'):
342 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
343 'HAVE_LINUX_FALLOCATE',
344 msg="Checking whether the Linux 'fallocate' function is available",
345 headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
346 if conf.CONFIG_SET('HAVE_FALLOCATE64'):
348 int ret = fallocate64(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
349 'HAVE_LINUX_FALLOCATE64',
350 msg="Checking whether the Linux 'fallocate64' function is available",
351 headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
353 ssize_t err = readahead(0,0,0x80000);''',
354 'HAVE_LINUX_READAHEAD',
355 msg="Checking whether Linux readahead is available",
356 headers='unistd.h fcntl.h')
357 conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
360 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
361 #include <sys/types.h>
366 'HAVE_EXPLICIT_LARGEFILE_SUPPORT',
367 msg="Checking whether large file support can be enabled")
369 if Options.options.with_aio_support:
370 conf.CHECK_FUNCS_IN('aio_read', 'aio')
371 conf.CHECK_FUNCS_IN('aio_read', 'rt')
372 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);',
374 msg='Checking for asynchronous io support',
375 headers='sys/types.h aio.h',
377 conf.CHECK_CODE('struct aiocb64 a; return aio_read64(&a);',
379 msg='Checking for 64-bit asynchronous io support',
380 headers='sys/types.h aio.h',
382 if conf.CONFIG_SET('HAVE_AIO64'):
383 conf.DEFINE('HAVE_AIOCB64', '1')
384 conf.DEFINE('WITH_AIO', '1')
385 elif conf.CONFIG_SET('HAVE_AIO'):
386 conf.DEFINE('WITH_AIO', '1')
387 if conf.CONFIG_SET('HAVE_AIO'):
388 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg='Checking for aio_read', headers='aio.h', lib='aio rt')
389 conf.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg='Checking for aio_write', headers='aio.h', lib='aio rt')
390 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')
391 conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
392 conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
393 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')
394 conf.CHECK_CODE('struct aiocb a; return aio_suspend(&a, 1, NULL);', 'HAVE_AIO_SUSPEND', msg='Checking for aio_suspend', headers='aio.h', lib='aio rt')
395 if conf.CONFIG_SET('HAVE_AIO64'):
396 conf.CHECK_CODE('struct aiocb a; return aio_read64(&a);', 'HAVE_AIO_READ64', msg='Checking for aio_read64', headers='aio.h', lib='aio rt')
397 conf.CHECK_CODE('struct aiocb a; return aio_write64(&a);', 'HAVE_AIO_WRITE64', msg='Checking for aio_write64', headers='aio.h', lib='aio rt')
398 conf.CHECK_CODE('struct aiocb a; return aio_fsync64(1, &a);', 'HAVE_AIO_FSYNC64', msg='Checking for aio_fsync64', headers='aio.h', lib='aio rt')
399 conf.CHECK_CODE('struct aiocb a; return aio_return64(&a);', 'HAVE_AIO_RETURN64', msg='Checking for aio_return64', headers='aio.h', lib='aio rt')
400 conf.CHECK_CODE('struct aiocb a; return aio_error64(&a);', 'HAVE_AIO_ERROR64', msg='Checking for aio_error64', headers='aio.h', lib='aio rt')
401 conf.CHECK_CODE('struct aiocb a; return aio_cancel64(1, &a);', 'HAVE_AIO_CANCEL64', msg='Checking for aio_cancel64', headers='aio.h', lib='aio rt')
402 conf.CHECK_CODE('struct aiocb a; return aio_suspend64(&a, 1, NULL);', 'HAVE_AIO_SUSPEND64', msg='Checking for aio_suspend64', headers='aio.h', lib='aio rt')
403 if not conf.CONFIG_SET('HAVE_AIO'):
404 conf.DEFINE('HAVE_NO_AIO', '1')
406 conf.DEFINE('HAVE_NO_AIO', '1')
412 char control[CMSG_SPACE(sizeof(int))];
414 msg.msg_control = control_un.control;
415 msg.msg_controllen = sizeof(control_un.control);
417 'HAVE_MSGHDR_MSG_CONTROL',
418 msg='Checking if we can use msg_control for passing file descriptors',
419 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
423 msg.msg_acctrights = (caddr_t) &fd;
424 msg.msg_acctrightslen = sizeof(fd);
426 'HAVE_MSGHDR_MSG_ACCTRIGHTS',
427 msg='Checking if we can use msg_acctrights for passing file descriptors',
428 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
430 if Options.options.with_winbind:
431 conf.env.build_winbind = True
432 conf.DEFINE('WITH_WINBIND', '1')
434 conf.find_program('awk', var='AWK')
435 conf.find_program('perl', var='PERL')
437 # Darwin has extra options to xattr-family functions
438 conf.CHECK_CODE('getxattr(0, 0, 0, 0, 0, 0);',
440 msg="Checking whether xattr interface takes additional options",
441 headers='sys/types.h attr/xattr.h sys/xattr.h')
443 conf.CHECK_HEADERS('asm/types.h')
445 conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
446 headers='unistd.h sys/types.h',
447 msg="Checking for major macro")
449 conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
450 headers='unistd.h sys/types.h',
451 msg="Checking for minor macro")
453 conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
454 headers='unistd.h sys/types.h dirent.h',
455 define='HAVE_DIRENT_D_OFF')
457 conf.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
458 if conf.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
459 netgrent_cflags = '-Werror-implicit-function-declaration'
462 conf.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
463 msg="Checking for setnetgrent prototype",
464 headers='netdb.h netgroup.h',
465 cflags=netgrent_cflags)
466 conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
467 msg="Checking for getnetgrent prototype",
468 headers='netdb.h netgroup.h',
469 cflags=netgrent_cflags)
470 conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
471 msg="Checking for endnetgrent prototype",
472 headers='netdb.h netgroup.h',
473 cflags=netgrent_cflags)
477 if Options.options.with_cups:
478 conf.find_program('cups-config', var='CUPS_CONFIG')
479 if conf.env.CUPS_CONFIG:
480 # we would normally use --libs here, but cups-config incorrectly adds
481 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
482 # of an in-tree heimdal kerberos
483 conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
484 package="", uselib_store="CUPS")
485 conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
486 conf.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
487 if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
488 conf.DEFINE('HAVE_CUPS', '1')
490 conf.undefine('HAVE_CUPS')
491 conf.SET_TARGET_TYPE('cups', 'EMPTY')
493 # define an empty subsystem for cups, to allow it to be used as an empty dependency
494 conf.SET_TARGET_TYPE('cups', 'EMPTY')
496 if Options.options.with_iprint:
497 if conf.CONFIG_SET('HAVE_CUPS'):
498 conf.DEFINE('HAVE_IPRINT', '1')
500 Logs.warn("--enable-iprint=yes but cups support not sufficient")
501 if Options.options.with_syslog:
502 conf.DEFINE('WITH_SYSLOG', '1')
503 if Options.options.with_automount:
504 conf.DEFINE('WITH_AUTOMOUNT', '1')
507 if Options.options.with_ldap:
508 conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
509 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
510 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
511 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
513 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
515 conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
516 define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
518 conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
519 conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
521 # Check if ldap_set_rebind_proc() takes three arguments
522 if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
523 'LDAP_SET_REBIND_PROC_ARGS',
524 msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
525 headers='ldap.h lber.h', link=False):
526 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
528 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
530 # last but not least, if ldap_init() exists, we want to use ldap
531 if conf.CONFIG_SET('HAVE_LDAP_INIT'):
532 conf.DEFINE('HAVE_LDAP', '1')
533 conf.DEFINE('LDAP_DEPRECATED', '1')
534 conf.env['HAVE_LDAP'] = '1'
535 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
536 # SASL wrapping hooks
537 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
538 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
539 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
541 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
542 conf.SET_TARGET_TYPE('lber', 'EMPTY')
546 if Options.options.with_mit_krb5_checks and conf.env.developer:
547 Logs.info("Looking for kerberos features")
548 conf.find_program('krb5-config', var='KRB5_CONFIG')
549 if conf.env.KRB5_CONFIG:
550 conf.check_cfg(path="krb5-config", args="--cflags --libs",
551 package="gssapi", uselib_store="KRB5")
552 conf.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib='krb5')
553 conf.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h gssapi/gssapi_krb5.h com_err.h', lib='krb5')
555 if conf.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
556 conf.env['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
558 conf.CHECK_FUNCS_IN('_et_list', 'com_err')
559 conf.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
560 conf.CHECK_FUNCS_IN('des_set_key','crypto')
561 conf.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
562 conf.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
563 if conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi') or \
564 conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi_krb5'):
566 conf.CHECK_FUNCS_IN('''
569 gss_get_name_attribute
572 gss_inquire_sec_context_by_oid
573 gsskrb5_extract_authz_data_from_sec_context
574 gss_krb5_export_lucid_sec_context
575 ''', 'gssapi gssapi_krb5 krb5')
576 conf.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
578 krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
579 krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
580 krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
581 krb5_auth_con_setuseruserkey krb5_get_permitted_enctypes
582 krb5_get_default_in_tkt_etypes krb5_free_data_contents
583 krb5_principal_get_comp_string krb5_free_unparsed_name
584 krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
585 krb5_krbhst_get_addrinfo
586 krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
587 krb5_c_verify_checksum krb5_principal_compare_any_realm
588 krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
589 krb5_get_renewed_creds krb5_free_error_contents
590 initialize_krb5_error_table krb5_get_init_creds_opt_alloc
591 krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
592 krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
593 krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
594 krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
596 conf.CHECK_DECLS('''krb5_get_credentials_for_user
597 krb5_auth_con_set_req_cksumtype''',
598 headers='krb5.h', always=True)
599 conf.CHECK_VARIABLE('AP_OPTS_USE_SUBKEY', headers='krb5.h')
600 conf.CHECK_VARIABLE('KV5M_KEYTAB', headers='krb5.h')
601 conf.CHECK_VARIABLE('KRB5_KU_OTHER_CKSUM', headers='krb5.h')
602 conf.CHECK_VARIABLE('KRB5_KEYUSAGE_APP_DATA_CKSUM', headers='krb5.h')
603 conf.CHECK_VARIABLE('ENCTYPE_AES128_CTS_HMAC_SHA1_96', headers='krb5.h')
604 conf.CHECK_VARIABLE('ENCTYPE_AES256_CTS_HMAC_SHA1_96', headers='krb5.h')
605 conf.CHECK_DECLS('KRB5_PDU_NONE', reverse=True, headers='krb5.h')
606 conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'key', headers='krb5.h',
607 define='HAVE_KRB5_KEYTAB_ENTRY_KEY')
608 conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'keyblock', headers='krb5.h',
609 define='HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK')
610 conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'magic', headers='krb5.h',
611 define='HAVE_MAGIC_IN_KRB5_ADDRESS')
612 conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'addrtype', headers='krb5.h',
613 define='HAVE_ADDRTYPE_IN_KRB5_ADDRESS')
614 conf.CHECK_STRUCTURE_MEMBER('krb5_ap_req', 'ticket', headers='krb5.h',
615 define='HAVE_TICKET_POINTER_IN_KRB5_AP_REQ')
617 conf.CHECK_TYPE('krb5_encrypt_block', headers='krb5.h')
622 krb5_enctype enctype;
623 enctype = ticket.enc_part.enctype;
624 kvno = ticket.enc_part.kvno;
626 'KRB5_TICKET_HAS_KEYINFO',
627 headers='krb5.h', link=False,
628 msg="Checking whether the krb5_ticket structure contains the kvno and enctype")
631 krb5_get_init_creds_opt *opt = NULL;
632 krb5_get_init_creds_opt_free(ctx, opt);
634 'KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT',
635 headers='krb5.h', link=False,
636 msg="Checking whether krb5_get_init_creds_opt_free takes a context argument")
638 const krb5_data *pkdata;
639 krb5_context context;
640 krb5_principal principal;
641 pkdata = krb5_princ_component(context, principal, 0);
643 'HAVE_KRB5_PRINC_COMPONENT',
644 headers='krb5.h', lib='krb5',
645 msg="Checking whether krb5_princ_component is available")
650 krb5_enctype_to_string(1, buf, 256);
653 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG',
654 headers='krb5.h', lib='krb5 k5crypto',
655 addmain=False, cflags='-Werror',
656 msg="Checking whether krb5_enctype_to_string takes size_t argument")
660 krb5_context context = NULL;
662 krb5_enctype_to_string(context, 1, &str);
666 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG',
667 headers='krb5.h stdlib.h', lib='krb5',
668 addmain=False, cflags='-Werror',
669 msg="Checking whether krb5_enctype_to_string takes krb5_context argument")
672 krb5_context ctx = NULL;
673 krb5_principal princ = NULL;
674 const char *str = krb5_princ_realm(ctx, princ)->data;
677 'HAVE_KRB5_PRINC_REALM',
678 headers='krb5.h', lib='krb5',
680 msg="Checking whether the macro krb5_princ_realm is defined")
683 krb5_context context;
684 krb5_principal principal;
685 const char *realm; realm = krb5_principal_get_realm(context, principal);
688 'HAVE_KRB5_PRINCIPAL_GET_REALM',
689 headers='krb5.h', lib='krb5',
691 msg="Checking whether krb5_principal_get_realm is defined")
693 krb5_enctype enctype;
694 enctype = ENCTYPE_ARCFOUR_HMAC_MD5;
696 '_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5',
697 headers='krb5.h', lib='krb5',
698 msg="Checking whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available");
700 krb5_keytype keytype;
701 keytype = KEYTYPE_ARCFOUR_56;
703 '_HAVE_KEYTYPE_ARCFOUR_56',
704 headers='krb5.h', lib='krb5',
705 msg="Checking whether the HAVE_KEYTYPE_ARCFOUR_56 key type definition is available");
706 if conf.CONFIG_SET('_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and conf.CONFIG_SET('_HAVE_KEYTYPE_ARCFOUR_56'):
707 conf.DEFINE('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', '1')
710 krb5_enctype enctype;
711 enctype = ENCTYPE_ARCFOUR_HMAC;
713 'HAVE_ENCTYPE_ARCFOUR_HMAC',
714 headers='krb5.h', lib='krb5',
715 msg="Checking whether the ENCTYPE_ARCFOUR_HMAC key type definition is available");
718 krb5_context context;
720 krb5_init_context(&context);
721 return krb5_kt_resolve(context, "WRFILE:api", &keytab);
723 'HAVE_WRFILE_KEYTAB',
724 headers='krb5.h', lib='krb5', execute=True,
725 msg="Checking whether the WRFILE:-keytab is supported");
727 # Check for KRB5_DEPRECATED handling
728 conf.CHECK_CODE('''#define KRB5_DEPRECATED 1
729 #include <krb5.h>''',
730 'HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER', addmain=False,
732 msg="Checking for KRB5_DEPRECATED define taking an identifier")
734 if Options.options.with_ads:
736 if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
737 not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
738 Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
740 if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
741 Logs.warn("krb5_mk_req_extended not found in -lkrb5")
743 if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
744 Logs.warn("krb5_get_host_realm not found in -lkrb5")
746 if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
747 Logs.warn("krb5_free_host_realm not found in -lkrb5")
749 if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
750 Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
752 if not conf.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
753 Logs.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
755 if not conf.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
756 Logs.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
758 if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
759 Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
761 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
762 Logs.warn("krb5_principal_compare_any_realm not found in -lkrb5")
764 if not conf.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY'):
765 Logs.warn("krb5_string_to_key not found in -lkrb5")
767 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
768 not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
769 Logs.warn("no CREATE_KEY_FUNCTIONS detected")
771 if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
772 not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
773 Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
775 if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
776 not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
777 Logs.warn("no KT_FREE_FUNCTION detected")
779 if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
780 Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
782 if not conf.CONFIG_SET('KRB5_TICKET_HAS_KEYINFO'):
783 # We only need the following functions if we can't get the enctype
784 # and kvno out of the ticket directly (ie. on Heimdal).
785 if not conf.CONFIG_SET('HAVE_FREE_AP_REQ'):
786 Logs.warn("no KRB5_AP_REQ_FREE_FUNCTION detected")
788 if not conf.CONFIG_SET('HAVE_KRB5_DECODE_AP_REQ'):
789 Logs.warn("no KRB5_AP_REQ_DECODING_FUNCTION detected")
792 # We don't actually use
793 # gsskrb5_extract_authz_data_from_sec_context, but it is a
794 # clue that this Heimdal, which does the PAC processing we
795 # need on the standard gss_inquire_sec_context_by_oid
796 if not conf.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
797 not (conf.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
798 conf.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
799 Logs.warn("need eiterh gss_get_name_attribute or gsskrb5_extract_authz_data_from_sec_context and gss_inquire_sec_context_by_oid in -lgssapi for PAC support")
802 if not conf.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
803 Logs.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
807 conf.DEFINE('WITH_ADS', '1')
808 conf.DEFINE('HAVE_KRB5', '1')
809 if conf.CONFIG_SET('HAVE_LDAP'):
810 conf.env['HAVE_ADS'] = '1'
812 Logs.warn("krb5 libs don't have all features required for Active Directory support")
813 conf.undefine('HAVE_KRB5_H')
814 conf.undefine('HAVE_GSSAPI_H')
815 conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
816 conf.undefine('HAVE_GSSAPI_GSSAPI_H')
818 if Options.options.with_utmp:
819 conf.env.with_utmp = True
820 if not conf.CHECK_HEADERS('utmp.h'): conf.env.with_utmp = False
821 conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
822 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
823 define='HAVE_UT_UT_NAME')
824 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers='utmp.h',
825 define='HAVE_UT_UT_USER')
826 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers='utmp.h',
827 define='HAVE_UT_UT_ID')
828 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers='utmp.h',
829 define='HAVE_UT_UT_HOST')
830 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers='utmp.h',
831 define='HAVE_UT_UT_TIME')
832 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers='utmp.h',
833 define='HAVE_UT_UT_TV')
834 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers='utmp.h',
835 define='HAVE_UT_UT_TYPE')
836 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers='utmp.h',
837 define='HAVE_UT_UT_PID')
838 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers='utmp.h',
839 define='HAVE_UT_UT_EXIT')
840 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers='utmp.h',
841 define='HAVE_UT_UT_ADDR_V6')
842 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers='utmp.h',
843 define='HAVE_UT_UT_ADDR')
844 conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers='utmpx.h',
845 define='HAVE_UX_UT_SYSLEN')
846 conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
847 'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
848 msg="Checking whether pututline returns pointer")
849 if conf.env.with_utmp:
850 conf.DEFINE('WITH_UTMP', 1)
852 if Options.options.with_avahi:
853 conf.env.with_avahi = True
854 if not conf.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf.env.with_avahi = False
855 if not conf.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf.env.with_avahi = False
856 if not conf.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf.env.with_avahi = False
857 if conf.env.with_avahi:
858 conf.DEFINE('WITH_AVAHI_SUPPORT', 1)
860 conf.SET_TARGET_TYPE('avahi-common', 'EMPTY')
861 conf.SET_TARGET_TYPE('avahi-client', 'EMPTY')
863 if Options.options.with_iconv:
864 conf.env.with_iconv = True
865 if not conf.CHECK_FUNCS_IN('iconv_open', 'iconv', headers='iconv.h'):
866 conf.env.with_iconv = False
867 if conf.env.with_iconv:
868 conf.DEFINE('HAVE_ICONV', 1)
870 if Options.options.with_pam:
872 conf.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
873 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
874 Logs.warn("--with-pam=yes but pam_appl.h not found")
876 conf.CHECK_FUNCS_IN('pam_get_data', 'pam')
877 conf.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
878 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
879 Logs.warn("--with-pam=yes but pam_modules.h not found")
881 conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
882 conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
883 conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
885 #if defined(HAVE_SECURITY_PAM_APPL_H)
886 #include <security/pam_appl.h>
887 #elif defined(HAVE_PAM_PAM_APPL_H)
888 #include <pam/pam_appl.h>
890 pam_set_item(0, PAM_RHOST, 0);
894 msg="Checking whether PAM_RHOST is available");
896 #if defined(HAVE_SECURITY_PAM_APPL_H)
897 #include <security/pam_appl.h>
898 #elif defined(HAVE_PAM_PAM_APPL_H)
899 #include <pam/pam_appl.h>
901 pam_set_item(0, PAM_TTY, 0);
905 msg="Checking whether PAM_TTY is available");
907 #if (!defined(LINUX))
909 #define PAM_EXTERN extern
910 #if defined(HAVE_SECURITY_PAM_APPL_H)
911 #include <security/pam_appl.h>
912 #elif defined(HAVE_PAM_PAM_APPL_H)
913 #include <pam/pam_appl.h>
918 #if defined(HAVE_SECURITY_PAM_MODULES_H)
919 #include <security/pam_modules.h>
920 #elif defined(HAVE_PAM_PAM_MODULES_H)
921 #include <pam/pam_modules.h>
924 #if defined(HAVE_SECURITY__PAM_MACROS_H)
925 #include <security/_pam_macros.h>
926 #elif defined(HAVE_PAM__PAM_MACROS_H)
927 #include <pam/_pam_macros.h>
930 #ifdef HAVE_SECURITY_PAM_EXT_H
931 #include <security/pam_ext.h>
934 int i; i = PAM_RADIO_TYPE;
936 'HAVE_PAM_RADIO_TYPE',
938 msg="Checking whether PAM_RADIO_TYPE is available");
940 conf.DEFINE('WITH_PAM', 1)
941 conf.DEFINE('WITH_PAM_MODULES', 1)
945 seteuid = conf.CHECK_CODE('''
946 #define AUTOCONF_TEST 1
947 #define USE_SETREUID 1
948 #include "./lib/util_sec.c"
953 msg="Checking whether setreuid is available")
955 seteuid = conf.CHECK_CODE('''
956 #define AUTOCONF_TEST 1
957 #define USE_SETRESUID 1
958 #include "./lib/util_sec.c"
963 msg="Checking whether setresuid is available")
965 seteuid = conf.CHECK_CODE('''
966 #define AUTOCONF_TEST 1
967 #define USE_SETEUID 1
968 #include "./lib/util_sec.c"
973 msg="Checking whether seteuid is available")
975 seteuid = conf.CHECK_CODE('''
976 #define AUTOCONF_TEST 1
977 #define USE_SETUIDX 1
978 #include "./lib/util_sec.c"
984 msg="Checking whether setuidx is available")
985 if Options.options.with_dnsupdate:
986 conf.CHECK_HEADERS('uuid/uuid.h')
987 conf.CHECK_FUNCS_IN('uuid_generate', 'uuid')
988 if not conf.CONFIG_SET('HAVE_UUID_UUID_H') and not conf.CONFIG_SET('HAVE_UUID_GENERATE'):
989 Logs.warn("--with-dnsupdate=yes but uuid support not sufficient")
990 elif not conf.CONFIG_SET('HAVE_KRB5'):
991 Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
993 conf.DEFINE('WITH_DNS_UPDATES', 1)
995 conf.SET_TARGET_TYPE('uuid', 'EMPTY')
996 conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
997 if Options.options.developer:
998 if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
999 conf.DEFINE('VALGRIND', '1')
1001 if conf.CHECK_CODE('''
1002 #include <bits/sockaddr.h>
1003 #include <linux/netlink.h>
1005 'HAVE_LINUX_NETLINK_H',
1006 msg="Checking whether Linux netlink is available"):
1008 #include <bits/sockaddr.h>
1009 #include <linux/netlink.h>
1010 #include <linux/rtnetlink.h>
1012 'HAVE_LINUX_RTNETLINK_H',
1013 msg='Checking whether Linux rtnetlink is available')
1014 if conf.CHECK_TYPE('struct dirent64', headers='sys/types.h dirent.h') and conf.CONFIG_SET('HAVE_READDIR64'):
1015 conf.DEFINE('HAVE_STRUCT_DIRENT64', '1')
1017 conf.undefine('HAVE_STRUCT_DIRENT64')
1020 #include "../tests/fcntl_lock.c"
1025 msg='Checking whether fcntl locking is available')
1028 #include "../tests/fcntl_lock64.c"
1030 'HAVE_BROKEN_FCNTL64_LOCKS',
1033 msg='Checking whether fcntl64 locks are broken')
1035 if not conf.CONFIG_SET('HAVE_BROKEN_FCNTL64_LOCKS'):
1037 #if defined(HAVE_UNISTD_H)
1047 #ifdef HAVE_SYS_FCNTL_H
1048 #include <sys/fcntl.h>
1050 main() { struct flock64 fl64;
1051 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1058 'HAVE_STRUCT_FLOCK64',
1061 msg="Checking whether the flock64 struct is available")
1063 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1064 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1065 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1066 define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1067 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1068 define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1069 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1070 define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1071 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1072 define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1073 if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1074 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1075 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1076 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1077 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1078 conf.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1080 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1081 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1082 define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1083 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1084 define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1085 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1086 define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1089 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1091 'HAVE_POSIX_FADVISE',
1092 msg='Checking whether posix_fadvise is available',
1093 headers='unistd.h fcntl.h')
1095 for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1098 return sysconf(%s) == -1 ? 1 : 0;
1101 msg='Checking whether sysconf(%s) is available' % v)
1103 conf.CHECK_DECLS('__NR_inotify_init', reverse=True, headers='asm/unistd.h')
1106 #include <sys/syscall.h>
1108 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1110 'HAVE_DARWIN_INITGROUPS',
1111 msg='Checking whether to use the Darwin-specific initgroups system call')
1113 conf.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1115 headers='sys/types.h utime.h',
1116 msg='Checking whether struct utimbuf is available')
1118 if conf.CHECK_CODE('''struct sigevent s;''',
1119 'HAVE_STRUCT_SIGEVENT',
1120 headers='sys/types.h stdlib.h stddef.h signal.h',
1121 msg='Checking whether we have the struct sigevent'):
1122 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1123 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1124 headers='signal.h');
1125 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1126 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1127 headers='signal.h');
1129 if os.path.exists('/proc/sys/kernel/core_pattern'):
1130 conf.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
1132 if conf.CHECK_CODE('''
1136 if (sizeof(time_t) == 8) {
1137 time_t max_time = 0x7fffffffffffffffll;
1138 tm = gmtime(&max_time);
1139 /* This should fail with 32-bit tm_year. */
1141 /* Max time_t that works with 32-bit int tm_year in struct tm. */
1142 max_time = 67768036191676799ll;
1143 tm = gmtime(&max_time);
1154 msg="Checking for the maximum value of the 'time_t' type"):
1155 conf.DEFINE('TIME_T_MAX', '67768036191676799ll')
1158 #if defined(HAVE_UNISTD_H)
1161 #include <sys/types.h>
1162 main() { dev_t dev = makedev(1,2); return 0; }
1166 msg='Checking whether the macro for makedev is available')
1173 void exit_on_core(int ignored) {
1179 signal(SIGSEGV, exit_on_core);
1180 newpath = realpath("/tmp", NULL);
1181 exit((newpath != NULL) ? 0 : 1);
1184 'REALPATH_TAKES_NULL',
1187 msg='Checking whether the realpath function allows a NULL argument')
1189 conf.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1190 'HAVE_FTRUNCATE_EXTEND',
1191 msg='Checking for ftruncate extend',
1194 if os.getenv('RUN_FROM_BUILD_FARM'):
1195 Logs.info("enabling buildfarm hacks")
1196 conf.DEFINE('ENABLE_BUILD_FARM_HACKS', '1')
1198 if Options.options.with_sendfile_support:
1199 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):
1204 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
1207 headers='sys/sendfile',
1208 msg='Checking for linux sendfile64 support')
1213 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1216 headers='sys/sendfile',
1217 msg='Checking for linux sendfile support')
1219 # Try and cope with broken Linux sendfile....
1220 conf.CHECK_CODE('''#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
1221 #undef _FILE_OFFSET_BITS
1223 #include <sys/sendfile.h>
1227 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1229 '_HAVE_BROKEN_LINUX_SENDFILE',
1230 msg='Checking for broken linux sendfile support')
1231 if conf.CONFIG_SET('_HAVE_SENDFILE64'):
1232 conf.DEFINE('HAVE_SENDFILE64', '1')
1233 conf.DEFINE('LINUX_SENDFILE_API', '1')
1234 conf.DEFINE('WITH_SENDFILE', '1')
1235 elif conf.CONFIG_SET('_HAVE_SENDFILE'):
1236 conf.DEFINE('HAVE_SENDFILE', '1')
1237 conf.DEFINE('LINUX_SENDFILE_API', '1')
1238 conf.DEFINE('WITH_SENDFILE', '1')
1239 elif conf.CONFIG_SET('_HAVE_BROKEN_LINUX_SENDFILE'):
1240 conf.DEFINE('LINUX_BROKEN_SENDFILE_API', '1')
1241 conf.DEFINE('WITH_SENDFILE', '1')
1242 elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
1244 #include <sys/types.h>
1246 #include <sys/socket.h>
1247 #include <sys/uio.h>
1248 int fromfd, tofd, ret, total=0;
1249 off_t offset, nwritten;
1252 hdr.headers = &hdtrl;
1254 hdr.trailers = NULL;
1256 hdtrl.iov_base = NULL;
1258 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1261 msg='Checking for freebsd sendfile support')
1262 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1263 conf.DEFINE('HAVE_SENDFILE', '1')
1264 conf.DEFINE('FREEBSD_SENDFILE_API', '1')
1265 conf.DEFINE('WITH_SENDFILE', '1')
1266 elif (host_os.rfind('hpux') > -1):
1268 #include <sys/socket.h>
1269 #include <sys/uio.h>
1272 struct iovec hdtrl[2];
1275 hdtrl[0].iov_base = 0;
1276 hdtrl[0].iov_len = 0;
1277 nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
1280 msg='Checking for hpux sendfile64 support')
1282 #include <sys/socket.h>
1283 #include <sys/uio.h>
1286 struct iovec hdtrl[2];
1289 hdtrl[0].iov_base = 0;
1290 hdtrl[0].iov_len = 0;
1291 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1294 msg='Checking for hpux sendfile support')
1295 if conf.CONFIG_SET('_HAVE_SENDFILE64'):
1296 conf.DEFINE('HAVE_SENDFILE64', '1')
1297 conf.DEFINE('HPUX_SENDFILE_API', '1')
1298 conf.DEFINE('WITH_SENDFILE', '1')
1299 elif conf.CONFIG_SET('_HAVE_SENDFILE'):
1300 conf.DEFINE('HAVE_SENDFILE', '1')
1301 conf.DEFINE('HPUX_SENDFILE_API', '1')
1302 conf.DEFINE('WITH_SENDFILE', '1')
1303 elif (host_os.rfind('solaris') > -1):
1304 conf.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1306 #include <sys/sendfile.h>
1309 struct sendfilevec vec[2];
1313 vec[0].sfv_fd = SFV_FD_SELF;
1314 vec[0].sfv_flag = 0;
1318 vec[1].sfv_flag = 0;
1321 nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
1323 '_HAVE_SENDFILEV64',
1324 msg='Checking for solaris sendfilev64 support')
1326 #include <sys/sendfile.h>,
1329 struct sendfilevec vec[2];
1333 vec[0].sfv_fd = SFV_FD_SELF;
1334 vec[0].sfv_flag = 0;
1338 vec[1].sfv_flag = 0;
1341 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1344 msg='Checking for solaris sendfilev support')
1345 if conf.CONFIG_SET('_HAVE_SENDFILEV64'):
1346 conf.DEFINE('HAVE_SENDFILEV64', '1')
1347 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1348 conf.DEFINE('WITH_SENDFILE', '1')
1349 elif conf.CONFIG_SET('_HAVE_SENDFILEV'):
1350 conf.DEFINE('HAVE_SENDFILEV', '1')
1351 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1352 conf.DEFINE('WITH_SENDFILE', '1')
1353 elif (host_os.rfind('aix') > -1):
1355 #include <sys/socket.h>
1358 struct sf_parms hdtrl;
1361 hdtrl.header_data = 0;
1362 hdtrl.header_length = 0;
1363 hdtrl.file_descriptor = fromfd;
1364 hdtrl.file_offset = 0;
1365 hdtrl.file_bytes = 0;
1366 hdtrl.trailer_data = 0;
1367 hdtrl.trailer_length = 0;
1368 nwritten = send_file(&tofd, &hdtrl, 0);
1371 msg='Checking for AIX send_file support')
1372 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1373 conf.DEFINE('HAVE_SENDFILE', '1')
1374 conf.DEFINE('AIX_SENDFILE_API', '1')
1375 conf.DEFINE('WITH_SENDFILE', '1')
1377 # Check for getcwd allowing a NULL arg.
1381 char *s = getcwd(NULL,0);
1382 exit(s != NULL ? 0 : 1);
1383 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
1384 msg="getcwd takes a NULL argument")
1387 # UnixWare 7.x has its getspnam in -lgen
1388 conf.CHECK_FUNCS_IN('getspnam', 'gen')
1389 conf.CHECK_FUNCS_IN('getspnam', 'security')
1390 conf.CHECK_FUNCS_IN('getspnam', 'sec')
1392 if Options.options.with_quotas:
1393 # For quotas on Veritas VxFS filesystems
1394 conf.CHECK_HEADERS('sys/fs/vx_quota.h')
1395 # For quotas on Linux XFS filesystems
1396 conf.CHECK_HEADERS('linux/dqblk_xfs.h')
1397 # For sys/quota.h and linux/quota.h
1398 conf.CHECK_HEADERS('sys/quota.h')
1402 # checking for clustering extensions (CTDB)
1404 if not Options.options.with_cluster_support:
1405 have_cluster_support = False
1409 if Options.options.ctdb_dir:
1410 conf.ADD_EXTRA_INCLUDES(Options.options.ctdb_dir + '/include')
1412 srcdir = os.path.realpath(conf.srcdir)
1413 if 'EXTRA_INCLUDES' in conf.env:
1414 includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/')
1418 have_cluster_support = True
1423 #include "replace.h"
1424 #include "system/wait.h"
1425 #include "system/network.h"
1426 #define private #error __USED_RESERVED_WORD_private__
1439 msg='Checking for header ctdb.h')
1441 if not conf.CONFIG_SET('HAVE_CTDB_H'):
1442 have_cluster_support = False
1443 ctdb_broken = "ctdb.h is required for cluster support"
1445 if have_cluster_support:
1448 #include "replace.h"
1449 #include "system/wait.h"
1450 #include "system/network.h"
1451 #define private #error __USED_RESERVED_WORD_private__
1455 #include <ctdb_private.h>
1462 'HAVE_CTDB_PRIVATE_H',
1465 msg='Checking for header ctdb_private.h')
1467 if not conf.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
1468 have_cluster_support = False
1469 ctdb_broken = "ctdb_private.h is required for cluster support"
1471 if have_cluster_support:
1474 #include "replace.h"
1475 #include "system/wait.h"
1476 #include "system/network.h"
1480 #include <ctdb_private.h>
1484 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1488 'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
1491 msg='Checking for transaction support (TRANS3_COMMIT control)')
1493 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
1494 have_cluster_support = False
1495 ctdb_broken = "ctdb transaction support missing or too old"
1497 if have_cluster_support:
1500 #include "replace.h"
1501 #include "system/wait.h"
1502 #include "system/network.h"
1506 #include <ctdb_private.h>
1510 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1514 'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
1517 msg='Checking for SCHEDULE_FOR_DELETION control')
1519 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
1520 if not Options.options.enable_old_ctdb:
1521 have_cluster_support = False
1522 ctdb_broken = "SCHEDULE_FOR_DELETION control missing"
1524 Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1526 if have_cluster_support:
1529 #include "replace.h"
1530 #include "system/wait.h"
1531 #include "system/network.h"
1535 #include <ctdb_private.h>
1539 struct ctdb_control_tcp _x;
1543 'HAVE_STRUCT_CTDB_CONTROL_TCP',
1546 msg='Checking for ctdb ipv4 support')
1548 if not conf.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
1549 have_cluster_support = False
1550 ctdb_broken = "missing struct ctdb_control_tcp"
1552 if have_cluster_support:
1555 #include "replace.h"
1556 #include "system/wait.h"
1557 #include "system/network.h"
1561 #include <ctdb_private.h>
1565 struct ctdb_control_tcp_addr _x;
1569 'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
1572 msg='Checking for ctdb ipv6 support')
1574 if have_cluster_support:
1577 #include "replace.h"
1578 #include "system/wait.h"
1579 #include "system/network.h"
1583 #include <ctdb_private.h>
1587 int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1591 'HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL',
1594 msg='Checking for CHECK_SRVIDS control')
1596 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL'):
1597 if not Options.options.enable_old_ctdb:
1598 have_cluster_support = False
1599 ctdb_broken = "CHECK_SRVIDS control missing"
1601 Logs.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1603 if have_cluster_support:
1604 Logs.info("building with cluster support")
1605 conf.DEFINE('CLUSTER_SUPPORT', 1);
1607 if not Options.options.with_cluster_support:
1608 Logs.info("building without cluster support")
1610 Logs.warn("building without cluster support: " + ctdb_broken)
1611 conf.undefine('CLUSTER_SUPPORT')
1615 conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1616 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1619 msg='Checking whether we can compile with __attribute__((destructor))')
1621 conf.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1622 'SEEKDIR_RETURNS_VOID',
1623 headers='sys/types.h dirent.h',
1624 msg='Checking whether seekdir returns void')
1626 if Options.options.with_profiling_data:
1627 conf.DEFINE('WITH_PROFILE', 1);
1629 PTHREAD_CFLAGS='error'
1630 PTHREAD_LDFLAGS='error'
1632 if PTHREAD_LDFLAGS == 'error':
1633 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
1634 PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
1635 PTHREAD_LDFLAGS='-lpthread'
1636 if PTHREAD_LDFLAGS == 'error':
1637 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
1638 PTHREAD_CFLAGS='-D_THREAD_SAFE'
1639 PTHREAD_LDFLAGS='-lpthreads'
1640 if PTHREAD_LDFLAGS == 'error':
1641 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
1642 PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread'
1643 PTHREAD_LDFLAGS='-pthread'
1644 if PTHREAD_LDFLAGS == 'error':
1645 if conf.CHECK_FUNC('pthread_attr_init'):
1646 PTHREAD_CFLAGS='-D_REENTRANT'
1647 PTHREAD_LDFLAGS='-lpthread'
1648 # especially for HP-UX, where the CHECK_FUNC macro fails to test for
1649 # pthread_attr_init. On pthread_mutex_lock it works there...
1650 if PTHREAD_LDFLAGS == 'error':
1651 if conf.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
1652 PTHREAD_CFLAGS='-D_REENTRANT'
1653 PTHREAD_LDFLAGS='-lpthread'
1655 if PTHREAD_CFLAGS != 'error' and PTHREAD_LDFLAGS != 'error':
1656 conf.ADD_CFLAGS(PTHREAD_CFLAGS)
1657 conf.ADD_LDFLAGS(PTHREAD_LDFLAGS)
1658 conf.CHECK_HEADERS('pthread.h')
1659 conf.DEFINE('HAVE_PTHREAD', '1')
1661 if Options.options.with_pthreadpool:
1662 if conf.CONFIG_SET('HAVE_PTHREAD'):
1663 conf.DEFINE('WITH_PTHREADPOOL', '1')
1665 Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
1666 conf.undefine('WITH_PTHREADPOOL')
1668 if conf.CHECK_HEADERS('gpfs_gpl.h'):
1669 conf.DEFINE('HAVE_GPFS', '1')
1671 # Note that all charset 'modules' must actually be static, due to dependency loop issues
1672 # if we include the module loader in iconv
1674 default_static_modules=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1675 auth_sam auth_unix auth_winbind auth_wbc auth_server
1676 auth_domain auth_builtin vfs_default
1677 nss_info_template idmap_tdb idmap_passdb
1680 default_shared_modules=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1681 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1682 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1683 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1684 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1685 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1686 vfs_crossrename vfs_linux_xfs_sgid
1687 vfs_time_audit idmap_autorid''')
1689 if Options.options.developer:
1690 default_static_modules.extend(TO_LIST('pdb_ads auth_netlogond charset_weird'))
1691 default_shared_modules.extend(TO_LIST('perfcount_test'))
1692 default_shared_modules.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1693 default_shared_modules.extend(TO_LIST('auth_skel pdb_test'))
1695 default_static_modules.extend(TO_LIST('pdb_samba4 auth_samba4 vfs_dfs_samba4'))
1697 if Options.options.with_acl_support and conf.CONFIG_SET('HAVE_POSIX_ACLS'):
1698 default_static_modules.extend(TO_LIST('vfs_posixacl'))
1700 if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1701 default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
1703 if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
1704 default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1706 if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
1707 default_shared_modules.extend(TO_LIST('vfs_fileid'))
1709 if conf.CONFIG_SET('HAVE_AIO') and (conf.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
1710 default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
1712 if conf.CONFIG_SET('HAVE_AIO') and Options.options.with_pthreadpool:
1713 default_shared_modules.extend(TO_LIST('vfs_aio_pthread'))
1715 if conf.CONFIG_SET('HAVE_LDAP'):
1716 default_static_modules.extend(TO_LIST('pdb_ldap idmap_ldap'))
1718 if conf.CONFIG_SET('DARWINOS'):
1719 default_static_modules.extend(TO_LIST('charset_macosxfs'))
1721 if conf.CONFIG_SET('HAVE_GPFS'):
1722 default_shared_modules.extend(TO_LIST('vfs_gpfs vfs_gpfs_hsm_notify'))
1724 explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
1725 explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
1727 final_static_modules = default_static_modules
1728 final_shared_modules = default_shared_modules
1730 for m in explicit_static_modules:
1731 if m in final_shared_modules:
1732 final_shared_modules.remove(m)
1733 final_static_modules.append(m)
1734 for m in explicit_shared_modules:
1735 if m in final_static_modules:
1736 final_static_modules.remove(m)
1737 final_shared_modules.append(m)
1739 conf.env['static_modules'] = final_static_modules
1740 conf.env['shared_modules'] = final_shared_modules
1742 conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
1747 prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1748 conf.env['MODULE_PREFIXES'] = prefixes
1750 for m in final_static_modules:
1752 if not p in static_list:
1754 static_list[p].append(m)
1755 for m in final_shared_modules:
1757 if not p in shared_list:
1759 shared_list[p].append(m)
1762 static_env = "%s_STATIC" % p.upper()
1763 shared_env = "%s_SHARED" % p.upper()
1764 conf.env[static_env] = []
1765 conf.env[shared_env] = []
1766 if p in static_list:
1768 for entry in static_list[p]:
1769 decl_list += "extern NTSTATUS %s_init(void); " % entry
1770 conf.env[static_env].append('%s' % entry)
1771 decl_list = decl_list.rstrip()
1772 conf.DEFINE('static_decl_%s' % p, decl_list)
1773 conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
1775 conf.DEFINE('static_decl_%s' % p, '')
1776 conf.DEFINE('static_init_%s' % p, '{}')
1777 if p in shared_list:
1778 for entry in shared_list[p]:
1779 conf.DEFINE('%s_init' % entry, 'samba_init_module')
1780 conf.env[shared_env].append('%s' % entry)
1782 conf.SAMBA_CONFIG_H('include/config.h')
1785 "build 'tags' file using ctags"
1787 source_root = os.path.dirname(Utils.g_module.root_path)
1788 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1789 print("Running: %s" % cmd)