6 from optparse
import SUPPRESS_HELP
7 sys
.path
.insert(0, srcdir
+"/buildtools/wafsamba")
8 sys
.path
.insert(0, "source3")
9 import wafsamba
, Options
, Logs
, Utils
, Scripting
11 import samba_utils
, samba_version
14 Options
.default_prefix
= '/usr/local/samba'
18 opt
.add_option('--with-static-modules',
19 help=("Comma-separated list of names of modules to statically link in"),
20 action
="store", dest
='static_modules', default
=None)
21 opt
.add_option('--with-shared-modules',
22 help=("Comma-separated list of names of modules to build shared"),
23 action
="store", dest
='shared_modules', default
=None)
25 opt
.SAMBA3_ADD_OPTION('winbind')
26 opt
.SAMBA3_ADD_OPTION('swat')
27 opt
.SAMBA3_ADD_OPTION('ads')
28 opt
.SAMBA3_ADD_OPTION('ldap')
29 opt
.SAMBA3_ADD_OPTION('cups', with_name
="enable", without_name
="disable")
30 opt
.SAMBA3_ADD_OPTION('iprint', with_name
="enable", without_name
="disable")
31 opt
.SAMBA3_ADD_OPTION('pam')
32 opt
.SAMBA3_ADD_OPTION('pam_smbpass')
33 opt
.SAMBA3_ADD_OPTION('quotas')
34 opt
.SAMBA3_ADD_OPTION('sys-quotas')
35 opt
.SAMBA3_ADD_OPTION('sendfile-support')
36 opt
.SAMBA3_ADD_OPTION('utmp')
37 opt
.SAMBA3_ADD_OPTION('pthreadpool', with_name
="enable", without_name
="disable", default
=True)
38 opt
.SAMBA3_ADD_OPTION('avahi', with_name
="enable", without_name
="disable")
39 opt
.SAMBA3_ADD_OPTION('iconv')
40 opt
.SAMBA3_ADD_OPTION('acl-support')
41 opt
.SAMBA3_ADD_OPTION('dnsupdate')
42 opt
.SAMBA3_ADD_OPTION('syslog')
43 opt
.SAMBA3_ADD_OPTION('automount')
44 opt
.SAMBA3_ADD_OPTION('aio-support')
45 opt
.SAMBA3_ADD_OPTION('profiling-data', default
=False)
47 opt
.SAMBA3_ADD_OPTION('cluster-support')
49 opt
.add_option('--with-ctdb-dir',
50 help=("Directory under which ctdb is installed"),
51 action
="store", dest
='ctdb_dir', default
=None)
52 opt
.add_option('--enable-old-ctdb',
53 help=("enable building against (too) old version of ctdb (default=false)"),
54 action
="store_true", dest
='enable_old_ctdb', default
=False)
59 from samba_utils
import TO_LIST
61 default_static_modules
= []
62 default_shared_modules
= []
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 syscall 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_FUNCS_IN('dn_expand', 'inet')
101 conf
.CHECK_DECLS('fdatasync', reverse
=True)
102 conf
.CHECK_DECLS('readahead', reverse
=True, headers
='fcntl.h')
104 if conf
.CONFIG_SET('HAVE_LONG_LONG'):
105 conf
.DEFINE('HAVE_LONGLONG', 1)
107 if conf
.CHECK_CODE('''
108 #if defined(HAVE_UNISTD_H)
111 long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
115 conf
.CHECK_DECLS('splice', reverse
=True, headers
='fcntl.h')
117 # Check for inotify support
118 conf
.CHECK_HEADERS('sys/inotify.h')
119 if "HAVE_SYS_INOTIFY_H" in conf
.env
:
120 conf
.DEFINE('HAVE_INOTIFY', 1)
122 # Check for kernel change notify support
125 #define F_NOTIFY 1026
128 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
129 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain
=False, execute
=True,
130 headers
='fcntl.h signal.h',
131 msg
="Checking for kernel change notify support")
133 # Check for Linux kernel oplocks
135 #include <sys/types.h>
139 #define F_NOTIFY 1026
142 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
143 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain
=False, execute
=True,
144 msg
="Checking for Linux kernel oplocks")
146 # Check for IRIX kernel oplock types
147 conf
.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
148 'HAVE_KERNEL_OPLOCKS_IRIX', headers
='fcntl.h',
149 msg
="Checking for IRIX kernel oplock types")
151 # Check for kernel share modes
153 #include <sys/types.h>
156 #include <sys/file.h>
162 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
163 }''', 'HAVE_KERNEL_SHARE_MODES', addmain
=False, execute
=True,
164 msg
="Checking for krenel share modes")
166 # Check for various members of the stat structure
167 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define
='HAVE_STAT_ST_BLOCKS',
168 headers
='sys/stat.h')
169 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define
='HAVE_STAT_ST_BLKSIZE',
170 headers
='sys/stat.h')
171 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define
='HAVE_STAT_ST_FLAGS',
172 headers
='sys/types.h sys/stat.h unistd.h')
174 if "HAVE_BLKCNT_T" in conf
.env
:
176 return sizeof(blkcnt_t) == 4 ? 0 : 1''',
177 'SIZEOF_BLKCNT_T_4', execute
=True,
178 headers
='replace.h sys/types.h sys/stat.h unistd.h',
179 msg
="Checking whether blkcnt_t is 32 bit")
181 if "HAVE_BLKCNT_T" in conf
.env
:
183 return sizeof(blkcnt_t) == 8 ? 0 : 1''',
184 'SIZEOF_BLKCNT_T_8', execute
=True,
185 headers
='replace.h sys/types.h sys/stat.h unistd.h',
186 msg
="Checking whether blkcnt_t is 64 bit")
188 # Check for POSIX capability support
189 conf
.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers
='sys/capability.h')
191 if "HAVE_SYS_CAPABILITY_H" in conf
.env
:
195 if (!(cap = cap_get_proc())) exit(1);
197 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
198 cap_set_proc(cap);''',
199 'HAVE_POSIX_CAPABILITIES', execute
=True, lib
="cap",
200 headers
='sys/capability.h',
201 msg
="Checking whether POSIX capabilities are available")
203 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
204 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
206 if conf
.CONFIG_SET("HAVE_RPC_RPC_H"):
207 conf
.CHECK_TYPE('int16', headers
='rpc/rpc.h',
208 define
='HAVE_INT16_FROM_RPC_RPC_H',
209 msg
="Checking for int16 typedef included by rpc/rpc.h")
210 conf
.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
211 headers
='sys/types.h rpc/rpc.h',
212 msg
="Checking for uint16 typedef included by rpc/rpc.h")
213 conf
.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
214 headers
='sys/types.h rpc/rpc.h',
215 msg
="Checking for int32 typedef included by rpc/rpc.h")
216 conf
.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
217 headers
='sys/types.h rpc/rpc.h',
218 msg
="Checking for uint32 typedef included by rpc/rpc.h")
219 conf
.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
220 headers
='sys/types.h sys/acl.h rpcsvc/nis.h',
221 msg
="Checking for broken nisplus include files")
223 # Check if the compiler will optimize out functions
226 this_function_does_not_exist();
229 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
230 msg
="Checking if the compiler will optimize out functions")
232 # Check if the compiler supports the LL suffix on long long integers
234 conf
.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
236 msg
="Checking for LL suffix on long long integers")
240 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
241 __closedir crypt16 devnm dgettext dirfd
242 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
244 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
246 fsetxattr _fstat __fstat fsync
247 futimens futimes __fxstat getauthuid
248 getcwd _getcwd __getcwd getdents __getdents getdirentries
249 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
250 getpwanam getpwent_r getrlimit gettext
251 glob grantpt hstrerror initgroups innetgr
252 llseek _llseek __llseek _lseek __lseek
253 _lstat __lstat lutimes
254 __lxstat memalign mknod mlock mlockall munlock munlockall
255 _open __open _opendir __opendir
256 pathconf poll posix_fallocate
257 posix_memalign prctl pread _pread __pread
258 pwrite _pwrite __pwrite
259 rdchk _read __read _readdir __readdir
261 select setenv setgidx setgroups setlocale setluid
262 setmntent setpgid setpriv setsid setuidx
263 shmget shm_open sigaction sigblock sigprocmask sigset
265 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
266 __sys_llseek syslog _telldir __telldir textdomain timegm
267 utimensat vsyslog _write __write __xstat
270 conf
.CHECK_SAMBA3_CHARSET() # see build/charset.py
272 # FIXME: these should be tests for features, but the old build system just
274 host_os
= sys
.platform
275 Logs
.info("building on %s" % host_os
)
277 # Python doesn't have case switches... :/
278 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
279 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
281 conf
.SET_TARGET_TYPE('sunacl', 'EMPTY')
282 if (host_os
.rfind('linux') > -1) or (host_os
.rfind('gnu') > -1) or (host_os
.rfind('qnx') > -1):
283 if host_os
.rfind('linux') > -1:
284 conf
.DEFINE('LINUX', '1')
285 elif host_os
.rfind('qnx') > -1:
286 conf
.DEFINE('QNX', '1')
287 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
288 elif (host_os
.rfind('darwin') > -1):
289 conf
.DEFINE('DARWINOS', 1)
290 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
291 conf
.ADD_CFLAGS('-fno-common')
292 elif (host_os
.rfind('freebsd') > -1):
293 if conf
.CHECK_HEADERS('sunacl.h'):
294 conf
.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
295 conf
.CHECK_FUNCS_IN('acl', 'sunacl')
296 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
297 elif (host_os
.rfind('netbsd') > -1):
298 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
299 elif (host_os
.rfind('openbsd') > -1):
300 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
301 elif (host_os
.rfind('sunos') > -1):
302 conf
.DEFINE('STAT_ST_BLOCKSIZE', '512')
303 # FIXME: Add more checks here.
305 Logs
.warn("Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os
)
307 if Options
.options
.with_acl_support
:
308 if (host_os
.rfind('sysv5') > -1) and conf
.CHECK_FUNCS_IN('sec', 'facl', checklibc
=True):
309 Logs
.info('Using UnixWare ACLs')
310 conf
.DEFINE('HAVE_UNIXWARE_ACLS',1)
311 default_static_modules
.extend(TO_LIST('vfs_solarisacl'))
312 elif (host_os
.rfind('solaris') > -1) and conf
.CHECK_FUNCS_IN('sec', 'facl'):
313 Logs
.info('Using solaris ACLs')
314 conf
.DEFINE('HAVE_SOLARIS_ACLS',1)
315 default_static_modules
.extend(TO_LIST('vfs_solarisacl'))
316 elif (host_os
.rfind('hpux') > -1):
317 Logs
.info('Using HPUX ACLs')
318 conf
.DEFINE('HAVE_HPUX_ACLS',1)
319 default_static_modules
.extend(TO_LIST('vfs_hpuxacl'))
320 elif (host_os
.rfind('irix') > -1):
321 Logs
.info('Using IRIX ACLs')
322 conf
.DEFINE('HAVE_IRIX_ACLS',1)
323 default_static_modules
.extend(TO_LIST('vfs_irixacl'))
324 elif (host_os
.rfind('aix') > -1):
325 Logs
.info('Using AIX ACLs')
326 conf
.DEFINE('HAVE_AIX_ACLS',1)
327 default_static_modules
.extend(TO_LIST('vfs_aixacl'))
328 elif (host_os
.rfind('osf') > -1) and conf
.CHECK_FUNCS_IN('pacl', 'acl_get_fd'):
329 Logs
.info('Using Tru64 ACLs')
330 conf
.DEFINE('HAVE_TRU64_ACLS',1)
331 default_static_modules
.extend(TO_LIST('vfs_tru64acl'))
332 elif (host_os
.rfind('darwin') > -1):
333 Logs
.warn('ACLs on Dwarwin currently not supported')
335 conf
.CHECK_FUNCS_IN('acl_get_file', 'acl')
336 if conf
.CHECK_CODE('''
339 acl_entry_t *entry_p;
340 return acl_get_entry(acl, entry_id, entry_p);
343 headers
='sys/types.h sys/acl.h', link
=False,
344 msg
="Checking for POSIX ACL support") :
346 acl_permset_t permset_d;
348 return acl_get_perm_np(permset_d, perm);
350 'HAVE_ACL_GET_PERM_NP',
351 headers
='sys/types.h sys/acl.h', link
=True,
352 msg
="Checking whether acl_get_perm_np() is available")
353 default_static_modules
.extend(TO_LIST('vfs_posixacl'))
356 if conf
.CHECK_FUNCS('dirfd'):
357 conf
.DEFINE('HAVE_DIRFD_DECL', 1)
359 conf
.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
360 'HAVE_STATFS_F_FSID',
361 msg
="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
362 headers
='sys/types.h sys/statfs.h',
365 if conf
.CONFIG_SET('HAVE_FALLOCATE'):
367 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
368 'HAVE_LINUX_FALLOCATE',
369 msg
="Checking whether the Linux 'fallocate' function is available",
370 headers
='unistd.h sys/types.h fcntl.h linux/falloc.h')
372 ssize_t err = readahead(0,0,0x80000);''',
373 'HAVE_LINUX_READAHEAD',
374 msg
="Checking whether Linux readahead is available",
375 headers
='unistd.h fcntl.h')
376 conf
.CHECK_DECLS('readahead', headers
='fcntl.h', always
=True)
378 conf
.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
380 msg
='Checking for openat',
383 if Options
.options
.with_aio_support
:
384 conf
.CHECK_FUNCS_IN('aio_read', 'aio')
385 conf
.CHECK_FUNCS_IN('aio_read', 'rt')
386 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);',
388 msg
='Checking for asynchronous io support',
389 headers
='sys/types.h aio.h',
391 if conf
.CONFIG_SET('HAVE_AIO'):
392 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg
='Checking for aio_read', headers
='aio.h', lib
='aio rt')
393 conf
.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg
='Checking for aio_write', headers
='aio.h', lib
='aio rt')
394 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')
395 conf
.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg
='Checking for aio_return', headers
='aio.h', lib
='aio rt')
396 conf
.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg
='Checking for aio_error', headers
='aio.h', lib
='aio rt')
397 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')
398 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')
399 if not conf
.CONFIG_SET('HAVE_AIO'):
400 conf
.DEFINE('HAVE_NO_AIO', '1')
402 conf
.DEFINE('HAVE_NO_AIO', '1')
404 if host_os
.rfind('linux') > -1:
405 conf
.CHECK_FUNCS_IN('io_submit', 'aio')
407 struct io_event ioev;
413 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
414 io_queue_init(128,&ctx);
415 io_prep_pwrite(ioc, 1, buf, 1, 0);
416 io_prep_pread(ioc, 1, buf, 1, 0);
417 io_set_eventfd(ioc, fd);
418 io_set_callback(ioc, (io_callback_t)(0));
419 io_submit(ctx, 1, &ioc);
420 io_getevents(ctx, 1, 1, &ioev, &ts);
422 'HAVE_LINUX_KERNEL_AIO',
423 msg
='Checking for linux kernel asynchronous io support',
424 headers
='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
431 char control[CMSG_SPACE(sizeof(int))];
433 msg.msg_control = control_un.control;
434 msg.msg_controllen = sizeof(control_un.control);
436 'HAVE_MSGHDR_MSG_CONTROL',
437 msg
='Checking if we can use msg_control for passing file descriptors',
438 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
442 msg.msg_acctrights = (caddr_t) &fd;
443 msg.msg_acctrightslen = sizeof(fd);
445 'HAVE_MSGHDR_MSG_ACCTRIGHTS',
446 msg
='Checking if we can use msg_acctrights for passing file descriptors',
447 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
449 if Options
.options
.with_winbind
:
450 conf
.env
.build_winbind
= True
451 conf
.DEFINE('WITH_WINBIND', '1')
453 conf
.find_program('awk', var
='AWK')
454 conf
.find_program('perl', var
='PERL')
456 conf
.CHECK_HEADERS('asm/types.h')
458 conf
.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
459 headers
='unistd.h sys/types.h',
460 msg
="Checking for major macro")
462 conf
.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
463 headers
='unistd.h sys/types.h',
464 msg
="Checking for minor macro")
466 conf
.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
467 headers
='unistd.h sys/types.h dirent.h',
468 define
='HAVE_DIRENT_D_OFF')
470 conf
.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
471 if conf
.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
472 netgrent_cflags
= '-Werror-implicit-function-declaration'
475 conf
.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
476 msg
="Checking for setnetgrent prototype",
477 headers
='netdb.h netgroup.h',
478 cflags
=netgrent_cflags
)
479 conf
.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
480 msg
="Checking for getnetgrent prototype",
481 headers
='netdb.h netgroup.h',
482 cflags
=netgrent_cflags
)
483 conf
.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
484 msg
="Checking for endnetgrent prototype",
485 headers
='netdb.h netgroup.h',
486 cflags
=netgrent_cflags
)
490 if Options
.options
.with_cups
:
491 conf
.find_program('cups-config', var
='CUPS_CONFIG')
492 if conf
.env
.CUPS_CONFIG
:
493 # we would normally use --libs here, but cups-config incorrectly adds
494 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
495 # of an in-tree heimdal kerberos
496 conf
.check_cfg(path
=conf
.env
.CUPS_CONFIG
, args
="--cflags --ldflags",
497 package
="", uselib_store
="CUPS")
498 conf
.CHECK_HEADERS('cups/cups.h cups/language.h', lib
='cups')
499 conf
.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
500 if conf
.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf
.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
501 conf
.DEFINE('HAVE_CUPS', '1')
503 conf
.undefine('HAVE_CUPS')
504 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
506 # define an empty subsystem for cups, to allow it to be used as an empty dependency
507 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
509 if Options
.options
.with_iprint
:
510 if conf
.CONFIG_SET('HAVE_CUPS'):
511 conf
.DEFINE('HAVE_IPRINT', '1')
513 Logs
.warn("--enable-iprint=yes but cups support not sufficient")
514 if Options
.options
.with_syslog
:
515 conf
.DEFINE('WITH_SYSLOG', '1')
516 if Options
.options
.with_automount
:
517 conf
.DEFINE('WITH_AUTOMOUNT', '1')
520 if Options
.options
.with_ldap
:
521 conf
.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
522 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
523 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
524 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
526 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
528 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
529 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
531 conf
.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
532 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
534 # Check if ldap_set_rebind_proc() takes three arguments
535 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
536 'LDAP_SET_REBIND_PROC_ARGS',
537 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
538 headers
='ldap.h lber.h', link
=False):
539 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
541 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
543 # last but not least, if ldap_init() exists, we want to use ldap
544 if conf
.CONFIG_SET('HAVE_LDAP_INIT'):
545 conf
.DEFINE('HAVE_LDAP', '1')
546 conf
.DEFINE('LDAP_DEPRECATED', '1')
547 conf
.env
['HAVE_LDAP'] = '1'
548 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
549 # SASL wrapping hooks
550 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
551 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
552 conf
.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
554 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
555 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
557 if Options
.options
.with_ads
:
559 if not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
560 not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
561 Logs
.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
563 if not conf
.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
564 Logs
.warn("krb5_mk_req_extended not found in -lkrb5")
566 if not conf
.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
567 Logs
.warn("krb5_get_host_realm not found in -lkrb5")
569 if not conf
.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
570 Logs
.warn("krb5_free_host_realm not found in -lkrb5")
572 if not conf
.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
573 Logs
.warn("krb5_fwd_tgt_creds found in -lkrb5")
575 if not conf
.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
576 Logs
.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
578 if not conf
.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
579 Logs
.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
581 if not conf
.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
582 Logs
.warn("krb5_get_renewed_creds not found in -lkrb5")
584 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
585 Logs
.warn("krb5_principal_compare_any_realm not found in -lkrb5")
587 if not conf
.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
588 not conf
.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
589 Logs
.warn("krb5_c_string_to_key not found in -lkrb5")
591 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
592 not conf
.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
593 Logs
.warn("no CREATE_KEY_FUNCTIONS detected")
595 if not conf
.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
596 not conf
.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
597 Logs
.warn("no GET_ENCTYPES_FUNCTIONS detected")
599 if not conf
.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
600 not conf
.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
601 Logs
.warn("no KT_FREE_FUNCTION detected")
603 if not conf
.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
604 Logs
.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
607 # We don't actually use
608 # gsskrb5_extract_authz_data_from_sec_context, but it is a
609 # clue that this Heimdal, which does the PAC processing we
610 # need on the standard gss_inquire_sec_context_by_oid
611 if not conf
.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
612 not (conf
.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
613 conf
.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
614 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")
617 if not conf
.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
618 Logs
.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
622 conf
.DEFINE('WITH_ADS', '1')
623 conf
.DEFINE('HAVE_KRB5', '1')
624 if conf
.CONFIG_SET('HAVE_LDAP'):
625 conf
.env
['HAVE_ADS'] = '1'
627 Logs
.warn("krb5 libs don't have all features required for Active Directory support")
628 conf
.undefine('HAVE_KRB5_H')
629 conf
.undefine('HAVE_GSSAPI_H')
630 conf
.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
631 conf
.undefine('HAVE_GSSAPI_GSSAPI_H')
633 if Options
.options
.with_utmp
:
634 conf
.env
.with_utmp
= True
635 if not conf
.CHECK_HEADERS('utmp.h'): conf
.env
.with_utmp
= False
636 conf
.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
637 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers
='utmp.h',
638 define
='HAVE_UT_UT_NAME')
639 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers
='utmp.h',
640 define
='HAVE_UT_UT_USER')
641 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers
='utmp.h',
642 define
='HAVE_UT_UT_ID')
643 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers
='utmp.h',
644 define
='HAVE_UT_UT_HOST')
645 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers
='utmp.h',
646 define
='HAVE_UT_UT_TIME')
647 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers
='utmp.h',
648 define
='HAVE_UT_UT_TV')
649 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers
='utmp.h',
650 define
='HAVE_UT_UT_TYPE')
651 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers
='utmp.h',
652 define
='HAVE_UT_UT_PID')
653 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers
='utmp.h',
654 define
='HAVE_UT_UT_EXIT')
655 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers
='utmp.h',
656 define
='HAVE_UT_UT_ADDR_V6')
657 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers
='utmp.h',
658 define
='HAVE_UT_UT_ADDR')
659 conf
.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers
='utmpx.h',
660 define
='HAVE_UX_UT_SYSLEN')
661 conf
.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
662 'PUTUTLINE_RETURNS_UTMP', headers
='utmp.h',
663 msg
="Checking whether pututline returns pointer")
664 if conf
.env
.with_utmp
:
665 conf
.DEFINE('WITH_UTMP', 1)
667 if Options
.options
.with_avahi
:
668 conf
.env
.with_avahi
= True
669 if not conf
.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf
.env
.with_avahi
= False
670 if not conf
.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf
.env
.with_avahi
= False
671 if not conf
.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf
.env
.with_avahi
= False
672 if conf
.env
.with_avahi
:
673 conf
.DEFINE('WITH_AVAHI_SUPPORT', 1)
675 conf
.SET_TARGET_TYPE('avahi-common', 'EMPTY')
676 conf
.SET_TARGET_TYPE('avahi-client', 'EMPTY')
678 if Options
.options
.with_iconv
:
679 conf
.env
.with_iconv
= True
680 if not conf
.CHECK_FUNCS_IN('iconv_open', 'iconv', headers
='iconv.h'):
681 conf
.env
.with_iconv
= False
682 if conf
.env
.with_iconv
:
683 conf
.DEFINE('HAVE_ICONV', 1)
685 if Options
.options
.with_pam
:
687 conf
.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
688 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
689 Logs
.warn("--with-pam=yes but pam_appl.h not found")
691 conf
.CHECK_FUNCS_IN('pam_get_data', 'pam')
692 conf
.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
693 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
694 Logs
.warn("--with-pam=yes but pam_modules.h not found")
696 conf
.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
697 conf
.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
698 conf
.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
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>
705 pam_set_item(0, PAM_RHOST, 0);
709 msg
="Checking whether PAM_RHOST is available");
711 #if defined(HAVE_SECURITY_PAM_APPL_H)
712 #include <security/pam_appl.h>
713 #elif defined(HAVE_PAM_PAM_APPL_H)
714 #include <pam/pam_appl.h>
716 pam_set_item(0, PAM_TTY, 0);
720 msg
="Checking whether PAM_TTY is available");
722 #if (!defined(LINUX))
724 #define PAM_EXTERN extern
725 #if defined(HAVE_SECURITY_PAM_APPL_H)
726 #include <security/pam_appl.h>
727 #elif defined(HAVE_PAM_PAM_APPL_H)
728 #include <pam/pam_appl.h>
733 #if defined(HAVE_SECURITY_PAM_MODULES_H)
734 #include <security/pam_modules.h>
735 #elif defined(HAVE_PAM_PAM_MODULES_H)
736 #include <pam/pam_modules.h>
739 #if defined(HAVE_SECURITY__PAM_MACROS_H)
740 #include <security/_pam_macros.h>
741 #elif defined(HAVE_PAM__PAM_MACROS_H)
742 #include <pam/_pam_macros.h>
745 #ifdef HAVE_SECURITY_PAM_EXT_H
746 #include <security/pam_ext.h>
749 int i; i = PAM_RADIO_TYPE;
751 'HAVE_PAM_RADIO_TYPE',
753 msg
="Checking whether PAM_RADIO_TYPE is available");
755 conf
.DEFINE('WITH_PAM', 1)
756 conf
.DEFINE('WITH_PAM_MODULES', 1)
761 # Ensure we select the correct set of system calls on Linux.
763 if (host_os
.rfind('linux') > -1):
765 #if defined(HAVE_UNISTD_H)
770 #include <sys/types.h>
773 #ifdef HAVE_SYS_PRIV_H
774 #include <sys/priv.h>
780 #if defined(HAVE_SYSCALL_H)
784 #if defined(HAVE_SYS_SYSCALL_H)
785 #include <sys/syscall.h>
788 syscall(SYS_setresuid32, -1, -1, -1);
789 syscall(SYS_setresgid32, -1, -1, -1);
790 syscall(SYS_setreuid32, -1, -1);
791 syscall(SYS_setregid32, -1, -1);
792 syscall(SYS_setuid32, -1);
793 syscall(SYS_setgid32, -1);
794 syscall(SYS_setgroups32, 0, NULL);
796 'USE_LINUX_32BIT_SYSCALLS',
797 msg
="Checking whether Linux should use 32-bit credential calls");
799 if (conf
.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
800 seteuid
= conf
.CHECK_CODE('''
801 #define AUTOCONF_TEST 1
802 #define USE_LINUX_THREAD_CREDENTIALS 1
803 #define USE_LINUX_32BIT_SYSCALLS 1
804 #include "../lib/util/setid.c"
805 #include "./lib/util_sec.c"
807 'USE_LINUX_THREAD_CREDENTIALS',
810 msg
="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
812 seteuid
= conf
.CHECK_CODE('''
813 #define AUTOCONF_TEST 1
814 #define USE_LINUX_THREAD_CREDENTIALS 1
815 #include "../lib/util/setid.c"
816 #include "./lib/util_sec.c"
818 'USE_LINUX_THREAD_CREDENTIALS',
821 msg
="Checking whether we can use Linux thread-specific credentials")
823 seteuid
= conf
.CHECK_CODE('''
824 #define AUTOCONF_TEST 1
825 #define USE_SETREUID 1
826 #include "../lib/util/setid.c"
827 #include "./lib/util_sec.c"
832 msg
="Checking whether setreuid is available")
834 seteuid
= conf
.CHECK_CODE('''
835 #define AUTOCONF_TEST 1
836 #define USE_SETRESUID 1
837 #include "../lib/util/setid.c"
838 #include "./lib/util_sec.c"
843 msg
="Checking whether setresuid is available")
845 seteuid
= conf
.CHECK_CODE('''
846 #define AUTOCONF_TEST 1
847 #define USE_SETEUID 1
848 #include "../lib/util/setid.c"
849 #include "./lib/util_sec.c"
854 msg
="Checking whether seteuid is available")
856 seteuid
= conf
.CHECK_CODE('''
857 #define AUTOCONF_TEST 1
858 #define USE_SETUIDX 1
859 #include "../lib/util/setid.c"
860 #include "./lib/util_sec.c"
866 msg
="Checking whether setuidx is available")
867 if Options
.options
.with_dnsupdate
:
868 if not conf
.CONFIG_SET('HAVE_KRB5'):
869 Logs
.warn("--with-dnsupdate=yes but gssapi support not sufficient")
871 conf
.DEFINE('WITH_DNS_UPDATES', 1)
872 conf
.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
873 if Options
.options
.developer
:
874 if conf
.CONFIG_SET('HAVE_VALGRIND_H') or conf
.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
875 conf
.DEFINE('VALGRIND', '1')
877 if conf
.CHECK_CODE('''
878 #include <bits/sockaddr.h>
879 #include <linux/netlink.h>
881 'HAVE_LINUX_NETLINK_H',
882 msg
="Checking whether Linux netlink is available"):
885 #include <bits/sockaddr.h>
886 #include <linux/netlink.h>
887 #include <linux/rtnetlink.h>
889 'HAVE_LINUX_RTNETLINK_H',
890 msg
='Checking whether Linux rtnetlink is available')
893 #include "../tests/fcntl_lock.c"
898 msg
='Checking whether fcntl locking is available')
900 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
901 if not conf
.CHECK_CODE('''
902 #define _XOPEN_SOURCE 600
904 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
905 #error probably broken posix_fallocate
908 '_HAVE_UNBROKEN_POSIX_FALLOCATE',
909 msg
='Checking for broken posix_fallocate'):
910 conf
.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
913 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
914 define
='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
915 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
916 define
='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
917 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
918 define
='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
919 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
920 define
='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
921 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
922 define
='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
923 if conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
924 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
925 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
926 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
927 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
928 conf
.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
930 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
931 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
932 define
='HAVE_STRUCT_STAT_ST_BIRTHTIME')
933 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
934 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
935 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
936 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
939 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
941 'HAVE_POSIX_FADVISE',
942 msg
='Checking whether posix_fadvise is available',
943 headers
='unistd.h fcntl.h')
945 for v
in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
948 return sysconf(%s) == -1 ? 1 : 0;
951 msg
='Checking whether sysconf(%s) is available' % v
)
954 #include <sys/syscall.h>
956 syscall(SYS_initgroups, 16, NULL, NULL, 0);
958 'HAVE_DARWIN_INITGROUPS',
959 msg
='Checking whether to use the Darwin-specific initgroups system call')
961 conf
.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
963 headers
='sys/types.h utime.h',
964 msg
='Checking whether struct utimbuf is available')
966 if conf
.CHECK_CODE('''struct sigevent s;''',
967 'HAVE_STRUCT_SIGEVENT',
968 headers
='sys/types.h stdlib.h stddef.h signal.h',
969 msg
='Checking whether we have the struct sigevent'):
970 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
971 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
973 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
974 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
977 if os
.path
.exists('/proc/sys/kernel/core_pattern'):
978 conf
.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
980 if conf
.CHECK_CODE('''
984 if (sizeof(time_t) == 8) {
985 time_t max_time = 0x7fffffffffffffffll;
986 tm = gmtime(&max_time);
987 /* This should fail with 32-bit tm_year. */
989 /* Max time_t that works with 32-bit int tm_year in struct tm. */
990 max_time = 67768036191676799ll;
991 tm = gmtime(&max_time);
1002 msg
="Checking for the maximum value of the 'time_t' type"):
1003 conf
.DEFINE('TIME_T_MAX', '67768036191676799ll')
1006 #if defined(HAVE_UNISTD_H)
1009 #include <sys/types.h>
1010 main() { dev_t dev = makedev(1,2); return 0; }
1014 msg
='Checking whether the macro for makedev is available')
1021 void exit_on_core(int ignored) {
1027 signal(SIGSEGV, exit_on_core);
1028 newpath = realpath("/tmp", NULL);
1029 exit((newpath != NULL) ? 0 : 1);
1032 'REALPATH_TAKES_NULL',
1035 msg
='Checking whether the realpath function allows a NULL argument')
1037 conf
.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1038 'HAVE_FTRUNCATE_EXTEND',
1039 msg
='Checking for ftruncate extend',
1043 if Options
.options
.with_sendfile_support
:
1044 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):
1049 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1052 headers
='sys/sendfile.h',
1053 msg
='Checking for linux sendfile support')
1055 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1056 conf
.DEFINE('HAVE_SENDFILE', '1')
1057 conf
.DEFINE('LINUX_SENDFILE_API', '1')
1058 conf
.DEFINE('WITH_SENDFILE', '1')
1059 elif (host_os
.rfind('freebsd') > -1) or (host_os
.rfind('dragonfly') > -1):
1061 #include <sys/types.h>
1063 #include <sys/socket.h>
1064 #include <sys/uio.h>
1065 int fromfd, tofd, ret, total=0;
1066 off_t offset, nwritten;
1069 hdr.headers = &hdtrl;
1071 hdr.trailers = NULL;
1073 hdtrl.iov_base = NULL;
1075 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1078 msg
='Checking for freebsd sendfile support')
1079 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1080 conf
.DEFINE('HAVE_SENDFILE', '1')
1081 conf
.DEFINE('FREEBSD_SENDFILE_API', '1')
1082 conf
.DEFINE('WITH_SENDFILE', '1')
1083 elif (host_os
.rfind('darwin') > -1):
1085 #include <sys/types.h>
1086 #include <sys/socket.h>
1087 #include <sys/uio.h>
1088 int fromfd, tofd, ret;
1089 off_t offset, nwritten;
1092 hdr.headers = &hdtrl;
1094 hdr.trailers = (void *)0;
1096 hdtrl.iov_base = (void *)0;
1098 ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1101 msg
='Checking for darwin sendfile support')
1102 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1103 conf
.DEFINE('HAVE_SENDFILE', '1')
1104 conf
.DEFINE('DARWIN_SENDFILE_API', '1')
1105 conf
.DEFINE('WITH_SENDFILE', '1')
1106 elif (host_os
.rfind('hpux') > -1) or (host_os
.rfind('osf') > -1):
1108 #include <sys/socket.h>
1109 #include <sys/uio.h>
1112 struct iovec hdtrl[2];
1115 hdtrl[0].iov_base = 0;
1116 hdtrl[0].iov_len = 0;
1117 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1120 msg
='Checking for osf/hpux sendfile support')
1121 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1122 conf
.DEFINE('HAVE_SENDFILE', '1')
1123 conf
.DEFINE('HPUX_SENDFILE_API', '1')
1124 conf
.DEFINE('WITH_SENDFILE', '1')
1125 elif (host_os
.rfind('solaris') > -1):
1126 conf
.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1128 #include <sys/sendfile.h>,
1131 struct sendfilevec vec[2];
1135 vec[0].sfv_fd = SFV_FD_SELF;
1136 vec[0].sfv_flag = 0;
1140 vec[1].sfv_flag = 0;
1143 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1146 msg
='Checking for solaris sendfilev support')
1147 if conf
.CONFIG_SET('_HAVE_SENDFILEV'):
1148 conf
.DEFINE('HAVE_SENDFILEV', '1')
1149 conf
.DEFINE('SOLARIS_SENDFILE_API', '1')
1150 conf
.DEFINE('WITH_SENDFILE', '1')
1151 elif (host_os
.rfind('aix') > -1):
1153 #include <sys/socket.h>
1156 struct sf_parms hdtrl;
1158 hdtrl.header_data = 0;
1159 hdtrl.header_length = 0;
1160 hdtrl.file_descriptor = fromfd;
1161 hdtrl.file_offset = 0;
1162 hdtrl.file_bytes = 0;
1163 hdtrl.trailer_data = 0;
1164 hdtrl.trailer_length = 0;
1165 nwritten = send_file(&tofd, &hdtrl, 0);
1168 msg
='Checking for AIX send_file support')
1169 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1170 conf
.DEFINE('HAVE_SENDFILE', '1')
1171 conf
.DEFINE('AIX_SENDFILE_API', '1')
1172 conf
.DEFINE('WITH_SENDFILE', '1')
1174 # Check for getcwd allowing a NULL arg.
1178 char *s = getcwd(NULL,0);
1179 exit(s != NULL ? 0 : 1);
1180 }''', 'GETCWD_TAKES_NULL', addmain
=False, execute
=True,
1181 msg
="getcwd takes a NULL argument")
1184 # UnixWare 7.x has its getspnam in -lgen
1185 conf
.CHECK_FUNCS_IN('getspnam', 'gen')
1186 conf
.CHECK_FUNCS_IN('getspnam', 'security')
1187 conf
.CHECK_FUNCS_IN('getspnam', 'sec')
1189 if Options
.options
.with_quotas
:
1190 # For quotas on Veritas VxFS filesystems
1191 conf
.CHECK_HEADERS('sys/fs/vx_quota.h')
1192 # For sys/quota.h and linux/quota.h
1193 conf
.CHECK_HEADERS('sys/quota.h')
1194 # For quotas on BSD systems
1195 conf
.CHECK_HEADERS('ufs/ufs/quota.h')
1196 # For quotas on Linux XFS filesystems
1197 if conf
.CHECK_HEADERS('xfs/xqm.h'):
1198 conf
.DEFINE('HAVE_XFS_QUOTAS', '1')
1202 #include "confdefs.h"
1203 #ifdef HAVE_SYS_TYPES_H
1204 #include <sys/types.h>
1206 #ifdef HAVE_ASM_TYPES_H
1207 #include <asm/types.h>
1209 #include <sys/quota.h>
1210 int i = Q_XGETQUOTA;''',
1211 define
='HAVE_XFS_QUOTAS',
1212 msg
='for XFS QUOTA in <sys/quota.h>',
1214 local_include
=False)
1216 # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
1217 conf
.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define
='HAVE_DQB_FSOFTLIMIT',
1218 headers
='sys/quota.h')
1220 if conf
.CHECK_HEADERS('rpcsvc/rquota.h'):
1221 conf
.DEFINE('HAVE_NFS_QUOTAS', '1')
1222 conf
.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1223 define
='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1224 headers
='rpcsvc/rquota.h')
1226 if (host_os
.rfind('linux') > -1):
1227 conf
.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1229 if conf
.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1230 conf
.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1231 conf
.CONFIG_SET('HAVE_QUOTACTL_4B'):
1232 conf
.DEFINE('HAVE_SYS_QUOTAS', '1')
1235 # checking for clustering extensions (CTDB)
1237 if not Options
.options
.with_cluster_support
:
1238 have_cluster_support
= False
1242 if Options
.options
.ctdb_dir
:
1243 conf
.ADD_EXTRA_INCLUDES(Options
.options
.ctdb_dir
+ '/include')
1245 srcdir
= os
.path
.realpath(conf
.srcdir
)
1246 if 'EXTRA_INCLUDES' in conf
.env
:
1247 includes
= ' '.join(conf
.env
['EXTRA_INCLUDES']).replace('#', srcdir
+ '/')
1251 have_cluster_support
= True
1256 #include "replace.h"
1257 #include "system/wait.h"
1258 #include "system/network.h"
1259 #define private #error __USED_RESERVED_WORD_private__
1272 msg
='Checking for header ctdb.h')
1274 if not conf
.CONFIG_SET('HAVE_CTDB_H'):
1275 have_cluster_support
= False
1276 ctdb_broken
= "ctdb.h is required for cluster support"
1278 if have_cluster_support
:
1281 #include "replace.h"
1282 #include "system/wait.h"
1283 #include "system/network.h"
1284 #define private #error __USED_RESERVED_WORD_private__
1288 #include <ctdb_private.h>
1295 'HAVE_CTDB_PRIVATE_H',
1298 msg
='Checking for header ctdb_private.h')
1300 if not conf
.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
1301 have_cluster_support
= False
1302 ctdb_broken
= "ctdb_private.h is required for cluster support"
1304 if have_cluster_support
:
1307 #include "replace.h"
1308 #include "system/wait.h"
1309 #include "system/network.h"
1313 #include <ctdb_private.h>
1317 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1321 'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
1324 msg
='Checking for transaction support (TRANS3_COMMIT control)')
1326 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
1327 have_cluster_support
= False
1328 ctdb_broken
= "ctdb transaction support missing or too old"
1330 if have_cluster_support
:
1333 #include "replace.h"
1334 #include "system/wait.h"
1335 #include "system/network.h"
1339 #include <ctdb_private.h>
1343 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1347 'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
1350 msg
='Checking for SCHEDULE_FOR_DELETION control')
1352 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
1353 if not Options
.options
.enable_old_ctdb
:
1354 have_cluster_support
= False
1355 ctdb_broken
= "SCHEDULE_FOR_DELETION control missing"
1357 Logs
.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1359 if have_cluster_support
:
1362 #include "replace.h"
1363 #include "system/wait.h"
1364 #include "system/network.h"
1368 #include <ctdb_private.h>
1372 struct ctdb_control_tcp _x;
1376 'HAVE_STRUCT_CTDB_CONTROL_TCP',
1379 msg
='Checking for ctdb ipv4 support')
1381 if not conf
.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
1382 have_cluster_support
= False
1383 ctdb_broken
= "missing struct ctdb_control_tcp"
1385 if have_cluster_support
:
1388 #include "replace.h"
1389 #include "system/wait.h"
1390 #include "system/network.h"
1394 #include <ctdb_private.h>
1398 struct ctdb_control_tcp_addr _x;
1402 'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
1405 msg
='Checking for ctdb ipv6 support')
1407 if have_cluster_support
:
1410 #include "replace.h"
1411 #include "system/wait.h"
1412 #include "system/network.h"
1416 #include <ctdb_private.h>
1420 int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1424 'HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL',
1427 msg
='Checking for CHECK_SRVIDS control')
1429 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL'):
1430 if not Options
.options
.enable_old_ctdb
:
1431 have_cluster_support
= False
1432 ctdb_broken
= "CHECK_SRVIDS control missing"
1434 Logs
.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1436 if have_cluster_support
:
1437 Logs
.info("building with cluster support")
1438 conf
.DEFINE('CLUSTER_SUPPORT', 1);
1440 if not Options
.options
.with_cluster_support
:
1441 Logs
.info("building without cluster support")
1443 Logs
.warn("building without cluster support: " + ctdb_broken
)
1444 conf
.undefine('CLUSTER_SUPPORT')
1448 conf
.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1449 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1452 msg
='Checking whether we can compile with __attribute__((destructor))')
1454 conf
.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1455 'SEEKDIR_RETURNS_VOID',
1456 headers
='sys/types.h dirent.h',
1457 msg
='Checking whether seekdir returns void')
1459 if Options
.options
.with_profiling_data
:
1460 conf
.DEFINE('WITH_PROFILE', 1);
1462 PTHREAD_CFLAGS
='error'
1463 PTHREAD_LDFLAGS
='error'
1465 if PTHREAD_LDFLAGS
== 'error':
1466 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
1467 PTHREAD_CFLAGS
='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
1468 PTHREAD_LDFLAGS
='-lpthread'
1469 if PTHREAD_LDFLAGS
== 'error':
1470 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
1471 PTHREAD_CFLAGS
='-D_THREAD_SAFE'
1472 PTHREAD_LDFLAGS
='-lpthreads'
1473 if PTHREAD_LDFLAGS
== 'error':
1474 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
1475 PTHREAD_CFLAGS
='-D_THREAD_SAFE -pthread'
1476 PTHREAD_LDFLAGS
='-pthread'
1477 if PTHREAD_LDFLAGS
== 'error':
1478 if conf
.CHECK_FUNCS('pthread_attr_init'):
1479 PTHREAD_CFLAGS
='-D_REENTRANT'
1480 PTHREAD_LDFLAGS
='-lpthread'
1481 # especially for HP-UX, where the CHECK_FUNC macro fails to test for
1482 # pthread_attr_init. On pthread_mutex_lock it works there...
1483 if PTHREAD_LDFLAGS
== 'error':
1484 if conf
.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
1485 PTHREAD_CFLAGS
='-D_REENTRANT'
1486 PTHREAD_LDFLAGS
='-lpthread'
1488 if PTHREAD_CFLAGS
!= 'error' and PTHREAD_LDFLAGS
!= 'error':
1489 conf
.ADD_CFLAGS(PTHREAD_CFLAGS
)
1490 conf
.ADD_LDFLAGS(PTHREAD_LDFLAGS
)
1491 conf
.CHECK_HEADERS('pthread.h')
1492 conf
.DEFINE('HAVE_PTHREAD', '1')
1494 if Options
.options
.with_pthreadpool
:
1495 if conf
.CONFIG_SET('HAVE_PTHREAD'):
1496 conf
.DEFINE('WITH_PTHREADPOOL', '1')
1498 Logs
.warn("pthreadpool support cannot be enabled when pthread support was not found")
1499 conf
.undefine('WITH_PTHREADPOOL')
1501 if conf
.CHECK_HEADERS('gpfs_gpl.h'):
1502 conf
.DEFINE('HAVE_GPFS', '1')
1504 default_static_modules
.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1505 auth_sam auth_unix auth_winbind auth_wbc
1506 auth_domain auth_builtin vfs_default
1507 nss_info_template idmap_tdb idmap_passdb
1510 default_shared_modules
.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1511 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1512 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1513 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1514 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1515 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1517 vfs_crossrename vfs_linux_xfs_sgid
1518 vfs_time_audit idmap_autorid idmap_tdb2
1519 idmap_rid idmap_hash'''))
1521 if Options
.options
.developer
:
1522 default_static_modules
.extend(TO_LIST('charset_weird'))
1523 default_shared_modules
.extend(TO_LIST('perfcount_test'))
1524 default_shared_modules
.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1525 default_shared_modules
.extend(TO_LIST('auth_skel pdb_test'))
1527 if Options
.options
.enable_selftest
or Options
.options
.developer
:
1528 default_shared_modules
.extend(TO_LIST('vfs_fake_acls'))
1531 if conf
.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1532 default_static_modules
.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
1534 if conf
.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1535 default_shared_modules
.extend(TO_LIST('vfs_zfsacl'))
1537 if conf
.CONFIG_SET('HAVE_DIRFD_DECL'):
1538 default_shared_modules
.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1540 if conf
.CONFIG_SET('HAVE_STATFS_F_FSID'):
1541 default_shared_modules
.extend(TO_LIST('vfs_fileid'))
1543 if (conf
.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf
.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
1544 default_shared_modules
.extend(TO_LIST('vfs_aio_fork'))
1546 if Options
.options
.with_pthreadpool
:
1547 default_shared_modules
.extend(TO_LIST('vfs_aio_pthread'))
1549 if conf
.CONFIG_SET('HAVE_AIO'):
1550 default_shared_modules
.extend(TO_LIST('vfs_aio_posix'))
1552 if conf
.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1553 default_shared_modules
.extend(TO_LIST('vfs_aio_linux'))
1555 if conf
.CONFIG_SET('HAVE_LDAP'):
1556 default_static_modules
.extend(TO_LIST('pdb_ldap idmap_ldap'))
1558 if conf
.CONFIG_SET('DARWINOS'):
1559 default_static_modules
.extend(TO_LIST('charset_macosxfs'))
1561 if conf
.CONFIG_SET('HAVE_GPFS'):
1562 default_shared_modules
.extend(TO_LIST('vfs_gpfs'))
1564 explicit_shared_modules
= TO_LIST(Options
.options
.shared_modules
, delimiter
=',')
1565 explicit_static_modules
= TO_LIST(Options
.options
.static_modules
, delimiter
=',')
1567 final_static_modules
= default_static_modules
1568 final_shared_modules
= default_shared_modules
1570 for m
in explicit_static_modules
:
1571 if m
in final_shared_modules
:
1572 final_shared_modules
.remove(m
)
1573 final_static_modules
.append(m
)
1574 for m
in explicit_shared_modules
:
1575 if m
in final_static_modules
:
1576 final_static_modules
.remove(m
)
1577 final_shared_modules
.append(m
)
1579 conf
.env
['static_modules'] = final_static_modules
1580 conf
.env
['shared_modules'] = final_shared_modules
1582 conf
.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules
), quote
=True)
1587 prefixes
= ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1588 conf
.env
['MODULE_PREFIXES'] = prefixes
1590 for m
in final_static_modules
:
1592 if not p
in static_list
:
1594 static_list
[p
].append(m
)
1595 for m
in final_shared_modules
:
1597 if not p
in shared_list
:
1599 shared_list
[p
].append(m
)
1602 static_env
= "%s_STATIC" % p
.upper()
1603 shared_env
= "%s_SHARED" % p
.upper()
1604 conf
.env
[static_env
] = []
1605 conf
.env
[shared_env
] = []
1606 if p
in static_list
:
1608 for entry
in static_list
[p
]:
1609 decl_list
+= "extern NTSTATUS %s_init(void); " % entry
1610 conf
.env
[static_env
].append('%s' % entry
)
1611 decl_list
= decl_list
.rstrip()
1612 conf
.DEFINE('static_decl_%s' % p
, decl_list
)
1613 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(); }' % '_init(); '.join(static_list
[p
]))
1615 conf
.DEFINE('static_decl_%s' % p
, '')
1616 conf
.DEFINE('static_init_%s' % p
, '{}')
1617 if p
in shared_list
:
1618 for entry
in shared_list
[p
]:
1619 conf
.DEFINE('%s_init' % entry
, 'samba_init_module')
1620 conf
.env
[shared_env
].append('%s' % entry
)
1622 conf
.SAMBA_CONFIG_H('include/config.h')
1625 "build 'tags' file using ctags"
1627 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
1628 cmd
= 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1629 print("Running: %s" % cmd
)