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('ldap')
32 opt
.SAMBA3_ADD_OPTION('cups', with_name
="enable", without_name
="disable")
33 opt
.SAMBA3_ADD_OPTION('iprint', with_name
="enable", without_name
="disable")
34 opt
.SAMBA3_ADD_OPTION('pam')
35 opt
.SAMBA3_ADD_OPTION('pam_smbpass')
36 opt
.SAMBA3_ADD_OPTION('quotas')
37 opt
.SAMBA3_ADD_OPTION('sys-quotas')
38 opt
.SAMBA3_ADD_OPTION('sendfile-support')
39 opt
.SAMBA3_ADD_OPTION('utmp')
40 opt
.SAMBA3_ADD_OPTION('pthreadpool', with_name
="enable", without_name
="disable")
41 opt
.SAMBA3_ADD_OPTION('avahi', with_name
="enable", without_name
="disable")
42 opt
.SAMBA3_ADD_OPTION('iconv')
43 opt
.SAMBA3_ADD_OPTION('acl-support')
44 opt
.SAMBA3_ADD_OPTION('dnsupdate')
45 opt
.SAMBA3_ADD_OPTION('syslog')
46 opt
.SAMBA3_ADD_OPTION('automount')
47 opt
.SAMBA3_ADD_OPTION('aio-support')
48 opt
.SAMBA3_ADD_OPTION('profiling-data', default
=False)
50 opt
.SAMBA3_ADD_OPTION('cluster-support')
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)
62 from samba_utils
import TO_LIST
64 if Options
.options
.developer
:
65 conf
.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
66 conf
.env
.developer
= True
68 if Options
.options
.with_swat
:
69 conf
.env
['build_swat'] = True
71 if sys
.platform
!= 'openbsd5':
72 conf
.ADD_LDFLAGS("-Wl,--export-dynamic", testflags
=True)
74 conf
.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
75 conf
.CHECK_HEADERS('linux/falloc.h')
77 conf
.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
78 conf
.CHECK_FUNCS('strtol strchr strupr chflags')
79 conf
.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
80 conf
.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
81 conf
.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
82 conf
.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
83 conf
.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf')
84 conf
.CHECK_FUNCS('atexit grantpt fallocate posix_fallocate')
85 conf
.CHECK_FUNCS('fseeko setluid')
86 conf
.CHECK_FUNCS('getpwnam', headers
='sys/types.h pwd.h')
87 conf
.CHECK_FUNCS('fdopendir')
88 conf
.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
89 conf
.CHECK_FUNCS('syslog vsyslog timegm setlocale')
90 conf
.CHECK_FUNCS_IN('nanosleep', 'rt')
91 conf
.CHECK_FUNCS('lutimes futimes utimensat futimens')
92 conf
.CHECK_FUNCS('mlock munlock mlockall munlockall')
93 conf
.CHECK_FUNCS('memalign posix_memalign hstrerror')
94 conf
.CHECK_FUNCS('shmget')
95 conf
.CHECK_FUNCS_IN('shm_open', 'rt', checklibc
=True)
96 conf
.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain bind_textdomain_codeset')
97 #FIXME: for some reason this one still fails
98 conf
.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
99 conf
.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
100 conf
.CHECK_DECLS('fdatasync', reverse
=True)
101 conf
.CHECK_DECLS('readahead', reverse
=True, headers
='fcntl.h')
103 if conf
.CONFIG_SET('HAVE_LONG_LONG'):
104 conf
.DEFINE('HAVE_LONGLONG', 1)
106 if conf
.CHECK_CODE('''
107 #if defined(HAVE_UNISTD_H)
110 long ret = splice(0,0,1,0,400,0);
114 conf
.CHECK_DECLS('splice', reverse
=True, headers
='fcntl.h')
116 # Check for inotify support
117 conf
.CHECK_HEADERS('sys/inotify.h')
118 if "HAVE_SYS_INOTIFY_H" in conf
.env
:
119 conf
.DEFINE('HAVE_INOTIFY', 1)
121 # Check for kernel change notify support
124 #define F_NOTIFY 1026
127 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
128 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain
=False, execute
=True,
129 headers
='fcntl.h signal.h',
130 msg
="Checking for kernel change notify support")
132 # Check for Linux kernel oplocks
134 #include <sys/types.h>
138 #define F_NOTIFY 1026
141 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
142 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain
=False, execute
=True,
143 msg
="Checking for Linux kernel oplocks")
145 # Check for IRIX kernel oplock types
146 conf
.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
147 'HAVE_KERNEL_OPLOCKS_IRIX', headers
='fcntl.h',
148 msg
="Checking for IRIX kernel oplock types")
150 # Check for kernel share modes
152 #include <sys/types.h>
155 #include <sys/file.h>
161 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
162 }''', 'HAVE_KERNEL_SHARE_MODES', addmain
=False, execute
=True,
163 msg
="Checking for krenel share modes")
165 # Check for various members of the stat structure
166 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define
='HAVE_STAT_ST_BLOCKS',
167 headers
='sys/stat.h')
168 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define
='HAVE_STAT_ST_BLKSIZE',
169 headers
='sys/stat.h')
170 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define
='HAVE_STAT_ST_FLAGS',
171 headers
='sys/types.h sys/stat.h unistd.h')
173 if "HAVE_BLKCNT_T" in conf
.env
:
175 return sizeof(blkcnt_t) == 4 ? 0 : 1''',
176 'SIZEOF_BLKCNT_T_4', execute
=True,
177 headers
='replace.h sys/types.h sys/stat.h unistd.h',
178 msg
="Checking whether blkcnt_t is 32 bit")
180 if "HAVE_BLKCNT_T" in conf
.env
:
182 return sizeof(blkcnt_t) == 8 ? 0 : 1''',
183 'SIZEOF_BLKCNT_T_8', execute
=True,
184 headers
='replace.h sys/types.h sys/stat.h unistd.h',
185 msg
="Checking whether blkcnt_t is 64 bit")
187 # Check for POSIX capability support
188 conf
.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers
='sys/capability.h')
190 if "HAVE_SYS_CAPABILITY_H" in conf
.env
:
194 if (!(cap = cap_get_proc())) exit(1);
196 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
197 cap_set_proc(cap);''',
198 'HAVE_POSIX_CAPABILITIES', execute
=True, lib
="cap",
199 headers
='sys/capability.h',
200 msg
="Checking whether POSIX capabilities are available")
202 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
203 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
205 if conf
.CONFIG_SET("HAVE_RPC_RPC_H"):
206 conf
.CHECK_TYPE('int16', headers
='rpc/rpc.h',
207 define
='HAVE_INT16_FROM_RPC_RPC_H',
208 msg
="Checking for int16 typedef included by rpc/rpc.h")
209 conf
.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
210 headers
='sys/types.h rpc/rpc.h',
211 msg
="Checking for uint16 typedef included by rpc/rpc.h")
212 conf
.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
213 headers
='sys/types.h rpc/rpc.h',
214 msg
="Checking for int32 typedef included by rpc/rpc.h")
215 conf
.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
216 headers
='sys/types.h rpc/rpc.h',
217 msg
="Checking for uint32 typedef included by rpc/rpc.h")
218 conf
.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
219 headers
='sys/types.h sys/acl.h rpcsvc/nis.h',
220 msg
="Checking for broken nisplus include files")
222 # Check if the compiler will optimize out functions
225 this_function_does_not_exist();
228 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
229 msg
="Checking if the compiler will optimize out functions")
231 # Check if the compiler supports the LL suffix on long long integers
233 conf
.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
235 msg
="Checking for LL suffix on long long integers")
239 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
240 __closedir crypt16 devnm dgettext dirfd
241 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
243 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
245 fsetxattr _fstat __fstat fsync
246 futimens futimes __fxstat getauthuid
247 getcwd _getcwd __getcwd getdents __getdents getdirentries
248 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
249 getpwanam getpwent_r getrlimit gettext
250 glob grantpt hstrerror initgroups innetgr
251 llseek _llseek __llseek _lseek __lseek
252 _lstat __lstat lutimes
253 __lxstat memalign mknod mlock mlockall munlock munlockall
254 _open __open _opendir __opendir
255 pathconf poll posix_fallocate
256 posix_memalign prctl pread _pread __pread
257 pwrite _pwrite __pwrite
258 rdchk _read __read _readdir __readdir
260 select setenv setgidx setgroups setlocale setluid
261 setmntent setpgid setpriv setsid setuidx
262 shmget shm_open sigaction sigblock sigprocmask sigset
264 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
265 __sys_llseek syslog _telldir __telldir textdomain timegm
266 utimensat vsyslog _write __write __xstat
269 conf
.CHECK_SAMBA3_CHARSET() # see build/charset.py
271 # FIXME: these should be tests for features, but the old build system just
273 host_os
= sys
.platform
274 Logs
.info("building on %s" % host_os
)
276 # Python doesn't have case switches... :/
277 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
278 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
280 conf
.SET_TARGET_TYPE('sunacl', 'EMPTY')
281 if (host_os
.rfind('linux') > -1) or (host_os
.rfind('gnu') > -1) or (host_os
.rfind('qnx') > -1):
282 if host_os
.rfind('linux') > -1:
283 conf
.DEFINE('LINUX', '1')
284 elif host_os
.rfind('qnx') > -1:
285 conf
.DEFINE('QNX', '1')
286 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
287 elif (host_os
.rfind('darwin') > -1):
288 conf
.DEFINE('DARWINOS', 1)
289 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
290 conf
.ADD_CFLAGS('-fno-common')
291 elif (host_os
.rfind('freebsd') > -1):
292 if conf
.CHECK_HEADERS('sunacl.h'):
293 conf
.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
294 conf
.CHECK_FUNCS_IN('acl', 'sunacl')
295 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
296 elif (host_os
.rfind('netbsd') > -1):
297 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
298 elif (host_os
.rfind('openbsd') > -1):
299 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
300 elif (host_os
.rfind('sunos') > -1):
301 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
302 # FIXME: Add more checks here.
304 Logs
.warn("Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os
)
306 #FIXME: add more checks
307 if Options
.options
.with_acl_support
:
308 if (host_os
.rfind('darwin') > -1):
309 conf
.DEFINE('HAVE_NO_ACLS', 1)
310 conf
.SET_TARGET_TYPE('acl', 'EMPTY')
312 conf
.CHECK_FUNCS_IN('acl_get_file', 'acl')
313 if conf
.CHECK_CODE('''
316 acl_entry_t *entry_p;
317 return acl_get_entry(acl, entry_id, entry_p);
320 headers
='sys/types.h sys/acl.h', link
=False,
321 msg
="Checking for POSIX ACL support") :
323 acl_permset_t permset_d;
325 return acl_get_perm_np(permset_d, perm);
327 'HAVE_ACL_GET_PERM_NP',
328 headers
='sys/types.h sys/acl.h', link
=True,
329 msg
="Checking whether acl_get_perm_np() is available")
331 conf
.DEFINE('HAVE_NO_ACLS', 1)
332 conf
.SET_TARGET_TYPE('acl', 'EMPTY')
334 if conf
.CHECK_FUNCS('dirfd'):
335 conf
.DEFINE('HAVE_DIRFD_DECL', 1)
337 conf
.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
338 'HAVE_STATFS_F_FSID',
339 msg
="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
340 headers
='sys/types.h sys/statfs.h',
343 if conf
.CONFIG_SET('HAVE_FALLOCATE'):
345 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
346 'HAVE_LINUX_FALLOCATE',
347 msg
="Checking whether the Linux 'fallocate' function is available",
348 headers
='unistd.h sys/types.h fcntl.h linux/falloc.h')
350 ssize_t err = readahead(0,0,0x80000);''',
351 'HAVE_LINUX_READAHEAD',
352 msg
="Checking whether Linux readahead is available",
353 headers
='unistd.h fcntl.h')
354 conf
.CHECK_DECLS('readahead', headers
='fcntl.h', always
=True)
356 if Options
.options
.with_aio_support
:
357 conf
.CHECK_FUNCS_IN('aio_read', 'aio')
358 conf
.CHECK_FUNCS_IN('aio_read', 'rt')
359 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);',
361 msg
='Checking for asynchronous io support',
362 headers
='sys/types.h aio.h',
364 if conf
.CONFIG_SET('HAVE_AIO'):
365 conf
.DEFINE('WITH_AIO', '1')
366 if conf
.CONFIG_SET('HAVE_AIO'):
367 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg
='Checking for aio_read', headers
='aio.h', lib
='aio rt')
368 conf
.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg
='Checking for aio_write', headers
='aio.h', lib
='aio rt')
369 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')
370 conf
.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg
='Checking for aio_return', headers
='aio.h', lib
='aio rt')
371 conf
.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg
='Checking for aio_error', headers
='aio.h', lib
='aio rt')
372 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')
373 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')
374 if host_os
.rfind('linux') > -1:
375 conf
.CHECK_FUNCS_IN('io_submit', 'aio')
377 struct io_event ioev;
383 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
384 io_queue_init(128,&ctx);
385 io_prep_pwrite(ioc, 1, buf, 1, 0);
386 io_prep_pread(ioc, 1, buf, 1, 0);
387 io_set_eventfd(ioc, fd);
388 io_set_callback(ioc, (io_callback_t)(0));
389 io_submit(ctx, 1, &ioc);
390 io_getevents(ctx, 1, 1, &ioev, &ts);
392 'HAVE_LINUX_KERNEL_AIO',
393 msg
='Checking for linux kernel asynchronous io support',
394 headers
='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
397 if not conf
.CONFIG_SET('HAVE_AIO'):
398 conf
.DEFINE('HAVE_NO_AIO', '1')
400 conf
.DEFINE('HAVE_NO_AIO', '1')
406 char control[CMSG_SPACE(sizeof(int))];
408 msg.msg_control = control_un.control;
409 msg.msg_controllen = sizeof(control_un.control);
411 'HAVE_MSGHDR_MSG_CONTROL',
412 msg
='Checking if we can use msg_control for passing file descriptors',
413 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
417 msg.msg_acctrights = (caddr_t) &fd;
418 msg.msg_acctrightslen = sizeof(fd);
420 'HAVE_MSGHDR_MSG_ACCTRIGHTS',
421 msg
='Checking if we can use msg_acctrights for passing file descriptors',
422 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
424 if Options
.options
.with_winbind
:
425 conf
.env
.build_winbind
= True
426 conf
.DEFINE('WITH_WINBIND', '1')
428 conf
.find_program('awk', var
='AWK')
429 conf
.find_program('perl', var
='PERL')
431 conf
.CHECK_HEADERS('asm/types.h')
433 conf
.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
434 headers
='unistd.h sys/types.h',
435 msg
="Checking for major macro")
437 conf
.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
438 headers
='unistd.h sys/types.h',
439 msg
="Checking for minor macro")
441 conf
.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
442 headers
='unistd.h sys/types.h dirent.h',
443 define
='HAVE_DIRENT_D_OFF')
445 conf
.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
446 if conf
.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
447 netgrent_cflags
= '-Werror-implicit-function-declaration'
450 conf
.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
451 msg
="Checking for setnetgrent prototype",
452 headers
='netdb.h netgroup.h',
453 cflags
=netgrent_cflags
)
454 conf
.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
455 msg
="Checking for getnetgrent prototype",
456 headers
='netdb.h netgroup.h',
457 cflags
=netgrent_cflags
)
458 conf
.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
459 msg
="Checking for endnetgrent prototype",
460 headers
='netdb.h netgroup.h',
461 cflags
=netgrent_cflags
)
465 if Options
.options
.with_cups
:
466 conf
.find_program('cups-config', var
='CUPS_CONFIG')
467 if conf
.env
.CUPS_CONFIG
:
468 # we would normally use --libs here, but cups-config incorrectly adds
469 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
470 # of an in-tree heimdal kerberos
471 conf
.check_cfg(path
=conf
.env
.CUPS_CONFIG
, args
="--cflags --ldflags",
472 package
="", uselib_store
="CUPS")
473 conf
.CHECK_HEADERS('cups/cups.h cups/language.h', lib
='cups')
474 conf
.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
475 if conf
.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf
.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
476 conf
.DEFINE('HAVE_CUPS', '1')
478 conf
.undefine('HAVE_CUPS')
479 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
481 # define an empty subsystem for cups, to allow it to be used as an empty dependency
482 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
484 if Options
.options
.with_iprint
:
485 if conf
.CONFIG_SET('HAVE_CUPS'):
486 conf
.DEFINE('HAVE_IPRINT', '1')
488 Logs
.warn("--enable-iprint=yes but cups support not sufficient")
489 if Options
.options
.with_syslog
:
490 conf
.DEFINE('WITH_SYSLOG', '1')
491 if Options
.options
.with_automount
:
492 conf
.DEFINE('WITH_AUTOMOUNT', '1')
495 if Options
.options
.with_ldap
:
496 conf
.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
497 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
498 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
499 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
501 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
503 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
504 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
506 conf
.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
507 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
509 # Check if ldap_set_rebind_proc() takes three arguments
510 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
511 'LDAP_SET_REBIND_PROC_ARGS',
512 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
513 headers
='ldap.h lber.h', link
=False):
514 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
516 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
518 # last but not least, if ldap_init() exists, we want to use ldap
519 if conf
.CONFIG_SET('HAVE_LDAP_INIT'):
520 conf
.DEFINE('HAVE_LDAP', '1')
521 conf
.DEFINE('LDAP_DEPRECATED', '1')
522 conf
.env
['HAVE_LDAP'] = '1'
523 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
524 # SASL wrapping hooks
525 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
526 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
527 conf
.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
529 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
530 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
532 if Options
.options
.with_ads
:
534 if not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
535 not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
536 Logs
.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
538 if not conf
.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
539 Logs
.warn("krb5_mk_req_extended not found in -lkrb5")
541 if not conf
.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
542 Logs
.warn("krb5_get_host_realm not found in -lkrb5")
544 if not conf
.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
545 Logs
.warn("krb5_free_host_realm not found in -lkrb5")
547 if not conf
.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
548 Logs
.warn("krb5_fwd_tgt_creds found in -lkrb5")
550 if not conf
.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
551 Logs
.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
553 if not conf
.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
554 Logs
.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
556 if not conf
.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
557 Logs
.warn("krb5_get_renewed_creds not found in -lkrb5")
559 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
560 Logs
.warn("krb5_principal_compare_any_realm not found in -lkrb5")
562 if not conf
.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
563 not conf
.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
564 Logs
.warn("krb5_c_string_to_key not found in -lkrb5")
566 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
567 not conf
.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
568 Logs
.warn("no CREATE_KEY_FUNCTIONS detected")
570 if not conf
.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
571 not conf
.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
572 Logs
.warn("no GET_ENCTYPES_FUNCTIONS detected")
574 if not conf
.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
575 not conf
.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
576 Logs
.warn("no KT_FREE_FUNCTION detected")
578 if not conf
.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
579 Logs
.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
582 # We don't actually use
583 # gsskrb5_extract_authz_data_from_sec_context, but it is a
584 # clue that this Heimdal, which does the PAC processing we
585 # need on the standard gss_inquire_sec_context_by_oid
586 if not conf
.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
587 not (conf
.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
588 conf
.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
589 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")
592 if not conf
.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
593 Logs
.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
597 conf
.DEFINE('WITH_ADS', '1')
598 conf
.DEFINE('HAVE_KRB5', '1')
599 if conf
.CONFIG_SET('HAVE_LDAP'):
600 conf
.env
['HAVE_ADS'] = '1'
602 Logs
.warn("krb5 libs don't have all features required for Active Directory support")
603 conf
.undefine('HAVE_KRB5_H')
604 conf
.undefine('HAVE_GSSAPI_H')
605 conf
.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
606 conf
.undefine('HAVE_GSSAPI_GSSAPI_H')
608 if Options
.options
.with_utmp
:
609 conf
.env
.with_utmp
= True
610 if not conf
.CHECK_HEADERS('utmp.h'): conf
.env
.with_utmp
= False
611 conf
.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
612 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers
='utmp.h',
613 define
='HAVE_UT_UT_NAME')
614 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers
='utmp.h',
615 define
='HAVE_UT_UT_USER')
616 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers
='utmp.h',
617 define
='HAVE_UT_UT_ID')
618 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers
='utmp.h',
619 define
='HAVE_UT_UT_HOST')
620 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers
='utmp.h',
621 define
='HAVE_UT_UT_TIME')
622 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers
='utmp.h',
623 define
='HAVE_UT_UT_TV')
624 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers
='utmp.h',
625 define
='HAVE_UT_UT_TYPE')
626 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers
='utmp.h',
627 define
='HAVE_UT_UT_PID')
628 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers
='utmp.h',
629 define
='HAVE_UT_UT_EXIT')
630 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers
='utmp.h',
631 define
='HAVE_UT_UT_ADDR_V6')
632 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers
='utmp.h',
633 define
='HAVE_UT_UT_ADDR')
634 conf
.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers
='utmpx.h',
635 define
='HAVE_UX_UT_SYSLEN')
636 conf
.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
637 'PUTUTLINE_RETURNS_UTMP', headers
='utmp.h',
638 msg
="Checking whether pututline returns pointer")
639 if conf
.env
.with_utmp
:
640 conf
.DEFINE('WITH_UTMP', 1)
642 if Options
.options
.with_avahi
:
643 conf
.env
.with_avahi
= True
644 if not conf
.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf
.env
.with_avahi
= False
645 if not conf
.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf
.env
.with_avahi
= False
646 if not conf
.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf
.env
.with_avahi
= False
647 if conf
.env
.with_avahi
:
648 conf
.DEFINE('WITH_AVAHI_SUPPORT', 1)
650 conf
.SET_TARGET_TYPE('avahi-common', 'EMPTY')
651 conf
.SET_TARGET_TYPE('avahi-client', 'EMPTY')
653 if Options
.options
.with_iconv
:
654 conf
.env
.with_iconv
= True
655 if not conf
.CHECK_FUNCS_IN('iconv_open', 'iconv', headers
='iconv.h'):
656 conf
.env
.with_iconv
= False
657 if conf
.env
.with_iconv
:
658 conf
.DEFINE('HAVE_ICONV', 1)
660 if Options
.options
.with_pam
:
662 conf
.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
663 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
664 Logs
.warn("--with-pam=yes but pam_appl.h not found")
666 conf
.CHECK_FUNCS_IN('pam_get_data', 'pam')
667 conf
.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
668 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
669 Logs
.warn("--with-pam=yes but pam_modules.h not found")
671 conf
.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
672 conf
.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
673 conf
.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
675 #if defined(HAVE_SECURITY_PAM_APPL_H)
676 #include <security/pam_appl.h>
677 #elif defined(HAVE_PAM_PAM_APPL_H)
678 #include <pam/pam_appl.h>
680 pam_set_item(0, PAM_RHOST, 0);
684 msg
="Checking whether PAM_RHOST is available");
686 #if defined(HAVE_SECURITY_PAM_APPL_H)
687 #include <security/pam_appl.h>
688 #elif defined(HAVE_PAM_PAM_APPL_H)
689 #include <pam/pam_appl.h>
691 pam_set_item(0, PAM_TTY, 0);
695 msg
="Checking whether PAM_TTY is available");
697 #if (!defined(LINUX))
699 #define PAM_EXTERN extern
700 #if defined(HAVE_SECURITY_PAM_APPL_H)
701 #include <security/pam_appl.h>
702 #elif defined(HAVE_PAM_PAM_APPL_H)
703 #include <pam/pam_appl.h>
708 #if defined(HAVE_SECURITY_PAM_MODULES_H)
709 #include <security/pam_modules.h>
710 #elif defined(HAVE_PAM_PAM_MODULES_H)
711 #include <pam/pam_modules.h>
714 #if defined(HAVE_SECURITY__PAM_MACROS_H)
715 #include <security/_pam_macros.h>
716 #elif defined(HAVE_PAM__PAM_MACROS_H)
717 #include <pam/_pam_macros.h>
720 #ifdef HAVE_SECURITY_PAM_EXT_H
721 #include <security/pam_ext.h>
724 int i; i = PAM_RADIO_TYPE;
726 'HAVE_PAM_RADIO_TYPE',
728 msg
="Checking whether PAM_RADIO_TYPE is available");
730 conf
.DEFINE('WITH_PAM', 1)
731 conf
.DEFINE('WITH_PAM_MODULES', 1)
735 seteuid
= conf
.CHECK_CODE('''
736 #define AUTOCONF_TEST 1
737 #define USE_SETREUID 1
738 #include "./lib/util_sec.c"
743 msg
="Checking whether setreuid is available")
745 seteuid
= conf
.CHECK_CODE('''
746 #define AUTOCONF_TEST 1
747 #define USE_SETRESUID 1
748 #include "./lib/util_sec.c"
753 msg
="Checking whether setresuid is available")
755 seteuid
= conf
.CHECK_CODE('''
756 #define AUTOCONF_TEST 1
757 #define USE_SETEUID 1
758 #include "./lib/util_sec.c"
763 msg
="Checking whether seteuid is available")
765 seteuid
= conf
.CHECK_CODE('''
766 #define AUTOCONF_TEST 1
767 #define USE_SETUIDX 1
768 #include "./lib/util_sec.c"
774 msg
="Checking whether setuidx is available")
775 if Options
.options
.with_dnsupdate
:
776 if not conf
.CONFIG_SET('HAVE_KRB5'):
777 Logs
.warn("--with-dnsupdate=yes but gssapi support not sufficient")
779 conf
.DEFINE('WITH_DNS_UPDATES', 1)
780 conf
.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
781 if Options
.options
.developer
:
782 if conf
.CONFIG_SET('HAVE_VALGRIND_H') or conf
.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
783 conf
.DEFINE('VALGRIND', '1')
785 if conf
.CHECK_CODE('''
786 #include <bits/sockaddr.h>
787 #include <linux/netlink.h>
789 'HAVE_LINUX_NETLINK_H',
790 msg
="Checking whether Linux netlink is available"):
793 #include <bits/sockaddr.h>
794 #include <linux/netlink.h>
795 #include <linux/rtnetlink.h>
797 'HAVE_LINUX_RTNETLINK_H',
798 msg
='Checking whether Linux rtnetlink is available')
801 #include "../tests/fcntl_lock.c"
806 msg
='Checking whether fcntl locking is available')
808 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
809 if not conf
.CHECK_CODE('''
810 #define _XOPEN_SOURCE 600
812 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
813 #error probably broken posix_fallocate
816 '_HAVE_UNBROKEN_POSIX_FALLOCATE',
817 msg
='for broken posix_fallocate'):
818 conf
.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
821 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
822 define
='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
823 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
824 define
='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
825 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
826 define
='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
827 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
828 define
='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
829 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
830 define
='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
831 if conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
832 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
833 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
834 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
835 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
836 conf
.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
838 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
839 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
840 define
='HAVE_STRUCT_STAT_ST_BIRTHTIME')
841 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
842 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
843 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
844 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
847 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
849 'HAVE_POSIX_FADVISE',
850 msg
='Checking whether posix_fadvise is available',
851 headers
='unistd.h fcntl.h')
853 for v
in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
856 return sysconf(%s) == -1 ? 1 : 0;
859 msg
='Checking whether sysconf(%s) is available' % v
)
862 #include <sys/syscall.h>
864 syscall(SYS_initgroups, 16, NULL, NULL, 0);
866 'HAVE_DARWIN_INITGROUPS',
867 msg
='Checking whether to use the Darwin-specific initgroups system call')
869 conf
.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
871 headers
='sys/types.h utime.h',
872 msg
='Checking whether struct utimbuf is available')
874 if conf
.CHECK_CODE('''struct sigevent s;''',
875 'HAVE_STRUCT_SIGEVENT',
876 headers
='sys/types.h stdlib.h stddef.h signal.h',
877 msg
='Checking whether we have the struct sigevent'):
878 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
879 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
881 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
882 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
885 if os
.path
.exists('/proc/sys/kernel/core_pattern'):
886 conf
.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
888 if conf
.CHECK_CODE('''
892 if (sizeof(time_t) == 8) {
893 time_t max_time = 0x7fffffffffffffffll;
894 tm = gmtime(&max_time);
895 /* This should fail with 32-bit tm_year. */
897 /* Max time_t that works with 32-bit int tm_year in struct tm. */
898 max_time = 67768036191676799ll;
899 tm = gmtime(&max_time);
910 msg
="Checking for the maximum value of the 'time_t' type"):
911 conf
.DEFINE('TIME_T_MAX', '67768036191676799ll')
914 #if defined(HAVE_UNISTD_H)
917 #include <sys/types.h>
918 main() { dev_t dev = makedev(1,2); return 0; }
922 msg
='Checking whether the macro for makedev is available')
929 void exit_on_core(int ignored) {
935 signal(SIGSEGV, exit_on_core);
936 newpath = realpath("/tmp", NULL);
937 exit((newpath != NULL) ? 0 : 1);
940 'REALPATH_TAKES_NULL',
943 msg
='Checking whether the realpath function allows a NULL argument')
945 conf
.CHECK_CODE('''#include "../tests/ftruncate.c"''',
946 'HAVE_FTRUNCATE_EXTEND',
947 msg
='Checking for ftruncate extend',
950 if os
.getenv('RUN_FROM_BUILD_FARM'):
951 Logs
.info("enabling buildfarm hacks")
952 conf
.DEFINE('ENABLE_BUILD_FARM_HACKS', '1')
954 if Options
.options
.with_sendfile_support
:
955 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):
960 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
963 headers
='sys/sendfile.h',
964 msg
='Checking for linux sendfile support')
966 # Try and cope with broken Linux sendfile....
967 conf
.CHECK_CODE('''#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
968 #undef _FILE_OFFSET_BITS
970 #include <sys/sendfile.h>
974 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
976 '_HAVE_BROKEN_LINUX_SENDFILE',
977 msg
='Checking for broken linux sendfile support')
978 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
979 conf
.DEFINE('HAVE_SENDFILE', '1')
980 conf
.DEFINE('LINUX_SENDFILE_API', '1')
981 conf
.DEFINE('WITH_SENDFILE', '1')
982 elif conf
.CONFIG_SET('_HAVE_BROKEN_LINUX_SENDFILE'):
983 conf
.DEFINE('LINUX_BROKEN_SENDFILE_API', '1')
984 conf
.DEFINE('WITH_SENDFILE', '1')
985 elif (host_os
.rfind('freebsd') > -1) or (host_os
.rfind('dragonfly') > -1):
987 #include <sys/types.h>
989 #include <sys/socket.h>
991 int fromfd, tofd, ret, total=0;
992 off_t offset, nwritten;
995 hdr.headers = &hdtrl;
999 hdtrl.iov_base = NULL;
1001 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1004 msg
='Checking for freebsd sendfile support')
1005 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1006 conf
.DEFINE('HAVE_SENDFILE', '1')
1007 conf
.DEFINE('FREEBSD_SENDFILE_API', '1')
1008 conf
.DEFINE('WITH_SENDFILE', '1')
1009 elif (host_os
.rfind('hpux') > -1):
1011 #include <sys/socket.h>
1012 #include <sys/uio.h>
1015 struct iovec hdtrl[2];
1018 hdtrl[0].iov_base = 0;
1019 hdtrl[0].iov_len = 0;
1020 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1023 msg
='Checking for hpux sendfile support')
1024 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1025 conf
.DEFINE('HAVE_SENDFILE', '1')
1026 conf
.DEFINE('HPUX_SENDFILE_API', '1')
1027 conf
.DEFINE('WITH_SENDFILE', '1')
1028 elif (host_os
.rfind('solaris') > -1):
1029 conf
.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1031 #include <sys/sendfile.h>,
1034 struct sendfilevec vec[2];
1038 vec[0].sfv_fd = SFV_FD_SELF;
1039 vec[0].sfv_flag = 0;
1043 vec[1].sfv_flag = 0;
1046 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1049 msg
='Checking for solaris sendfilev support')
1050 if conf
.CONFIG_SET('_HAVE_SENDFILEV'):
1051 conf
.DEFINE('HAVE_SENDFILEV', '1')
1052 conf
.DEFINE('SOLARIS_SENDFILE_API', '1')
1053 conf
.DEFINE('WITH_SENDFILE', '1')
1054 elif (host_os
.rfind('aix') > -1):
1056 #include <sys/socket.h>
1059 struct sf_parms hdtrl;
1061 hdtrl.header_data = 0;
1062 hdtrl.header_length = 0;
1063 hdtrl.file_descriptor = fromfd;
1064 hdtrl.file_offset = 0;
1065 hdtrl.file_bytes = 0;
1066 hdtrl.trailer_data = 0;
1067 hdtrl.trailer_length = 0;
1068 nwritten = send_file(&tofd, &hdtrl, 0);
1071 msg
='Checking for AIX send_file support')
1072 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1073 conf
.DEFINE('HAVE_SENDFILE', '1')
1074 conf
.DEFINE('AIX_SENDFILE_API', '1')
1075 conf
.DEFINE('WITH_SENDFILE', '1')
1077 # Check for getcwd allowing a NULL arg.
1081 char *s = getcwd(NULL,0);
1082 exit(s != NULL ? 0 : 1);
1083 }''', 'GETCWD_TAKES_NULL', addmain
=False, execute
=True,
1084 msg
="getcwd takes a NULL argument")
1087 # UnixWare 7.x has its getspnam in -lgen
1088 conf
.CHECK_FUNCS_IN('getspnam', 'gen')
1089 conf
.CHECK_FUNCS_IN('getspnam', 'security')
1090 conf
.CHECK_FUNCS_IN('getspnam', 'sec')
1092 if Options
.options
.with_quotas
:
1093 # For quotas on Veritas VxFS filesystems
1094 conf
.CHECK_HEADERS('sys/fs/vx_quota.h')
1095 # For quotas on Linux XFS filesystems
1096 conf
.CHECK_HEADERS('linux/dqblk_xfs.h')
1097 # For sys/quota.h and linux/quota.h
1098 conf
.CHECK_HEADERS('sys/quota.h')
1102 # checking for clustering extensions (CTDB)
1104 if not Options
.options
.with_cluster_support
:
1105 have_cluster_support
= False
1109 if Options
.options
.ctdb_dir
:
1110 conf
.ADD_EXTRA_INCLUDES(Options
.options
.ctdb_dir
+ '/include')
1112 srcdir
= os
.path
.realpath(conf
.srcdir
)
1113 if 'EXTRA_INCLUDES' in conf
.env
:
1114 includes
= ' '.join(conf
.env
['EXTRA_INCLUDES']).replace('#', srcdir
+ '/')
1118 have_cluster_support
= True
1123 #include "replace.h"
1124 #include "system/wait.h"
1125 #include "system/network.h"
1126 #define private #error __USED_RESERVED_WORD_private__
1139 msg
='Checking for header ctdb.h')
1141 if not conf
.CONFIG_SET('HAVE_CTDB_H'):
1142 have_cluster_support
= False
1143 ctdb_broken
= "ctdb.h is required for cluster support"
1145 if have_cluster_support
:
1148 #include "replace.h"
1149 #include "system/wait.h"
1150 #include "system/network.h"
1151 #define private #error __USED_RESERVED_WORD_private__
1155 #include <ctdb_private.h>
1162 'HAVE_CTDB_PRIVATE_H',
1165 msg
='Checking for header ctdb_private.h')
1167 if not conf
.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
1168 have_cluster_support
= False
1169 ctdb_broken
= "ctdb_private.h is required for cluster support"
1171 if have_cluster_support
:
1174 #include "replace.h"
1175 #include "system/wait.h"
1176 #include "system/network.h"
1180 #include <ctdb_private.h>
1184 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1188 'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
1191 msg
='Checking for transaction support (TRANS3_COMMIT control)')
1193 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
1194 have_cluster_support
= False
1195 ctdb_broken
= "ctdb transaction support missing or too old"
1197 if have_cluster_support
:
1200 #include "replace.h"
1201 #include "system/wait.h"
1202 #include "system/network.h"
1206 #include <ctdb_private.h>
1210 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1214 'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
1217 msg
='Checking for SCHEDULE_FOR_DELETION control')
1219 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
1220 if not Options
.options
.enable_old_ctdb
:
1221 have_cluster_support
= False
1222 ctdb_broken
= "SCHEDULE_FOR_DELETION control missing"
1224 Logs
.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1226 if have_cluster_support
:
1229 #include "replace.h"
1230 #include "system/wait.h"
1231 #include "system/network.h"
1235 #include <ctdb_private.h>
1239 struct ctdb_control_tcp _x;
1243 'HAVE_STRUCT_CTDB_CONTROL_TCP',
1246 msg
='Checking for ctdb ipv4 support')
1248 if not conf
.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
1249 have_cluster_support
= False
1250 ctdb_broken
= "missing struct ctdb_control_tcp"
1252 if have_cluster_support
:
1255 #include "replace.h"
1256 #include "system/wait.h"
1257 #include "system/network.h"
1261 #include <ctdb_private.h>
1265 struct ctdb_control_tcp_addr _x;
1269 'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
1272 msg
='Checking for ctdb ipv6 support')
1274 if have_cluster_support
:
1277 #include "replace.h"
1278 #include "system/wait.h"
1279 #include "system/network.h"
1283 #include <ctdb_private.h>
1287 int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1291 'HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL',
1294 msg
='Checking for CHECK_SRVIDS control')
1296 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL'):
1297 if not Options
.options
.enable_old_ctdb
:
1298 have_cluster_support
= False
1299 ctdb_broken
= "CHECK_SRVIDS control missing"
1301 Logs
.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1303 if have_cluster_support
:
1304 Logs
.info("building with cluster support")
1305 conf
.DEFINE('CLUSTER_SUPPORT', 1);
1307 if not Options
.options
.with_cluster_support
:
1308 Logs
.info("building without cluster support")
1310 Logs
.warn("building without cluster support: " + ctdb_broken
)
1311 conf
.undefine('CLUSTER_SUPPORT')
1315 conf
.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1316 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1319 msg
='Checking whether we can compile with __attribute__((destructor))')
1321 conf
.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1322 'SEEKDIR_RETURNS_VOID',
1323 headers
='sys/types.h dirent.h',
1324 msg
='Checking whether seekdir returns void')
1326 if Options
.options
.with_profiling_data
:
1327 conf
.DEFINE('WITH_PROFILE', 1);
1329 PTHREAD_CFLAGS
='error'
1330 PTHREAD_LDFLAGS
='error'
1332 if PTHREAD_LDFLAGS
== 'error':
1333 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
1334 PTHREAD_CFLAGS
='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
1335 PTHREAD_LDFLAGS
='-lpthread'
1336 if PTHREAD_LDFLAGS
== 'error':
1337 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
1338 PTHREAD_CFLAGS
='-D_THREAD_SAFE'
1339 PTHREAD_LDFLAGS
='-lpthreads'
1340 if PTHREAD_LDFLAGS
== 'error':
1341 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
1342 PTHREAD_CFLAGS
='-D_THREAD_SAFE -pthread'
1343 PTHREAD_LDFLAGS
='-pthread'
1344 if PTHREAD_LDFLAGS
== 'error':
1345 if conf
.CHECK_FUNC('pthread_attr_init'):
1346 PTHREAD_CFLAGS
='-D_REENTRANT'
1347 PTHREAD_LDFLAGS
='-lpthread'
1348 # especially for HP-UX, where the CHECK_FUNC macro fails to test for
1349 # pthread_attr_init. On pthread_mutex_lock it works there...
1350 if PTHREAD_LDFLAGS
== 'error':
1351 if conf
.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
1352 PTHREAD_CFLAGS
='-D_REENTRANT'
1353 PTHREAD_LDFLAGS
='-lpthread'
1355 if PTHREAD_CFLAGS
!= 'error' and PTHREAD_LDFLAGS
!= 'error':
1356 conf
.ADD_CFLAGS(PTHREAD_CFLAGS
)
1357 conf
.ADD_LDFLAGS(PTHREAD_LDFLAGS
)
1358 conf
.CHECK_HEADERS('pthread.h')
1359 conf
.DEFINE('HAVE_PTHREAD', '1')
1361 if Options
.options
.with_pthreadpool
:
1362 if conf
.CONFIG_SET('HAVE_PTHREAD'):
1363 conf
.DEFINE('WITH_PTHREADPOOL', '1')
1365 Logs
.warn("pthreadpool support cannot be enabled when pthread support was not found")
1366 conf
.undefine('WITH_PTHREADPOOL')
1368 if conf
.CHECK_HEADERS('gpfs_gpl.h'):
1369 conf
.DEFINE('HAVE_GPFS', '1')
1371 # Note that all charset 'modules' must actually be static, due to dependency loop issues
1372 # if we include the module loader in iconv
1374 default_static_modules
=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1375 auth_sam auth_unix auth_winbind auth_wbc
1376 auth_domain auth_builtin vfs_default
1377 nss_info_template idmap_tdb idmap_passdb
1380 default_shared_modules
=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1381 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1382 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1383 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1384 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1385 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1386 vfs_crossrename vfs_linux_xfs_sgid
1387 vfs_time_audit idmap_autorid''')
1389 if Options
.options
.developer
:
1390 default_static_modules
.extend(TO_LIST('pdb_ads auth_netlogond charset_weird'))
1391 default_shared_modules
.extend(TO_LIST('perfcount_test'))
1392 default_shared_modules
.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1393 default_shared_modules
.extend(TO_LIST('auth_skel pdb_test'))
1395 if conf
.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1396 default_static_modules
.extend(TO_LIST('pdb_samba4 auth_samba4 vfs_dfs_samba4'))
1398 if Options
.options
.with_acl_support
and conf
.CONFIG_SET('HAVE_POSIX_ACLS'):
1399 default_static_modules
.extend(TO_LIST('vfs_posixacl'))
1401 if conf
.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1402 default_shared_modules
.extend(TO_LIST('vfs_zfsacl'))
1404 if conf
.CONFIG_SET('HAVE_DIRFD_DECL'):
1405 default_shared_modules
.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1407 if conf
.CONFIG_SET('HAVE_STATFS_F_FSID'):
1408 default_shared_modules
.extend(TO_LIST('vfs_fileid'))
1410 if conf
.CONFIG_SET('HAVE_AIO') and (conf
.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf
.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
1411 default_shared_modules
.extend(TO_LIST('vfs_aio_fork'))
1413 if conf
.CONFIG_SET('HAVE_AIO') and Options
.options
.with_pthreadpool
:
1414 default_shared_modules
.extend(TO_LIST('vfs_aio_pthread'))
1416 if conf
.CONFIG_SET('HAVE_AIO') and conf
.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1417 default_shared_modules
.extend(TO_LIST('vfs_aio_linux'))
1419 if conf
.CONFIG_SET('HAVE_LDAP'):
1420 default_static_modules
.extend(TO_LIST('pdb_ldap idmap_ldap'))
1422 if conf
.CONFIG_SET('DARWINOS'):
1423 default_static_modules
.extend(TO_LIST('charset_macosxfs'))
1425 if conf
.CONFIG_SET('HAVE_GPFS'):
1426 default_shared_modules
.extend(TO_LIST('vfs_gpfs vfs_gpfs_hsm_notify'))
1428 explicit_shared_modules
= TO_LIST(Options
.options
.shared_modules
, delimiter
=',')
1429 explicit_static_modules
= TO_LIST(Options
.options
.static_modules
, delimiter
=',')
1431 final_static_modules
= default_static_modules
1432 final_shared_modules
= default_shared_modules
1434 for m
in explicit_static_modules
:
1435 if m
in final_shared_modules
:
1436 final_shared_modules
.remove(m
)
1437 final_static_modules
.append(m
)
1438 for m
in explicit_shared_modules
:
1439 if m
in final_static_modules
:
1440 final_static_modules
.remove(m
)
1441 final_shared_modules
.append(m
)
1443 conf
.env
['static_modules'] = final_static_modules
1444 conf
.env
['shared_modules'] = final_shared_modules
1446 conf
.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules
), quote
=True)
1451 prefixes
= ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1452 conf
.env
['MODULE_PREFIXES'] = prefixes
1454 for m
in final_static_modules
:
1456 if not p
in static_list
:
1458 static_list
[p
].append(m
)
1459 for m
in final_shared_modules
:
1461 if not p
in shared_list
:
1463 shared_list
[p
].append(m
)
1466 static_env
= "%s_STATIC" % p
.upper()
1467 shared_env
= "%s_SHARED" % p
.upper()
1468 conf
.env
[static_env
] = []
1469 conf
.env
[shared_env
] = []
1470 if p
in static_list
:
1472 for entry
in static_list
[p
]:
1473 decl_list
+= "extern NTSTATUS %s_init(void); " % entry
1474 conf
.env
[static_env
].append('%s' % entry
)
1475 decl_list
= decl_list
.rstrip()
1476 conf
.DEFINE('static_decl_%s' % p
, decl_list
)
1477 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(); }' % '_init(); '.join(static_list
[p
]))
1479 conf
.DEFINE('static_decl_%s' % p
, '')
1480 conf
.DEFINE('static_init_%s' % p
, '{}')
1481 if p
in shared_list
:
1482 for entry
in shared_list
[p
]:
1483 conf
.DEFINE('%s_init' % entry
, 'samba_init_module')
1484 conf
.env
[shared_env
].append('%s' % entry
)
1486 conf
.SAMBA_CONFIG_H('include/config.h')
1489 "build 'tags' file using ctags"
1491 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
1492 cmd
= 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1493 print("Running: %s" % cmd
)