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_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,SPLICE_F_MOVE);
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 if Options
.options
.with_acl_support
:
307 if (host_os
.rfind('sysv5') > -1) and conf
.CHECK_FUNCS_IN('sec', 'facl', checklibc
=True):
308 Logs
.info('Using UnixWare ACLs')
309 conf
.DEFINE('HAVE_UNIXWARE_ACLS',1)
310 default_static_modules
.extend(TO_LIST('vfs_solarisacl'))
311 elif (host_os
.rfind('solaris') > -1) and conf
.CHECK_FUNCS_IN('sec', 'facl'):
312 Logs
.info('Using solaris ACLs')
313 conf
.DEFINE('HAVE_SOLARIS_ACLS',1)
314 default_static_modules
.extend(TO_LIST('vfs_solarisacl'))
315 elif (host_os
.rfind('hpux') > -1):
316 Logs
.info('Using HPUX ACLs')
317 conf
.DEFINE('HAVE_HPUX_ACLS',1)
318 default_static_modules
.extend(TO_LIST('vfs_hpuxacl'))
319 elif (host_os
.rfind('irix') > -1):
320 Logs
.info('Using IRIX ACLs')
321 conf
.DEFINE('HAVE_IRIX_ACLS',1)
322 default_static_modules
.extend(TO_LIST('vfs_irixacl'))
323 elif (host_os
.rfind('aix') > -1):
324 Logs
.info('Using AIX ACLs')
325 conf
.DEFINE('HAVE_AIX_ACLS',1)
326 default_static_modules
.extend(TO_LIST('vfs_aixacl'))
327 elif (host_os
.rfind('osf') > -1) and conf
.CHECK_FUNCS_IN('pacl', 'acl_get_fd'):
328 Logs
.info('Using Tru64 ACLs')
329 conf
.DEFINE('HAVE_TRU64_ACLS',1)
330 default_static_modules
.extend(TO_LIST('vfs_tru64acl'))
331 elif (host_os
.rfind('darwin') > -1):
332 Logs
.warn('ACLs on Dwarwin currently not supported')
334 conf
.CHECK_FUNCS_IN('acl_get_file', 'acl')
335 if conf
.CHECK_CODE('''
338 acl_entry_t *entry_p;
339 return acl_get_entry(acl, entry_id, entry_p);
342 headers
='sys/types.h sys/acl.h', link
=False,
343 msg
="Checking for POSIX ACL support") :
345 acl_permset_t permset_d;
347 return acl_get_perm_np(permset_d, perm);
349 'HAVE_ACL_GET_PERM_NP',
350 headers
='sys/types.h sys/acl.h', link
=True,
351 msg
="Checking whether acl_get_perm_np() is available")
352 default_static_modules
.extend(TO_LIST('vfs_posixacl'))
355 if conf
.CHECK_FUNCS('dirfd'):
356 conf
.DEFINE('HAVE_DIRFD_DECL', 1)
358 conf
.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
359 'HAVE_STATFS_F_FSID',
360 msg
="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
361 headers
='sys/types.h sys/statfs.h',
364 if conf
.CONFIG_SET('HAVE_FALLOCATE'):
366 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
367 'HAVE_LINUX_FALLOCATE',
368 msg
="Checking whether the Linux 'fallocate' function is available",
369 headers
='unistd.h sys/types.h fcntl.h linux/falloc.h')
371 ssize_t err = readahead(0,0,0x80000);''',
372 'HAVE_LINUX_READAHEAD',
373 msg
="Checking whether Linux readahead is available",
374 headers
='unistd.h fcntl.h')
375 conf
.CHECK_DECLS('readahead', headers
='fcntl.h', always
=True)
377 conf
.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
379 msg
='Checking for openat',
382 if Options
.options
.with_aio_support
:
383 conf
.CHECK_FUNCS_IN('aio_read', 'aio')
384 conf
.CHECK_FUNCS_IN('aio_read', 'rt')
385 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);',
387 msg
='Checking for asynchronous io support',
388 headers
='sys/types.h aio.h',
390 if conf
.CONFIG_SET('HAVE_AIO'):
391 conf
.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg
='Checking for aio_read', headers
='aio.h', lib
='aio rt')
392 conf
.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg
='Checking for aio_write', headers
='aio.h', lib
='aio rt')
393 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')
394 conf
.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg
='Checking for aio_return', headers
='aio.h', lib
='aio rt')
395 conf
.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg
='Checking for aio_error', headers
='aio.h', lib
='aio rt')
396 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')
397 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')
398 if not conf
.CONFIG_SET('HAVE_AIO'):
399 conf
.DEFINE('HAVE_NO_AIO', '1')
401 conf
.DEFINE('HAVE_NO_AIO', '1')
403 if host_os
.rfind('linux') > -1:
404 conf
.CHECK_FUNCS_IN('io_submit', 'aio')
406 struct io_event ioev;
412 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
413 io_queue_init(128,&ctx);
414 io_prep_pwrite(ioc, 1, buf, 1, 0);
415 io_prep_pread(ioc, 1, buf, 1, 0);
416 io_set_eventfd(ioc, fd);
417 io_set_callback(ioc, (io_callback_t)(0));
418 io_submit(ctx, 1, &ioc);
419 io_getevents(ctx, 1, 1, &ioev, &ts);
421 'HAVE_LINUX_KERNEL_AIO',
422 msg
='Checking for linux kernel asynchronous io support',
423 headers
='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
430 char control[CMSG_SPACE(sizeof(int))];
432 msg.msg_control = control_un.control;
433 msg.msg_controllen = sizeof(control_un.control);
435 'HAVE_MSGHDR_MSG_CONTROL',
436 msg
='Checking if we can use msg_control for passing file descriptors',
437 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
441 msg.msg_acctrights = (caddr_t) &fd;
442 msg.msg_acctrightslen = sizeof(fd);
444 'HAVE_MSGHDR_MSG_ACCTRIGHTS',
445 msg
='Checking if we can use msg_acctrights for passing file descriptors',
446 headers
='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
448 if Options
.options
.with_winbind
:
449 conf
.env
.build_winbind
= True
450 conf
.DEFINE('WITH_WINBIND', '1')
452 conf
.find_program('awk', var
='AWK')
453 conf
.find_program('perl', var
='PERL')
455 conf
.CHECK_HEADERS('asm/types.h')
457 conf
.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
458 headers
='unistd.h sys/types.h',
459 msg
="Checking for major macro")
461 conf
.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
462 headers
='unistd.h sys/types.h',
463 msg
="Checking for minor macro")
465 conf
.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
466 headers
='unistd.h sys/types.h dirent.h',
467 define
='HAVE_DIRENT_D_OFF')
469 conf
.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
470 if conf
.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
471 netgrent_cflags
= '-Werror-implicit-function-declaration'
474 conf
.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
475 msg
="Checking for setnetgrent prototype",
476 headers
='netdb.h netgroup.h',
477 cflags
=netgrent_cflags
)
478 conf
.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
479 msg
="Checking for getnetgrent prototype",
480 headers
='netdb.h netgroup.h',
481 cflags
=netgrent_cflags
)
482 conf
.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
483 msg
="Checking for endnetgrent prototype",
484 headers
='netdb.h netgroup.h',
485 cflags
=netgrent_cflags
)
489 if Options
.options
.with_cups
:
490 conf
.find_program('cups-config', var
='CUPS_CONFIG')
491 if conf
.env
.CUPS_CONFIG
:
492 # we would normally use --libs here, but cups-config incorrectly adds
493 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
494 # of an in-tree heimdal kerberos
495 conf
.check_cfg(path
=conf
.env
.CUPS_CONFIG
, args
="--cflags --ldflags",
496 package
="", uselib_store
="CUPS")
497 conf
.CHECK_HEADERS('cups/cups.h cups/language.h', lib
='cups')
498 conf
.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
499 if conf
.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf
.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
500 conf
.DEFINE('HAVE_CUPS', '1')
502 conf
.undefine('HAVE_CUPS')
503 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
505 # define an empty subsystem for cups, to allow it to be used as an empty dependency
506 conf
.SET_TARGET_TYPE('cups', 'EMPTY')
508 if Options
.options
.with_iprint
:
509 if conf
.CONFIG_SET('HAVE_CUPS'):
510 conf
.DEFINE('HAVE_IPRINT', '1')
512 Logs
.warn("--enable-iprint=yes but cups support not sufficient")
513 if Options
.options
.with_syslog
:
514 conf
.DEFINE('WITH_SYSLOG', '1')
515 if Options
.options
.with_automount
:
516 conf
.DEFINE('WITH_AUTOMOUNT', '1')
519 if Options
.options
.with_ldap
:
520 conf
.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
521 conf
.CHECK_TYPE('ber_tag_t', 'unsigned int', headers
='ldap.h lber.h')
522 conf
.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
523 conf
.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers
='ldap.h')
525 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
527 conf
.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
528 define
='HAVE_LBER_LOG_PRINT_FN', headers
='lber.h')
530 conf
.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
531 conf
.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
533 # Check if ldap_set_rebind_proc() takes three arguments
534 if conf
.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
535 'LDAP_SET_REBIND_PROC_ARGS',
536 msg
="Checking whether ldap_set_rebind_proc takes 3 arguments",
537 headers
='ldap.h lber.h', link
=False):
538 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
540 conf
.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
542 # last but not least, if ldap_init() exists, we want to use ldap
543 if conf
.CONFIG_SET('HAVE_LDAP_INIT'):
544 conf
.DEFINE('HAVE_LDAP', '1')
545 conf
.DEFINE('LDAP_DEPRECATED', '1')
546 conf
.env
['HAVE_LDAP'] = '1'
547 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
548 # SASL wrapping hooks
549 if conf
.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
550 conf
.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
551 conf
.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
553 conf
.SET_TARGET_TYPE('ldap', 'EMPTY')
554 conf
.SET_TARGET_TYPE('lber', 'EMPTY')
556 if Options
.options
.with_ads
:
558 if not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
559 not conf
.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
560 Logs
.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
562 if not conf
.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
563 Logs
.warn("krb5_mk_req_extended not found in -lkrb5")
565 if not conf
.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
566 Logs
.warn("krb5_get_host_realm not found in -lkrb5")
568 if not conf
.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
569 Logs
.warn("krb5_free_host_realm not found in -lkrb5")
571 if not conf
.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
572 Logs
.warn("krb5_fwd_tgt_creds found in -lkrb5")
574 if not conf
.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
575 Logs
.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
577 if not conf
.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
578 Logs
.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
580 if not conf
.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
581 Logs
.warn("krb5_get_renewed_creds not found in -lkrb5")
583 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
584 Logs
.warn("krb5_principal_compare_any_realm not found in -lkrb5")
586 if not conf
.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
587 not conf
.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
588 Logs
.warn("krb5_c_string_to_key not found in -lkrb5")
590 if not conf
.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
591 not conf
.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
592 Logs
.warn("no CREATE_KEY_FUNCTIONS detected")
594 if not conf
.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
595 not conf
.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
596 Logs
.warn("no GET_ENCTYPES_FUNCTIONS detected")
598 if not conf
.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
599 not conf
.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
600 Logs
.warn("no KT_FREE_FUNCTION detected")
602 if not conf
.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
603 Logs
.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
606 # We don't actually use
607 # gsskrb5_extract_authz_data_from_sec_context, but it is a
608 # clue that this Heimdal, which does the PAC processing we
609 # need on the standard gss_inquire_sec_context_by_oid
610 if not conf
.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
611 not (conf
.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
612 conf
.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
613 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")
616 if not conf
.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
617 Logs
.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
621 conf
.DEFINE('WITH_ADS', '1')
622 conf
.DEFINE('HAVE_KRB5', '1')
623 if conf
.CONFIG_SET('HAVE_LDAP'):
624 conf
.env
['HAVE_ADS'] = '1'
626 Logs
.warn("krb5 libs don't have all features required for Active Directory support")
627 conf
.undefine('HAVE_KRB5_H')
628 conf
.undefine('HAVE_GSSAPI_H')
629 conf
.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
630 conf
.undefine('HAVE_GSSAPI_GSSAPI_H')
632 if Options
.options
.with_utmp
:
633 conf
.env
.with_utmp
= True
634 if not conf
.CHECK_HEADERS('utmp.h'): conf
.env
.with_utmp
= False
635 conf
.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
636 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers
='utmp.h',
637 define
='HAVE_UT_UT_NAME')
638 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers
='utmp.h',
639 define
='HAVE_UT_UT_USER')
640 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers
='utmp.h',
641 define
='HAVE_UT_UT_ID')
642 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers
='utmp.h',
643 define
='HAVE_UT_UT_HOST')
644 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers
='utmp.h',
645 define
='HAVE_UT_UT_TIME')
646 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers
='utmp.h',
647 define
='HAVE_UT_UT_TV')
648 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers
='utmp.h',
649 define
='HAVE_UT_UT_TYPE')
650 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers
='utmp.h',
651 define
='HAVE_UT_UT_PID')
652 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers
='utmp.h',
653 define
='HAVE_UT_UT_EXIT')
654 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers
='utmp.h',
655 define
='HAVE_UT_UT_ADDR_V6')
656 conf
.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers
='utmp.h',
657 define
='HAVE_UT_UT_ADDR')
658 conf
.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers
='utmpx.h',
659 define
='HAVE_UX_UT_SYSLEN')
660 conf
.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
661 'PUTUTLINE_RETURNS_UTMP', headers
='utmp.h',
662 msg
="Checking whether pututline returns pointer")
663 if conf
.env
.with_utmp
:
664 conf
.DEFINE('WITH_UTMP', 1)
666 if Options
.options
.with_avahi
:
667 conf
.env
.with_avahi
= True
668 if not conf
.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf
.env
.with_avahi
= False
669 if not conf
.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf
.env
.with_avahi
= False
670 if not conf
.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf
.env
.with_avahi
= False
671 if conf
.env
.with_avahi
:
672 conf
.DEFINE('WITH_AVAHI_SUPPORT', 1)
674 conf
.SET_TARGET_TYPE('avahi-common', 'EMPTY')
675 conf
.SET_TARGET_TYPE('avahi-client', 'EMPTY')
677 if Options
.options
.with_iconv
:
678 conf
.env
.with_iconv
= True
679 if not conf
.CHECK_FUNCS_IN('iconv_open', 'iconv', headers
='iconv.h'):
680 conf
.env
.with_iconv
= False
681 if conf
.env
.with_iconv
:
682 conf
.DEFINE('HAVE_ICONV', 1)
684 if Options
.options
.with_pam
:
686 conf
.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
687 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
688 Logs
.warn("--with-pam=yes but pam_appl.h not found")
690 conf
.CHECK_FUNCS_IN('pam_get_data', 'pam')
691 conf
.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
692 if not conf
.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf
.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
693 Logs
.warn("--with-pam=yes but pam_modules.h not found")
695 conf
.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
696 conf
.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
697 conf
.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
699 #if defined(HAVE_SECURITY_PAM_APPL_H)
700 #include <security/pam_appl.h>
701 #elif defined(HAVE_PAM_PAM_APPL_H)
702 #include <pam/pam_appl.h>
704 pam_set_item(0, PAM_RHOST, 0);
708 msg
="Checking whether PAM_RHOST is available");
710 #if defined(HAVE_SECURITY_PAM_APPL_H)
711 #include <security/pam_appl.h>
712 #elif defined(HAVE_PAM_PAM_APPL_H)
713 #include <pam/pam_appl.h>
715 pam_set_item(0, PAM_TTY, 0);
719 msg
="Checking whether PAM_TTY is available");
721 #if (!defined(LINUX))
723 #define PAM_EXTERN extern
724 #if defined(HAVE_SECURITY_PAM_APPL_H)
725 #include <security/pam_appl.h>
726 #elif defined(HAVE_PAM_PAM_APPL_H)
727 #include <pam/pam_appl.h>
732 #if defined(HAVE_SECURITY_PAM_MODULES_H)
733 #include <security/pam_modules.h>
734 #elif defined(HAVE_PAM_PAM_MODULES_H)
735 #include <pam/pam_modules.h>
738 #if defined(HAVE_SECURITY__PAM_MACROS_H)
739 #include <security/_pam_macros.h>
740 #elif defined(HAVE_PAM__PAM_MACROS_H)
741 #include <pam/_pam_macros.h>
744 #ifdef HAVE_SECURITY_PAM_EXT_H
745 #include <security/pam_ext.h>
748 int i; i = PAM_RADIO_TYPE;
750 'HAVE_PAM_RADIO_TYPE',
752 msg
="Checking whether PAM_RADIO_TYPE is available");
754 conf
.DEFINE('WITH_PAM', 1)
755 conf
.DEFINE('WITH_PAM_MODULES', 1)
760 # Ensure we select the correct set of system calls on Linux.
762 if (host_os
.rfind('linux') > -1):
764 #if defined(HAVE_UNISTD_H)
769 #include <sys/types.h>
772 #ifdef HAVE_SYS_PRIV_H
773 #include <sys/priv.h>
779 #if defined(HAVE_SYSCALL_H)
783 #if defined(HAVE_SYS_SYSCALL_H)
784 #include <sys/syscall.h>
787 syscall(SYS_setresuid32, -1, -1, -1);
788 syscall(SYS_setresgid32, -1, -1, -1);
789 syscall(SYS_setreuid32, -1, -1);
790 syscall(SYS_setregid32, -1, -1);
791 syscall(SYS_setuid32, -1);
792 syscall(SYS_setgid32, -1);
793 syscall(SYS_setgroups32, 0, NULL);
795 'USE_LINUX_32BIT_SYSCALLS',
796 msg
="Checking whether Linux should use 32-bit credential calls");
798 if (conf
.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
799 seteuid
= conf
.CHECK_CODE('''
800 #define AUTOCONF_TEST 1
801 #define USE_LINUX_THREAD_CREDENTIALS 1
802 #define USE_LINUX_32BIT_SYSCALLS 1
803 #include "../lib/util/setid.c"
804 #include "./lib/util_sec.c"
806 'USE_LINUX_THREAD_CREDENTIALS',
809 msg
="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
811 seteuid
= conf
.CHECK_CODE('''
812 #define AUTOCONF_TEST 1
813 #define USE_LINUX_THREAD_CREDENTIALS 1
814 #include "../lib/util/setid.c"
815 #include "./lib/util_sec.c"
817 'USE_LINUX_THREAD_CREDENTIALS',
820 msg
="Checking whether we can use Linux thread-specific credentials")
822 seteuid
= conf
.CHECK_CODE('''
823 #define AUTOCONF_TEST 1
824 #define USE_SETREUID 1
825 #include "../lib/util/setid.c"
826 #include "./lib/util_sec.c"
831 msg
="Checking whether setreuid is available")
833 seteuid
= conf
.CHECK_CODE('''
834 #define AUTOCONF_TEST 1
835 #define USE_SETRESUID 1
836 #include "../lib/util/setid.c"
837 #include "./lib/util_sec.c"
842 msg
="Checking whether setresuid is available")
844 seteuid
= conf
.CHECK_CODE('''
845 #define AUTOCONF_TEST 1
846 #define USE_SETEUID 1
847 #include "../lib/util/setid.c"
848 #include "./lib/util_sec.c"
853 msg
="Checking whether seteuid is available")
855 seteuid
= conf
.CHECK_CODE('''
856 #define AUTOCONF_TEST 1
857 #define USE_SETUIDX 1
858 #include "../lib/util/setid.c"
859 #include "./lib/util_sec.c"
865 msg
="Checking whether setuidx is available")
866 if Options
.options
.with_dnsupdate
:
867 if not conf
.CONFIG_SET('HAVE_KRB5'):
868 Logs
.warn("--with-dnsupdate=yes but gssapi support not sufficient")
870 conf
.DEFINE('WITH_DNS_UPDATES', 1)
871 conf
.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
872 if Options
.options
.developer
:
873 if conf
.CONFIG_SET('HAVE_VALGRIND_H') or conf
.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
874 conf
.DEFINE('VALGRIND', '1')
876 if conf
.CHECK_CODE('''
877 #include <bits/sockaddr.h>
878 #include <linux/netlink.h>
880 'HAVE_LINUX_NETLINK_H',
881 msg
="Checking whether Linux netlink is available"):
884 #include <bits/sockaddr.h>
885 #include <linux/netlink.h>
886 #include <linux/rtnetlink.h>
888 'HAVE_LINUX_RTNETLINK_H',
889 msg
='Checking whether Linux rtnetlink is available')
892 #include "../tests/fcntl_lock.c"
897 msg
='Checking whether fcntl locking is available')
899 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
900 if not conf
.CHECK_CODE('''
901 #define _XOPEN_SOURCE 600
903 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
904 #error probably broken posix_fallocate
907 '_HAVE_UNBROKEN_POSIX_FALLOCATE',
908 msg
='Checking for broken posix_fallocate'):
909 conf
.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
912 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
913 define
='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
914 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
915 define
='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
916 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
917 define
='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
918 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
919 define
='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
920 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
921 define
='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
922 if conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
923 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
924 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
925 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
926 conf
.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
927 conf
.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
929 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
930 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
931 define
='HAVE_STRUCT_STAT_ST_BIRTHTIME')
932 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
933 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
934 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
935 define
='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
938 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
940 'HAVE_POSIX_FADVISE',
941 msg
='Checking whether posix_fadvise is available',
942 headers
='unistd.h fcntl.h')
944 for v
in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
947 return sysconf(%s) == -1 ? 1 : 0;
950 msg
='Checking whether sysconf(%s) is available' % v
)
953 #include <sys/syscall.h>
955 syscall(SYS_initgroups, 16, NULL, NULL, 0);
957 'HAVE_DARWIN_INITGROUPS',
958 msg
='Checking whether to use the Darwin-specific initgroups system call')
960 conf
.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
962 headers
='sys/types.h utime.h',
963 msg
='Checking whether struct utimbuf is available')
965 if conf
.CHECK_CODE('''struct sigevent s;''',
966 'HAVE_STRUCT_SIGEVENT',
967 headers
='sys/types.h stdlib.h stddef.h signal.h',
968 msg
='Checking whether we have the struct sigevent'):
969 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
970 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
972 conf
.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
973 define
='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
976 if os
.path
.exists('/proc/sys/kernel/core_pattern'):
977 conf
.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
979 if conf
.CHECK_CODE('''
983 if (sizeof(time_t) == 8) {
984 time_t max_time = 0x7fffffffffffffffll;
985 tm = gmtime(&max_time);
986 /* This should fail with 32-bit tm_year. */
988 /* Max time_t that works with 32-bit int tm_year in struct tm. */
989 max_time = 67768036191676799ll;
990 tm = gmtime(&max_time);
1001 msg
="Checking for the maximum value of the 'time_t' type"):
1002 conf
.DEFINE('TIME_T_MAX', '67768036191676799ll')
1005 #if defined(HAVE_UNISTD_H)
1008 #include <sys/types.h>
1009 main() { dev_t dev = makedev(1,2); return 0; }
1013 msg
='Checking whether the macro for makedev is available')
1020 void exit_on_core(int ignored) {
1026 signal(SIGSEGV, exit_on_core);
1027 newpath = realpath("/tmp", NULL);
1028 exit((newpath != NULL) ? 0 : 1);
1031 'REALPATH_TAKES_NULL',
1034 msg
='Checking whether the realpath function allows a NULL argument')
1036 conf
.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1037 'HAVE_FTRUNCATE_EXTEND',
1038 msg
='Checking for ftruncate extend',
1042 if Options
.options
.with_sendfile_support
:
1043 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):
1048 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1051 headers
='sys/sendfile.h',
1052 msg
='Checking for linux sendfile support')
1054 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1055 conf
.DEFINE('HAVE_SENDFILE', '1')
1056 conf
.DEFINE('LINUX_SENDFILE_API', '1')
1057 conf
.DEFINE('WITH_SENDFILE', '1')
1058 elif (host_os
.rfind('freebsd') > -1) or (host_os
.rfind('dragonfly') > -1):
1060 #include <sys/types.h>
1062 #include <sys/socket.h>
1063 #include <sys/uio.h>
1064 int fromfd, tofd, ret, total=0;
1065 off_t offset, nwritten;
1068 hdr.headers = &hdtrl;
1070 hdr.trailers = NULL;
1072 hdtrl.iov_base = NULL;
1074 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1077 msg
='Checking for freebsd sendfile support')
1078 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1079 conf
.DEFINE('HAVE_SENDFILE', '1')
1080 conf
.DEFINE('FREEBSD_SENDFILE_API', '1')
1081 conf
.DEFINE('WITH_SENDFILE', '1')
1082 elif (host_os
.rfind('darwin') > -1):
1084 #include <sys/types.h>
1085 #include <sys/socket.h>
1086 #include <sys/uio.h>
1087 int fromfd, tofd, ret;
1088 off_t offset, nwritten;
1091 hdr.headers = &hdtrl;
1093 hdr.trailers = (void *)0;
1095 hdtrl.iov_base = (void *)0;
1097 ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1100 msg
='Checking for darwin sendfile support')
1101 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1102 conf
.DEFINE('HAVE_SENDFILE', '1')
1103 conf
.DEFINE('DARWIN_SENDFILE_API', '1')
1104 conf
.DEFINE('WITH_SENDFILE', '1')
1105 elif (host_os
.rfind('hpux') > -1) or (host_os
.rfind('osf') > -1):
1107 #include <sys/socket.h>
1108 #include <sys/uio.h>
1111 struct iovec hdtrl[2];
1114 hdtrl[0].iov_base = 0;
1115 hdtrl[0].iov_len = 0;
1116 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1119 msg
='Checking for osf/hpux sendfile support')
1120 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1121 conf
.DEFINE('HAVE_SENDFILE', '1')
1122 conf
.DEFINE('HPUX_SENDFILE_API', '1')
1123 conf
.DEFINE('WITH_SENDFILE', '1')
1124 elif (host_os
.rfind('solaris') > -1):
1125 conf
.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1127 #include <sys/sendfile.h>,
1130 struct sendfilevec vec[2];
1134 vec[0].sfv_fd = SFV_FD_SELF;
1135 vec[0].sfv_flag = 0;
1139 vec[1].sfv_flag = 0;
1142 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1145 msg
='Checking for solaris sendfilev support')
1146 if conf
.CONFIG_SET('_HAVE_SENDFILEV'):
1147 conf
.DEFINE('HAVE_SENDFILEV', '1')
1148 conf
.DEFINE('SOLARIS_SENDFILE_API', '1')
1149 conf
.DEFINE('WITH_SENDFILE', '1')
1150 elif (host_os
.rfind('aix') > -1):
1152 #include <sys/socket.h>
1155 struct sf_parms hdtrl;
1157 hdtrl.header_data = 0;
1158 hdtrl.header_length = 0;
1159 hdtrl.file_descriptor = fromfd;
1160 hdtrl.file_offset = 0;
1161 hdtrl.file_bytes = 0;
1162 hdtrl.trailer_data = 0;
1163 hdtrl.trailer_length = 0;
1164 nwritten = send_file(&tofd, &hdtrl, 0);
1167 msg
='Checking for AIX send_file support')
1168 if conf
.CONFIG_SET('_HAVE_SENDFILE'):
1169 conf
.DEFINE('HAVE_SENDFILE', '1')
1170 conf
.DEFINE('AIX_SENDFILE_API', '1')
1171 conf
.DEFINE('WITH_SENDFILE', '1')
1173 # Check for getcwd allowing a NULL arg.
1177 char *s = getcwd(NULL,0);
1178 exit(s != NULL ? 0 : 1);
1179 }''', 'GETCWD_TAKES_NULL', addmain
=False, execute
=True,
1180 msg
="getcwd takes a NULL argument")
1183 # UnixWare 7.x has its getspnam in -lgen
1184 conf
.CHECK_FUNCS_IN('getspnam', 'gen')
1185 conf
.CHECK_FUNCS_IN('getspnam', 'security')
1186 conf
.CHECK_FUNCS_IN('getspnam', 'sec')
1188 if Options
.options
.with_quotas
:
1189 # For quotas on Veritas VxFS filesystems
1190 conf
.CHECK_HEADERS('sys/fs/vx_quota.h')
1191 # For sys/quota.h and linux/quota.h
1192 conf
.CHECK_HEADERS('sys/quota.h')
1193 # For quotas on BSD systems
1194 conf
.CHECK_HEADERS('ufs/ufs/quota.h')
1195 # For quotas on Linux XFS filesystems
1196 if conf
.CHECK_HEADERS('xfs/xqm.h'):
1197 conf
.DEFINE('HAVE_XFS_QUOTAS', '1')
1201 #include "confdefs.h"
1202 #ifdef HAVE_SYS_TYPES_H
1203 #include <sys/types.h>
1205 #ifdef HAVE_ASM_TYPES_H
1206 #include <asm/types.h>
1208 #include <sys/quota.h>
1209 int i = Q_XGETQUOTA;''',
1210 define
='HAVE_XFS_QUOTAS',
1211 msg
='for XFS QUOTA in <sys/quota.h>',
1213 local_include
=False)
1215 # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
1216 conf
.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define
='HAVE_DQB_FSOFTLIMIT',
1217 headers
='sys/quota.h')
1219 if conf
.CHECK_HEADERS('rpcsvc/rquota.h'):
1220 conf
.DEFINE('HAVE_NFS_QUOTAS', '1')
1221 conf
.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1222 define
='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1223 headers
='rpcsvc/rquota.h')
1225 if (host_os
.rfind('linux') > -1):
1226 conf
.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1228 if conf
.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1229 conf
.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1230 conf
.CONFIG_SET('HAVE_QUOTACTL_4B'):
1231 conf
.DEFINE('HAVE_SYS_QUOTAS', '1')
1234 # checking for clustering extensions (CTDB)
1236 if not Options
.options
.with_cluster_support
:
1237 have_cluster_support
= False
1241 if Options
.options
.ctdb_dir
:
1242 conf
.ADD_EXTRA_INCLUDES(Options
.options
.ctdb_dir
+ '/include')
1244 srcdir
= os
.path
.realpath(conf
.srcdir
)
1245 if 'EXTRA_INCLUDES' in conf
.env
:
1246 includes
= ' '.join(conf
.env
['EXTRA_INCLUDES']).replace('#', srcdir
+ '/')
1250 have_cluster_support
= True
1255 #include "replace.h"
1256 #include "system/wait.h"
1257 #include "system/network.h"
1258 #define private #error __USED_RESERVED_WORD_private__
1271 msg
='Checking for header ctdb.h')
1273 if not conf
.CONFIG_SET('HAVE_CTDB_H'):
1274 have_cluster_support
= False
1275 ctdb_broken
= "ctdb.h is required for cluster support"
1277 if have_cluster_support
:
1280 #include "replace.h"
1281 #include "system/wait.h"
1282 #include "system/network.h"
1283 #define private #error __USED_RESERVED_WORD_private__
1287 #include <ctdb_private.h>
1294 'HAVE_CTDB_PRIVATE_H',
1297 msg
='Checking for header ctdb_private.h')
1299 if not conf
.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
1300 have_cluster_support
= False
1301 ctdb_broken
= "ctdb_private.h is required for cluster support"
1303 if have_cluster_support
:
1306 #include "replace.h"
1307 #include "system/wait.h"
1308 #include "system/network.h"
1312 #include <ctdb_private.h>
1316 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1320 'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
1323 msg
='Checking for transaction support (TRANS3_COMMIT control)')
1325 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
1326 have_cluster_support
= False
1327 ctdb_broken
= "ctdb transaction support missing or too old"
1329 if have_cluster_support
:
1332 #include "replace.h"
1333 #include "system/wait.h"
1334 #include "system/network.h"
1338 #include <ctdb_private.h>
1342 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1346 'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
1349 msg
='Checking for SCHEDULE_FOR_DELETION control')
1351 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
1352 if not Options
.options
.enable_old_ctdb
:
1353 have_cluster_support
= False
1354 ctdb_broken
= "SCHEDULE_FOR_DELETION control missing"
1356 Logs
.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1358 if have_cluster_support
:
1361 #include "replace.h"
1362 #include "system/wait.h"
1363 #include "system/network.h"
1367 #include <ctdb_private.h>
1371 struct ctdb_control_tcp _x;
1375 'HAVE_STRUCT_CTDB_CONTROL_TCP',
1378 msg
='Checking for ctdb ipv4 support')
1380 if not conf
.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
1381 have_cluster_support
= False
1382 ctdb_broken
= "missing struct ctdb_control_tcp"
1384 if have_cluster_support
:
1387 #include "replace.h"
1388 #include "system/wait.h"
1389 #include "system/network.h"
1393 #include <ctdb_private.h>
1397 struct ctdb_control_tcp_addr _x;
1401 'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
1404 msg
='Checking for ctdb ipv6 support')
1406 if have_cluster_support
:
1409 #include "replace.h"
1410 #include "system/wait.h"
1411 #include "system/network.h"
1415 #include <ctdb_private.h>
1419 int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1423 'HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL',
1426 msg
='Checking for CHECK_SRVIDS control')
1428 if not conf
.CONFIG_SET('HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL'):
1429 if not Options
.options
.enable_old_ctdb
:
1430 have_cluster_support
= False
1431 ctdb_broken
= "CHECK_SRVIDS control missing"
1433 Logs
.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1435 if have_cluster_support
:
1436 Logs
.info("building with cluster support")
1437 conf
.DEFINE('CLUSTER_SUPPORT', 1);
1439 if not Options
.options
.with_cluster_support
:
1440 Logs
.info("building without cluster support")
1442 Logs
.warn("building without cluster support: " + ctdb_broken
)
1443 conf
.undefine('CLUSTER_SUPPORT')
1447 conf
.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1448 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1451 msg
='Checking whether we can compile with __attribute__((destructor))')
1453 conf
.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1454 'SEEKDIR_RETURNS_VOID',
1455 headers
='sys/types.h dirent.h',
1456 msg
='Checking whether seekdir returns void')
1458 if Options
.options
.with_profiling_data
:
1459 conf
.DEFINE('WITH_PROFILE', 1);
1461 PTHREAD_CFLAGS
='error'
1462 PTHREAD_LDFLAGS
='error'
1464 if PTHREAD_LDFLAGS
== 'error':
1465 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
1466 PTHREAD_CFLAGS
='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
1467 PTHREAD_LDFLAGS
='-lpthread'
1468 if PTHREAD_LDFLAGS
== 'error':
1469 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
1470 PTHREAD_CFLAGS
='-D_THREAD_SAFE'
1471 PTHREAD_LDFLAGS
='-lpthreads'
1472 if PTHREAD_LDFLAGS
== 'error':
1473 if conf
.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
1474 PTHREAD_CFLAGS
='-D_THREAD_SAFE -pthread'
1475 PTHREAD_LDFLAGS
='-pthread'
1476 if PTHREAD_LDFLAGS
== 'error':
1477 if conf
.CHECK_FUNCS('pthread_attr_init'):
1478 PTHREAD_CFLAGS
='-D_REENTRANT'
1479 PTHREAD_LDFLAGS
='-lpthread'
1480 # especially for HP-UX, where the CHECK_FUNC macro fails to test for
1481 # pthread_attr_init. On pthread_mutex_lock it works there...
1482 if PTHREAD_LDFLAGS
== 'error':
1483 if conf
.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
1484 PTHREAD_CFLAGS
='-D_REENTRANT'
1485 PTHREAD_LDFLAGS
='-lpthread'
1487 if PTHREAD_CFLAGS
!= 'error' and PTHREAD_LDFLAGS
!= 'error':
1488 conf
.ADD_CFLAGS(PTHREAD_CFLAGS
)
1489 conf
.ADD_LDFLAGS(PTHREAD_LDFLAGS
)
1490 conf
.CHECK_HEADERS('pthread.h')
1491 conf
.DEFINE('HAVE_PTHREAD', '1')
1493 if Options
.options
.with_pthreadpool
:
1494 if conf
.CONFIG_SET('HAVE_PTHREAD'):
1495 conf
.DEFINE('WITH_PTHREADPOOL', '1')
1497 Logs
.warn("pthreadpool support cannot be enabled when pthread support was not found")
1498 conf
.undefine('WITH_PTHREADPOOL')
1500 if conf
.CHECK_HEADERS('gpfs_gpl.h'):
1501 conf
.DEFINE('HAVE_GPFS', '1')
1503 default_static_modules
.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1504 auth_sam auth_unix auth_winbind auth_wbc
1505 auth_domain auth_builtin vfs_default
1506 nss_info_template idmap_tdb idmap_passdb
1509 default_shared_modules
.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1510 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1511 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1512 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1513 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1514 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1516 vfs_crossrename vfs_linux_xfs_sgid
1517 vfs_time_audit idmap_autorid idmap_tdb2
1518 idmap_rid idmap_hash'''))
1520 if Options
.options
.developer
:
1521 default_static_modules
.extend(TO_LIST('charset_weird'))
1522 default_shared_modules
.extend(TO_LIST('perfcount_test'))
1523 default_shared_modules
.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1524 default_shared_modules
.extend(TO_LIST('auth_skel pdb_test'))
1526 if Options
.options
.enable_selftest
or Options
.options
.developer
:
1527 default_shared_modules
.extend(TO_LIST('vfs_fake_acls'))
1530 if conf
.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1531 default_static_modules
.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
1533 if conf
.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1534 default_shared_modules
.extend(TO_LIST('vfs_zfsacl'))
1536 if conf
.CONFIG_SET('HAVE_DIRFD_DECL'):
1537 default_shared_modules
.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1539 if conf
.CONFIG_SET('HAVE_STATFS_F_FSID'):
1540 default_shared_modules
.extend(TO_LIST('vfs_fileid'))
1542 if (conf
.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf
.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
1543 default_shared_modules
.extend(TO_LIST('vfs_aio_fork'))
1545 if Options
.options
.with_pthreadpool
:
1546 default_shared_modules
.extend(TO_LIST('vfs_aio_pthread'))
1548 if conf
.CONFIG_SET('HAVE_AIO'):
1549 default_shared_modules
.extend(TO_LIST('vfs_aio_posix'))
1551 if conf
.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1552 default_shared_modules
.extend(TO_LIST('vfs_aio_linux'))
1554 if conf
.CONFIG_SET('HAVE_LDAP'):
1555 default_static_modules
.extend(TO_LIST('pdb_ldap idmap_ldap'))
1557 if conf
.CONFIG_SET('DARWINOS'):
1558 default_static_modules
.extend(TO_LIST('charset_macosxfs'))
1560 if conf
.CONFIG_SET('HAVE_GPFS'):
1561 default_shared_modules
.extend(TO_LIST('vfs_gpfs'))
1563 explicit_shared_modules
= TO_LIST(Options
.options
.shared_modules
, delimiter
=',')
1564 explicit_static_modules
= TO_LIST(Options
.options
.static_modules
, delimiter
=',')
1566 final_static_modules
= default_static_modules
1567 final_shared_modules
= default_shared_modules
1569 for m
in explicit_static_modules
:
1570 if m
in final_shared_modules
:
1571 final_shared_modules
.remove(m
)
1572 final_static_modules
.append(m
)
1573 for m
in explicit_shared_modules
:
1574 if m
in final_static_modules
:
1575 final_static_modules
.remove(m
)
1576 final_shared_modules
.append(m
)
1578 conf
.env
['static_modules'] = final_static_modules
1579 conf
.env
['shared_modules'] = final_shared_modules
1581 conf
.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules
), quote
=True)
1586 prefixes
= ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1587 conf
.env
['MODULE_PREFIXES'] = prefixes
1589 for m
in final_static_modules
:
1591 if not p
in static_list
:
1593 static_list
[p
].append(m
)
1594 for m
in final_shared_modules
:
1596 if not p
in shared_list
:
1598 shared_list
[p
].append(m
)
1601 static_env
= "%s_STATIC" % p
.upper()
1602 shared_env
= "%s_SHARED" % p
.upper()
1603 conf
.env
[static_env
] = []
1604 conf
.env
[shared_env
] = []
1605 if p
in static_list
:
1607 for entry
in static_list
[p
]:
1608 decl_list
+= "extern NTSTATUS %s_init(void); " % entry
1609 conf
.env
[static_env
].append('%s' % entry
)
1610 decl_list
= decl_list
.rstrip()
1611 conf
.DEFINE('static_decl_%s' % p
, decl_list
)
1612 conf
.DEFINE('static_init_%s' % p
, '{ %s_init(); }' % '_init(); '.join(static_list
[p
]))
1614 conf
.DEFINE('static_decl_%s' % p
, '')
1615 conf
.DEFINE('static_init_%s' % p
, '{}')
1616 if p
in shared_list
:
1617 for entry
in shared_list
[p
]:
1618 conf
.DEFINE('%s_init' % entry
, 'samba_init_module')
1619 conf
.env
[shared_env
].append('%s' % entry
)
1621 conf
.SAMBA_CONFIG_H('include/config.h')
1624 "build 'tags' file using ctags"
1626 source_root
= os
.path
.dirname(Utils
.g_module
.root_path
)
1627 cmd
= 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1628 print("Running: %s" % cmd
)