build(waf): check if we have ctdb_protocol.h in the cluster checks
[Samba/bjacke.git] / source3 / wscript
blob157a8c9d161a246b47c5e79ab15d31529fbccc3c
1 #! /usr/bin/env python
3 srcdir=".."
5 import sys, os
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
10 import build.charset
11 import samba_utils, samba_version
12 import samba3
14 Options.default_prefix = '/usr/local/samba'
16 def set_options(opt):
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('sendfile-support')
35 opt.SAMBA3_ADD_OPTION('utmp')
36 opt.SAMBA3_ADD_OPTION('pthreadpool', with_name="enable", without_name="disable", default=True)
37 opt.SAMBA3_ADD_OPTION('avahi', with_name="enable", without_name="disable")
38 opt.SAMBA3_ADD_OPTION('iconv')
39 opt.SAMBA3_ADD_OPTION('acl-support')
40 opt.SAMBA3_ADD_OPTION('dnsupdate')
41 opt.SAMBA3_ADD_OPTION('syslog')
42 opt.SAMBA3_ADD_OPTION('automount')
43 opt.SAMBA3_ADD_OPTION('aio-support')
44 opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
46 opt.SAMBA3_ADD_OPTION('cluster-support')
48 opt.add_option('--with-ctdb-dir',
49 help=("Directory under which ctdb is installed"),
50 action="store", dest='ctdb_dir', default=None)
51 opt.add_option('--enable-old-ctdb',
52 help=("enable building against (too) old version of ctdb (default=false)"),
53 action="store_true", dest='enable_old_ctdb', default=False)
57 def configure(conf):
58 from samba_utils import TO_LIST
60 default_static_modules = []
61 default_shared_modules = []
63 if Options.options.developer:
64 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
65 conf.env.developer = True
67 if Options.options.with_swat:
68 conf.env['build_swat'] = True
70 if sys.platform != 'openbsd5':
71 conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
73 conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
74 conf.CHECK_HEADERS('linux/falloc.h')
76 conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
77 conf.CHECK_FUNCS('strtol strchr strupr chflags')
78 conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
79 conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
80 conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
81 conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
82 conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
83 conf.CHECK_FUNCS('atexit grantpt fallocate posix_fallocate')
84 conf.CHECK_FUNCS('fseeko setluid')
85 conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
86 conf.CHECK_FUNCS('fdopendir')
87 conf.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
88 conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
89 conf.CHECK_FUNCS_IN('nanosleep', 'rt')
90 conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
91 conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
92 conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
93 conf.CHECK_FUNCS('shmget')
94 conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
95 conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain bind_textdomain_codeset')
96 #FIXME: for some reason this one still fails
97 conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
98 conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
99 conf.CHECK_FUNCS_IN('dn_expand', 'inet')
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)
108 #include <unistd.h>
109 #endif
110 long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
111 ''',
112 'HAVE_LINUX_SPLICE',
113 headers='fcntl.h'):
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
122 conf.CHECK_CODE('''
123 #ifndef F_NOTIFY
124 #define F_NOTIFY 1026
125 #endif
126 main() {
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
133 conf.CHECK_CODE('''
134 #include <sys/types.h>
135 #include <fcntl.h>
136 #include <signal.h>
137 #ifndef F_NOTIFY
138 #define F_NOTIFY 1026
139 #endif
140 main() {
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
151 conf.CHECK_CODE('''
152 #include <sys/types.h>
153 #include <fcntl.h>
154 #include <signal.h>
155 #include <sys/file.h>
156 #ifndef LOCK_MAND
157 #define LOCK_MAND 32
158 #define LOCK_READ 64
159 #endif
160 main() {
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:
174 conf.CHECK_CODE('''
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:
181 conf.CHECK_CODE('''
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:
191 conf.CHECK_CODE('''
192 cap_t cap;
193 cap_value_t vals[1];
194 if (!(cap = cap_get_proc())) exit(1);
195 vals[0] = CAP_CHOWN;
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.
204 # -- JRA.
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
223 conf.CHECK_CODE('''
224 if (0) {
225 this_function_does_not_exist();
226 } else {
227 return 1;
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
232 # AIX needs this
233 conf.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
234 headers='stdio.h',
235 msg="Checking for LL suffix on long long integers")
237 conf.CHECK_FUNCS('''
238 _acl __acl atexit
239 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
240 __closedir crypt16 devnm dgettext dirfd
241 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
242 _facl __facl _fchdir
243 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
244 _fork __fork fseeko
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
259 _seekdir __seekdir
260 select setenv setgidx setgroups setlocale setluid
261 setmntent setpgid setpriv setsid setuidx
262 shmget shm_open sigaction sigblock sigprocmask sigset
263 _stat __stat statvfs
264 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
265 __sys_llseek syslog _telldir __telldir textdomain timegm
266 utimensat vsyslog _write __write __xstat
267 ''')
269 conf.CHECK_CODE('''
270 #ifdef HAVE_SYS_PRCTL_H
271 #include <sys/prctl.h>
272 #endif
273 int i; i = prtcl(0);
274 ''',
275 'HAVE_PRCTL', link=False)
277 conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
279 # FIXME: these should be tests for features, but the old build system just
280 # checks for OSes.
281 host_os = sys.platform
282 Logs.info("building on %s" % host_os)
284 # Python doesn't have case switches... :/
285 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
286 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
288 conf.SET_TARGET_TYPE('sunacl', 'EMPTY')
289 if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('qnx') > -1):
290 if host_os.rfind('linux') > -1:
291 conf.DEFINE('LINUX', '1')
292 elif host_os.rfind('qnx') > -1:
293 conf.DEFINE('QNX', '1')
294 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
295 elif (host_os.rfind('darwin') > -1):
296 conf.DEFINE('DARWINOS', 1)
297 conf.ADD_CFLAGS('-fno-common')
298 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
299 elif (host_os.rfind('freebsd') > -1):
300 conf.DEFINE('FREEBSD', 1)
301 if conf.CHECK_HEADERS('sunacl.h'):
302 conf.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
303 conf.CHECK_FUNCS_IN('acl', 'sunacl')
304 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
305 elif (host_os.rfind('irix') > -1):
306 conf.DEFINE('IRIX', 1)
307 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
308 elif (host_os.rfind('aix') > -1):
309 conf.DEFINE('AIX', 1)
310 conf.DEFINE('STAT_ST_BLOCKSIZE', 'DEV_BSIZE')
311 elif (host_os.rfind('hpux') > -1):
312 conf.DEFINE('HPUX', 1)
313 conf.DEFINE('STAT_ST_BLOCKSIZE', '8192')
314 elif (host_os.rfind('osf') > -1):
315 conf.DEFINE('OSF1', 1)
316 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
318 # FIXME: Add more checks here.
319 else:
320 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
322 if Options.options.with_acl_support:
323 if (host_os.rfind('sysv5') > -1) and conf.CHECK_FUNCS_IN('sec', 'facl', checklibc=True):
324 Logs.info('Using UnixWare ACLs')
325 conf.DEFINE('HAVE_UNIXWARE_ACLS',1)
326 default_static_modules.extend(TO_LIST('vfs_solarisacl'))
327 elif (host_os.rfind('solaris') > -1) and conf.CHECK_FUNCS_IN('sec', 'facl'):
328 Logs.info('Using solaris ACLs')
329 conf.DEFINE('HAVE_SOLARIS_ACLS',1)
330 default_static_modules.extend(TO_LIST('vfs_solarisacl'))
331 elif (host_os.rfind('hpux') > -1):
332 Logs.info('Using HPUX ACLs')
333 conf.DEFINE('HAVE_HPUX_ACLS',1)
334 conf.DEFINE('POSIX_ACL_NEEDS_MASK',1)
335 default_static_modules.extend(TO_LIST('vfs_hpuxacl'))
336 elif (host_os.rfind('aix') > -1):
337 Logs.info('Using AIX ACLs')
338 conf.DEFINE('HAVE_AIX_ACLS',1)
339 default_static_modules.extend(TO_LIST('vfs_aixacl'))
340 elif (host_os.rfind('osf') > -1) and conf.CHECK_FUNCS_IN('pacl', 'acl_get_fd'):
341 Logs.info('Using Tru64 ACLs')
342 conf.DEFINE('HAVE_TRU64_ACLS',1)
343 default_static_modules.extend(TO_LIST('vfs_tru64acl'))
344 elif (host_os.rfind('darwin') > -1):
345 Logs.warn('ACLs on Dwarwin currently not supported')
346 else:
347 conf.CHECK_FUNCS_IN('acl_get_file', 'acl')
348 if conf.CHECK_CODE('''
349 acl_t acl;
350 int entry_id;
351 acl_entry_t *entry_p;
352 return acl_get_entry(acl, entry_id, entry_p);
353 ''',
354 'HAVE_POSIX_ACLS',
355 headers='sys/types.h sys/acl.h', link=False,
356 msg="Checking for POSIX ACL support") :
357 conf.CHECK_CODE('''
358 acl_permset_t permset_d;
359 acl_perm_t perm;
360 return acl_get_perm_np(permset_d, perm);
361 ''',
362 'HAVE_ACL_GET_PERM_NP',
363 headers='sys/types.h sys/acl.h', link=True,
364 msg="Checking whether acl_get_perm_np() is available")
365 default_static_modules.extend(TO_LIST('vfs_posixacl'))
368 if conf.CHECK_FUNCS('dirfd'):
369 conf.DEFINE('HAVE_DIRFD_DECL', 1)
371 conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
372 'HAVE_STATFS_F_FSID',
373 msg="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
374 headers='sys/types.h sys/statfs.h',
375 execute=True)
377 if conf.CONFIG_SET('HAVE_FALLOCATE'):
378 conf.CHECK_CODE('''
379 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
380 'HAVE_LINUX_FALLOCATE',
381 msg="Checking whether the Linux 'fallocate' function is available",
382 headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
383 conf.CHECK_CODE('''
384 ssize_t err = readahead(0,0,0x80000);''',
385 'HAVE_LINUX_READAHEAD',
386 msg="Checking whether Linux readahead is available",
387 headers='unistd.h fcntl.h')
388 conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
390 conf.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
391 'HAVE_OPENAT',
392 msg='Checking for openat',
393 headers='fcntl.h')
395 if Options.options.with_aio_support:
396 conf.CHECK_FUNCS_IN('aio_read', 'aio')
397 conf.CHECK_FUNCS_IN('aio_read', 'rt')
398 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);',
399 'HAVE_AIO',
400 msg='Checking for asynchronous io support',
401 headers='sys/types.h aio.h',
402 lib='aio rt')
403 if conf.CONFIG_SET('HAVE_AIO'):
404 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg='Checking for aio_read', headers='aio.h', lib='aio rt')
405 conf.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg='Checking for aio_write', headers='aio.h', lib='aio rt')
406 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')
407 conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
408 conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
409 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')
410 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')
411 if not conf.CONFIG_SET('HAVE_AIO'):
412 conf.DEFINE('HAVE_NO_AIO', '1')
413 else:
414 conf.DEFINE('HAVE_NO_AIO', '1')
416 if host_os.rfind('linux') > -1:
417 conf.CHECK_FUNCS_IN('io_submit', 'aio')
418 conf.CHECK_CODE('''
419 struct io_event ioev;
420 struct iocb *ioc;
421 io_context_t ctx;
422 struct timespec ts;
423 int fd;
424 char *buf;
425 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
426 io_queue_init(128,&ctx);
427 io_prep_pwrite(ioc, 1, buf, 1, 0);
428 io_prep_pread(ioc, 1, buf, 1, 0);
429 io_set_eventfd(ioc, fd);
430 io_set_callback(ioc, (io_callback_t)(0));
431 io_submit(ctx, 1, &ioc);
432 io_getevents(ctx, 1, 1, &ioev, &ts);
433 ''',
434 'HAVE_LINUX_KERNEL_AIO',
435 msg='Checking for linux kernel asynchronous io support',
436 headers='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
437 lib='aio')
439 conf.CHECK_CODE('''
440 struct msghdr msg;
441 union {
442 struct cmsghdr cm;
443 char control[CMSG_SPACE(sizeof(int))];
444 } control_un;
445 msg.msg_control = control_un.control;
446 msg.msg_controllen = sizeof(control_un.control);
447 ''',
448 'HAVE_MSGHDR_MSG_CONTROL',
449 msg='Checking if we can use msg_control for passing file descriptors',
450 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
451 conf.CHECK_CODE('''
452 struct msghdr msg;
453 int fd;
454 msg.msg_acctrights = (caddr_t) &fd;
455 msg.msg_acctrightslen = sizeof(fd);
456 ''',
457 'HAVE_MSGHDR_MSG_ACCTRIGHTS',
458 msg='Checking if we can use msg_acctrights for passing file descriptors',
459 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
461 if Options.options.with_winbind:
462 conf.env.build_winbind = True
463 conf.DEFINE('WITH_WINBIND', '1')
465 conf.find_program('awk', var='AWK')
466 conf.find_program('perl', var='PERL')
468 conf.CHECK_HEADERS('asm/types.h')
470 conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
471 headers='unistd.h sys/types.h',
472 msg="Checking for major macro")
474 conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
475 headers='unistd.h sys/types.h',
476 msg="Checking for minor macro")
478 conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
479 headers='unistd.h sys/types.h dirent.h',
480 define='HAVE_DIRENT_D_OFF')
482 conf.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
483 if conf.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
484 netgrent_cflags = '-Werror-implicit-function-declaration'
485 else:
486 netgrent_cflags = ''
487 conf.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
488 msg="Checking for setnetgrent prototype",
489 headers='netdb.h netgroup.h',
490 cflags=netgrent_cflags)
491 conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
492 msg="Checking for getnetgrent prototype",
493 headers='netdb.h netgroup.h',
494 cflags=netgrent_cflags)
495 conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
496 msg="Checking for endnetgrent prototype",
497 headers='netdb.h netgroup.h',
498 cflags=netgrent_cflags)
501 # Look for CUPS
502 if Options.options.with_cups:
503 conf.find_program('cups-config', var='CUPS_CONFIG')
504 if conf.env.CUPS_CONFIG:
505 # we would normally use --libs here, but cups-config incorrectly adds
506 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
507 # of an in-tree heimdal kerberos
508 conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
509 package="", uselib_store="CUPS")
510 conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
511 conf.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
512 if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
513 conf.DEFINE('HAVE_CUPS', '1')
514 else:
515 conf.undefine('HAVE_CUPS')
516 conf.SET_TARGET_TYPE('cups', 'EMPTY')
517 else:
518 # define an empty subsystem for cups, to allow it to be used as an empty dependency
519 conf.SET_TARGET_TYPE('cups', 'EMPTY')
521 if Options.options.with_iprint:
522 if conf.CONFIG_SET('HAVE_CUPS'):
523 conf.DEFINE('HAVE_IPRINT', '1')
524 else:
525 Logs.warn("--enable-iprint=yes but cups support not sufficient")
526 if Options.options.with_syslog:
527 conf.DEFINE('WITH_SYSLOG', '1')
528 if Options.options.with_automount:
529 conf.DEFINE('WITH_AUTOMOUNT', '1')
531 # Check for LDAP
532 if Options.options.with_ldap:
533 conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
534 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
535 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
536 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
538 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
539 # for the samba logs
540 conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
541 define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
543 conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
544 conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
546 # Check if ldap_set_rebind_proc() takes three arguments
547 if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
548 'LDAP_SET_REBIND_PROC_ARGS',
549 msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
550 headers='ldap.h lber.h', link=False):
551 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
552 else:
553 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
555 # last but not least, if ldap_init() exists, we want to use ldap
556 if conf.CONFIG_SET('HAVE_LDAP_INIT') and conf.CONFIG_SET('HAVE_LDAP_H'):
557 conf.DEFINE('HAVE_LDAP', '1')
558 conf.DEFINE('LDAP_DEPRECATED', '1')
559 conf.env['HAVE_LDAP'] = '1'
560 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
561 # SASL wrapping hooks
562 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
563 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
564 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
565 else:
566 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
567 conf.SET_TARGET_TYPE('lber', 'EMPTY')
569 if Options.options.with_ads:
570 use_ads=True
571 if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
572 not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
573 Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
574 use_ads=False
575 if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
576 Logs.warn("krb5_mk_req_extended not found in -lkrb5")
577 use_ads=False
578 if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
579 Logs.warn("krb5_get_host_realm not found in -lkrb5")
580 use_ads=False
581 if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
582 Logs.warn("krb5_free_host_realm not found in -lkrb5")
583 use_ads=False
584 if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
585 Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
586 use_ads=False
587 if not conf.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
588 Logs.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
589 use_ads=False
590 if not conf.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
591 Logs.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
592 use_ads=False
593 if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
594 Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
595 use_ads=False
596 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
597 Logs.warn("krb5_principal_compare_any_realm not found in -lkrb5")
598 use_ads=False
599 if not conf.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
600 not conf.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
601 Logs.warn("krb5_c_string_to_key not found in -lkrb5")
602 use_ads=False
603 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
604 not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
605 Logs.warn("no CREATE_KEY_FUNCTIONS detected")
606 use_ads=False
607 if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
608 not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
609 Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
610 use_ads=False
611 if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
612 not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
613 Logs.warn("no KT_FREE_FUNCTION detected")
614 use_ads=False
615 if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
616 Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
617 use_ads=False
619 # We don't actually use
620 # gsskrb5_extract_authz_data_from_sec_context, but it is a
621 # clue that this Heimdal, which does the PAC processing we
622 # need on the standard gss_inquire_sec_context_by_oid
623 if not conf.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
624 not (conf.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
625 conf.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
626 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")
627 use_ads=False
629 if not conf.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
630 Logs.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
631 use_ads=False
633 if use_ads:
634 conf.DEFINE('WITH_ADS', '1')
635 conf.DEFINE('HAVE_KRB5', '1')
636 if conf.CONFIG_SET('HAVE_LDAP'):
637 conf.env['HAVE_ADS'] = '1'
638 else:
639 Logs.warn("krb5 libs don't have all features required for Active Directory support")
640 conf.undefine('HAVE_KRB5_H')
641 conf.undefine('HAVE_GSSAPI_H')
642 conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
643 conf.undefine('HAVE_GSSAPI_GSSAPI_H')
645 if Options.options.with_utmp:
646 conf.env.with_utmp = True
647 if not conf.CHECK_HEADERS('utmp.h'): conf.env.with_utmp = False
648 conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
649 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
650 define='HAVE_UT_UT_NAME')
651 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers='utmp.h',
652 define='HAVE_UT_UT_USER')
653 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers='utmp.h',
654 define='HAVE_UT_UT_ID')
655 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers='utmp.h',
656 define='HAVE_UT_UT_HOST')
657 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers='utmp.h',
658 define='HAVE_UT_UT_TIME')
659 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers='utmp.h',
660 define='HAVE_UT_UT_TV')
661 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers='utmp.h',
662 define='HAVE_UT_UT_TYPE')
663 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers='utmp.h',
664 define='HAVE_UT_UT_PID')
665 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers='utmp.h',
666 define='HAVE_UT_UT_EXIT')
667 conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers='utmpx.h',
668 define='HAVE_UX_UT_SYSLEN')
669 conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
670 'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
671 msg="Checking whether pututline returns pointer")
672 conf.CHECK_SIZEOF(['((struct utmp *)NULL)->ut_line'], headers='utmp.h',
673 define='SIZEOF_UTMP_UT_LINE')
674 if not conf.CONFIG_SET('SIZEOF_UTMP_UT_LINE'):
675 conf.env.with_utmp = False
676 elif int(conf.env.SIZEOF_UTMP_UT_LINE) < 15:
677 conf.env.with_utmp = False
678 if conf.env.with_utmp:
679 conf.DEFINE('WITH_UTMP', 1)
680 else:
681 Logs.warn("--with-utmp but utmp support not sufficient")
683 if Options.options.with_avahi:
684 conf.env.with_avahi = True
685 if not conf.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf.env.with_avahi = False
686 if not conf.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf.env.with_avahi = False
687 if not conf.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf.env.with_avahi = False
688 if conf.env.with_avahi:
689 conf.DEFINE('WITH_AVAHI_SUPPORT', 1)
690 else:
691 conf.SET_TARGET_TYPE('avahi-common', 'EMPTY')
692 conf.SET_TARGET_TYPE('avahi-client', 'EMPTY')
694 if Options.options.with_iconv:
695 conf.env.with_iconv = True
696 if not conf.CHECK_FUNCS_IN('iconv_open', 'iconv', headers='iconv.h'):
697 conf.env.with_iconv = False
698 if conf.env.with_iconv:
699 conf.DEFINE('HAVE_ICONV', 1)
701 if Options.options.with_pam:
702 use_pam=True
703 conf.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
704 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
705 Logs.warn("--with-pam=yes but pam_appl.h not found")
706 use_pam=False
707 conf.CHECK_FUNCS_IN('pam_get_data', 'pam')
708 conf.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
709 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
710 Logs.warn("--with-pam=yes but pam_modules.h not found")
711 use_pam=False
712 conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
713 conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
714 conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
715 conf.CHECK_CODE('''
716 #if defined(HAVE_SECURITY_PAM_APPL_H)
717 #include <security/pam_appl.h>
718 #elif defined(HAVE_PAM_PAM_APPL_H)
719 #include <pam/pam_appl.h>
720 #endif
721 pam_set_item(0, PAM_RHOST, 0);
722 ''',
723 'HAVE_PAM_RHOST',
724 lib='pam',
725 msg="Checking whether PAM_RHOST is available");
726 conf.CHECK_CODE('''
727 #if defined(HAVE_SECURITY_PAM_APPL_H)
728 #include <security/pam_appl.h>
729 #elif defined(HAVE_PAM_PAM_APPL_H)
730 #include <pam/pam_appl.h>
731 #endif
732 pam_set_item(0, PAM_TTY, 0);
733 ''',
734 'HAVE_PAM_TTY',
735 lib='pam',
736 msg="Checking whether PAM_TTY is available");
737 conf.CHECK_CODE('''
738 #if (!defined(LINUX))
740 #define PAM_EXTERN extern
741 #if defined(HAVE_SECURITY_PAM_APPL_H)
742 #include <security/pam_appl.h>
743 #elif defined(HAVE_PAM_PAM_APPL_H)
744 #include <pam/pam_appl.h>
745 #endif
747 #endif
749 #if defined(HAVE_SECURITY_PAM_MODULES_H)
750 #include <security/pam_modules.h>
751 #elif defined(HAVE_PAM_PAM_MODULES_H)
752 #include <pam/pam_modules.h>
753 #endif
755 #if defined(HAVE_SECURITY__PAM_MACROS_H)
756 #include <security/_pam_macros.h>
757 #elif defined(HAVE_PAM__PAM_MACROS_H)
758 #include <pam/_pam_macros.h>
759 #endif
761 #ifdef HAVE_SECURITY_PAM_EXT_H
762 #include <security/pam_ext.h>
763 #endif
765 int i; i = PAM_RADIO_TYPE;
766 ''',
767 'HAVE_PAM_RADIO_TYPE',
768 lib='pam',
769 msg="Checking whether PAM_RADIO_TYPE is available");
770 if use_pam:
771 conf.DEFINE('WITH_PAM', 1)
772 conf.DEFINE('WITH_PAM_MODULES', 1)
774 if Options.options.with_pam_smbpass:
775 conf.env.with_pam_smbpass = True
777 seteuid = False
780 # Ensure we select the correct set of system calls on Linux.
782 if (host_os.rfind('linux') > -1):
783 conf.CHECK_CODE('''
784 #if defined(HAVE_UNISTD_H)
785 #include <unistd.h>
786 #endif
787 #include <stdlib.h>
788 #include <stdio.h>
789 #include <sys/types.h>
790 #include <errno.h>
792 #ifdef HAVE_SYS_PRIV_H
793 #include <sys/priv.h>
794 #endif
795 #ifdef HAVE_SYS_ID_H
796 #include <sys/id.h>
797 #endif
799 #if defined(HAVE_SYSCALL_H)
800 #include <syscall.h>
801 #endif
803 #if defined(HAVE_SYS_SYSCALL_H)
804 #include <sys/syscall.h>
805 #endif
807 syscall(SYS_setresuid32, -1, -1, -1);
808 syscall(SYS_setresgid32, -1, -1, -1);
809 syscall(SYS_setreuid32, -1, -1);
810 syscall(SYS_setregid32, -1, -1);
811 syscall(SYS_setuid32, -1);
812 syscall(SYS_setgid32, -1);
813 syscall(SYS_setgroups32, 0, NULL);
814 ''',
815 'USE_LINUX_32BIT_SYSCALLS',
816 msg="Checking whether Linux should use 32-bit credential calls");
818 if (conf.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
819 seteuid = conf.CHECK_CODE('''
820 #define AUTOCONF_TEST 1
821 #define USE_LINUX_THREAD_CREDENTIALS 1
822 #define USE_LINUX_32BIT_SYSCALLS 1
823 #include "../lib/util/setid.c"
824 #include "./lib/util_sec.c"
825 ''',
826 'USE_LINUX_THREAD_CREDENTIALS',
827 addmain=False,
828 execute=True,
829 msg="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
830 else:
831 seteuid = conf.CHECK_CODE('''
832 #define AUTOCONF_TEST 1
833 #define USE_LINUX_THREAD_CREDENTIALS 1
834 #include "../lib/util/setid.c"
835 #include "./lib/util_sec.c"
836 ''',
837 'USE_LINUX_THREAD_CREDENTIALS',
838 addmain=False,
839 execute=True,
840 msg="Checking whether we can use Linux thread-specific credentials")
841 if not seteuid:
842 seteuid = conf.CHECK_CODE('''
843 #define AUTOCONF_TEST 1
844 #define USE_SETREUID 1
845 #include "../lib/util/setid.c"
846 #include "./lib/util_sec.c"
847 ''',
848 'USE_SETREUID',
849 addmain=False,
850 execute=True,
851 msg="Checking whether setreuid is available")
852 if not seteuid:
853 seteuid = conf.CHECK_CODE('''
854 #define AUTOCONF_TEST 1
855 #define USE_SETRESUID 1
856 #include "../lib/util/setid.c"
857 #include "./lib/util_sec.c"
858 ''',
859 'USE_SETRESUID',
860 addmain=False,
861 execute=True,
862 msg="Checking whether setresuid is available")
863 if not seteuid:
864 seteuid = conf.CHECK_CODE('''
865 #define AUTOCONF_TEST 1
866 #define USE_SETEUID 1
867 #include "../lib/util/setid.c"
868 #include "./lib/util_sec.c"
869 ''',
870 'USE_SETEUID',
871 addmain=False,
872 execute=True,
873 msg="Checking whether seteuid is available")
874 if not seteuid:
875 seteuid = conf.CHECK_CODE('''
876 #define AUTOCONF_TEST 1
877 #define USE_SETUIDX 1
878 #include "../lib/util/setid.c"
879 #include "./lib/util_sec.c"
880 ''',
881 'USE_SETUIDX',
882 addmain=False,
883 execute=True,
884 mandatory=True,
885 msg="Checking whether setuidx is available")
886 if Options.options.with_dnsupdate:
887 if not conf.CONFIG_SET('HAVE_KRB5'):
888 Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
889 else:
890 conf.DEFINE('WITH_DNS_UPDATES', 1)
891 conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
892 if Options.options.developer:
893 if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
894 conf.DEFINE('VALGRIND', '1')
896 if conf.CHECK_CODE('''
897 #include <bits/sockaddr.h>
898 #include <linux/netlink.h>
899 ''',
900 'HAVE_LINUX_NETLINK_H',
901 msg="Checking whether Linux netlink is available"):
903 conf.CHECK_CODE('''
904 #include <bits/sockaddr.h>
905 #include <linux/netlink.h>
906 #include <linux/rtnetlink.h>
907 ''',
908 'HAVE_LINUX_RTNETLINK_H',
909 msg='Checking whether Linux rtnetlink is available')
911 conf.CHECK_CODE('''
912 #include "../tests/fcntl_lock.c"
913 ''',
914 'HAVE_FCNTL_LOCK',
915 addmain=False,
916 execute=True,
917 msg='Checking whether fcntl locking is available')
919 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
920 if not conf.CHECK_CODE('''
921 #define _XOPEN_SOURCE 600
922 #include <stdlib.h>
923 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
924 #error probably broken posix_fallocate
925 #endif
926 ''',
927 '_HAVE_UNBROKEN_POSIX_FALLOCATE',
928 msg='Checking for broken posix_fallocate'):
929 conf.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
932 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
933 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
934 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
935 define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
936 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
937 define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
938 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
939 define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
940 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
941 define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
942 if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
943 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
944 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
945 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
946 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
947 conf.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
949 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
950 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
951 define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
952 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
953 define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
954 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
955 define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
957 conf.CHECK_CODE('''
958 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
959 ''',
960 'HAVE_POSIX_FADVISE',
961 msg='Checking whether posix_fadvise is available',
962 headers='unistd.h fcntl.h')
964 for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
965 conf.CHECK_CODE('''
966 #include <unistd.h>
967 return sysconf(%s) == -1 ? 1 : 0;
968 ''' % v,
969 'SYSCONF%s' % v,
970 msg='Checking whether sysconf(%s) is available' % v)
972 conf.CHECK_CODE('''
973 #include <sys/syscall.h>
974 #include <unistd.h>
975 syscall(SYS_initgroups, 16, NULL, NULL, 0);
976 ''',
977 'HAVE_DARWIN_INITGROUPS',
978 msg='Checking whether to use the Darwin-specific initgroups system call')
980 conf.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
981 'HAVE_UTIMBUF',
982 headers='sys/types.h utime.h',
983 msg='Checking whether struct utimbuf is available')
985 if conf.CHECK_CODE('''struct sigevent s;''',
986 'HAVE_STRUCT_SIGEVENT',
987 headers='sys/types.h stdlib.h stddef.h signal.h',
988 msg='Checking whether we have the struct sigevent'):
989 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
990 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
991 headers='signal.h');
992 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
993 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
994 headers='signal.h');
996 if os.path.exists('/proc/sys/kernel/core_pattern'):
997 conf.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
999 if conf.CHECK_CODE('''
1000 #include <time.h>
1001 main() {
1002 struct tm *tm;
1003 if (sizeof(time_t) == 8) {
1004 time_t max_time = 0x7fffffffffffffffll;
1005 tm = gmtime(&max_time);
1006 /* This should fail with 32-bit tm_year. */
1007 if (tm == NULL) {
1008 /* Max time_t that works with 32-bit int tm_year in struct tm. */
1009 max_time = 67768036191676799ll;
1010 tm = gmtime(&max_time);
1011 if (tm) {
1012 exit(0);
1016 exit(1);
1017 }''',
1018 '__TIME_T_MAX',
1019 addmain=False,
1020 execute=True,
1021 msg="Checking for the maximum value of the 'time_t' type"):
1022 conf.DEFINE('TIME_T_MAX', '67768036191676799ll')
1024 conf.CHECK_CODE('''
1025 #if defined(HAVE_UNISTD_H)
1026 #include <unistd.h>
1027 #endif
1028 #include <sys/types.h>
1029 main() { dev_t dev = makedev(1,2); return 0; }
1030 ''',
1031 'HAVE_MAKEDEV',
1032 addmain=False,
1033 msg='Checking whether the macro for makedev is available')
1035 conf.CHECK_CODE('''
1036 #include <stdio.h>
1037 #include <limits.h>
1038 #include <signal.h>
1040 void exit_on_core(int ignored) {
1041 exit(1);
1044 main() {
1045 char *newpath;
1046 signal(SIGSEGV, exit_on_core);
1047 newpath = realpath("/tmp", NULL);
1048 exit((newpath != NULL) ? 0 : 1);
1050 ''',
1051 'REALPATH_TAKES_NULL',
1052 addmain=False,
1053 execute=True,
1054 msg='Checking whether the realpath function allows a NULL argument')
1056 conf.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1057 'HAVE_FTRUNCATE_EXTEND',
1058 msg='Checking for ftruncate extend',
1059 addmain=False,
1060 execute=True)
1062 if Options.options.with_sendfile_support:
1063 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):
1064 conf.CHECK_CODE('''
1065 int tofd, fromfd;
1066 off_t offset;
1067 size_t total;
1068 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1069 ''',
1070 '_HAVE_SENDFILE',
1071 headers='sys/sendfile.h',
1072 msg='Checking for linux sendfile support')
1074 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1075 conf.DEFINE('HAVE_SENDFILE', '1')
1076 conf.DEFINE('LINUX_SENDFILE_API', '1')
1077 conf.DEFINE('WITH_SENDFILE', '1')
1078 elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
1079 conf.CHECK_CODE('''
1080 #include <sys/types.h>
1081 #include <unistd.h>
1082 #include <sys/socket.h>
1083 #include <sys/uio.h>
1084 int fromfd, tofd, ret, total=0;
1085 off_t offset, nwritten;
1086 struct sf_hdtr hdr;
1087 struct iovec hdtrl;
1088 hdr.headers = &hdtrl;
1089 hdr.hdr_cnt = 1;
1090 hdr.trailers = NULL;
1091 hdr.trl_cnt = 0;
1092 hdtrl.iov_base = NULL;
1093 hdtrl.iov_len = 0;
1094 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1095 ''',
1096 '_HAVE_SENDFILE',
1097 msg='Checking for freebsd sendfile support')
1098 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1099 conf.DEFINE('HAVE_SENDFILE', '1')
1100 conf.DEFINE('FREEBSD_SENDFILE_API', '1')
1101 conf.DEFINE('WITH_SENDFILE', '1')
1102 elif (host_os.rfind('darwin') > -1):
1103 conf.CHECK_CODE('''
1104 #include <sys/types.h>
1105 #include <sys/socket.h>
1106 #include <sys/uio.h>
1107 int fromfd, tofd, ret;
1108 off_t offset, nwritten;
1109 struct sf_hdtr hdr;
1110 struct iovec hdtrl;
1111 hdr.headers = &hdtrl;
1112 hdr.hdr_cnt = 1;
1113 hdr.trailers = (void *)0;
1114 hdr.trl_cnt = 0;
1115 hdtrl.iov_base = (void *)0;
1116 hdtrl.iov_len = 0;
1117 ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1118 ''',
1119 '_HAVE_SENDFILE',
1120 msg='Checking for darwin sendfile support')
1121 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1122 conf.DEFINE('HAVE_SENDFILE', '1')
1123 conf.DEFINE('DARWIN_SENDFILE_API', '1')
1124 conf.DEFINE('WITH_SENDFILE', '1')
1125 elif (host_os.rfind('hpux') > -1) or (host_os.rfind('osf') > -1):
1126 conf.CHECK_CODE('''
1127 #include <sys/socket.h>
1128 #include <sys/uio.h>
1129 int fromfd, tofd;
1130 size_t total=0;
1131 struct iovec hdtrl[2];
1132 ssize_t nwritten;
1133 off_t offset;
1134 hdtrl[0].iov_base = 0;
1135 hdtrl[0].iov_len = 0;
1136 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1137 ''',
1138 '_HAVE_SENDFILE',
1139 msg='Checking for osf/hpux sendfile support')
1140 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1141 conf.DEFINE('HAVE_SENDFILE', '1')
1142 conf.DEFINE('HPUX_SENDFILE_API', '1')
1143 conf.DEFINE('WITH_SENDFILE', '1')
1144 elif (host_os.rfind('solaris') > -1):
1145 conf.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1146 conf.CHECK_CODE('''
1147 #include <sys/sendfile.h>,
1148 int sfvcnt;
1149 size_t xferred;
1150 struct sendfilevec vec[2];
1151 ssize_t nwritten;
1152 int tofd;
1153 sfvcnt = 2;
1154 vec[0].sfv_fd = SFV_FD_SELF;
1155 vec[0].sfv_flag = 0;
1156 vec[0].sfv_off = 0;
1157 vec[0].sfv_len = 0;
1158 vec[1].sfv_fd = 0;
1159 vec[1].sfv_flag = 0;
1160 vec[1].sfv_off = 0;
1161 vec[1].sfv_len = 0;
1162 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1163 ''',
1164 '_HAVE_SENDFILEV',
1165 msg='Checking for solaris sendfilev support')
1166 if conf.CONFIG_SET('_HAVE_SENDFILEV'):
1167 conf.DEFINE('HAVE_SENDFILEV', '1')
1168 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1169 conf.DEFINE('WITH_SENDFILE', '1')
1170 elif (host_os.rfind('aix') > -1):
1171 conf.CHECK_CODE('''
1172 #include <sys/socket.h>
1173 int fromfd, tofd;
1174 size_t total=0;
1175 struct sf_parms hdtrl;
1176 ssize_t nwritten;
1177 hdtrl.header_data = 0;
1178 hdtrl.header_length = 0;
1179 hdtrl.file_descriptor = fromfd;
1180 hdtrl.file_offset = 0;
1181 hdtrl.file_bytes = 0;
1182 hdtrl.trailer_data = 0;
1183 hdtrl.trailer_length = 0;
1184 nwritten = send_file(&tofd, &hdtrl, 0);
1185 ''',
1186 '_HAVE_SENDFILE',
1187 msg='Checking for AIX send_file support')
1188 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1189 conf.DEFINE('HAVE_SENDFILE', '1')
1190 conf.DEFINE('AIX_SENDFILE_API', '1')
1191 conf.DEFINE('WITH_SENDFILE', '1')
1193 # Check for getcwd allowing a NULL arg.
1194 conf.CHECK_CODE('''
1195 #include <unistd.h>
1196 main() {
1197 char *s = getcwd(NULL,0);
1198 exit(s != NULL ? 0 : 1);
1199 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
1200 msg="getcwd takes a NULL argument")
1203 # UnixWare 7.x has its getspnam in -lgen
1204 conf.CHECK_FUNCS_IN('getspnam', 'gen')
1205 conf.CHECK_FUNCS_IN('getspnam', 'security')
1206 conf.CHECK_FUNCS_IN('getspnam', 'sec')
1208 if Options.options.with_quotas:
1209 # For quotas on Veritas VxFS filesystems
1210 conf.CHECK_HEADERS('sys/fs/vx_quota.h')
1211 # For sys/quota.h and linux/quota.h
1212 conf.CHECK_HEADERS('sys/quota.h')
1213 # For quotas on BSD systems
1214 conf.CHECK_HEADERS('ufs/ufs/quota.h')
1215 # For quotas on Linux XFS filesystems
1216 if conf.CHECK_HEADERS('xfs/xqm.h'):
1217 conf.DEFINE('HAVE_XFS_QUOTAS', '1')
1218 else:
1219 # For Irix XFS
1220 conf.CHECK_CODE('''
1221 #include "confdefs.h"
1222 #ifdef HAVE_SYS_TYPES_H
1223 #include <sys/types.h>
1224 #endif
1225 #ifdef HAVE_ASM_TYPES_H
1226 #include <asm/types.h>
1227 #endif
1228 #include <sys/quota.h>
1229 int i = Q_XGETQUOTA;''',
1230 define='HAVE_XFS_QUOTAS',
1231 msg='for XFS QUOTA in <sys/quota.h>',
1232 execute=False,
1233 local_include=False)
1235 # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
1236 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define='HAVE_DQB_FSOFTLIMIT',
1237 headers='sys/quota.h')
1238 #darwin style quota bytecount
1239 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_curbytes', define='HAVE_STRUCT_DQBLK_DQB_CURBYTES',
1240 headers='sys/quota.h')
1241 if conf.CHECK_HEADERS('rpcsvc/rquota.h'):
1242 conf.DEFINE('HAVE_NFS_QUOTAS', '1')
1243 conf.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1244 define='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1245 headers='rpcsvc/rquota.h')
1247 if (host_os.rfind('linux') > -1):
1248 conf.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1249 elif not conf.CONFIG_SET("HAVE_XFS_QUOTAS"):
1250 if not conf.CHECK_CODE('''
1251 #define HAVE_QUOTACTL_4A 1
1252 #define AUTOCONF_TEST 1
1253 #include "../tests/sysquotas.c"
1254 ''',
1255 cflags=conf.env['WERROR_CFLAGS'],
1256 define='HAVE_QUOTACTL_4A',
1257 msg='for QUOTACTL_4A: long quotactl(int cmd, char *special, qid_t id, caddr_t addr)',
1258 execute=True,
1259 addmain=False):
1261 conf.CHECK_CODE('''
1262 #define HAVE_QUOTACTL_4B 1
1263 #define AUTOCONF_TEST 1
1264 #include "../tests/sysquotas.c"
1265 ''',
1266 cflags=conf.env['WERROR_CFLAGS'],
1267 define='HAVE_QUOTACTL_4B',
1268 msg='for QUOTACTL_4B: int quotactl(const char *path, int cmd, int id, char *addr)',
1269 execute=True,
1270 addmain=False)
1272 conf.CHECK_CODE('''
1273 clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
1274 ''',
1275 headers="rpc/rpc.h rpc/types.h rpcsvc/rquota.h rpc/nettype.h rpc/xdr.h",
1276 define='HAVE_NFS_QUOTAS',
1277 msg='for NFS QUOTAS',
1278 execute=True,
1279 local_include=False)
1281 if conf.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1282 conf.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1283 conf.CONFIG_SET('HAVE_QUOTACTL_4B') or \
1284 conf.CONFIG_SET('HAVE_XFS_QUOTAS'):
1285 conf.DEFINE('HAVE_SYS_QUOTAS', '1')
1286 conf.DEFINE('WITH_QUOTAS', '1')
1289 # checking for clustering extensions (CTDB)
1291 if not Options.options.with_cluster_support:
1292 have_cluster_support = False
1294 else:
1296 if Options.options.ctdb_dir:
1297 conf.ADD_EXTRA_INCLUDES(Options.options.ctdb_dir + '/include')
1299 srcdir = os.path.realpath(conf.srcdir)
1300 if 'EXTRA_INCLUDES' in conf.env:
1301 includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/')
1302 else:
1303 includes = ''
1305 if not conf.env.USING_SYSTEM_TDB:
1306 includes = includes + ' ' + srcdir + '/lib/tdb/include'
1308 if not conf.env.USING_SYSTEM_TALLOC:
1309 includes = includes + ' ' + srcdir + '/lib/talloc'
1311 have_cluster_support = True
1312 ctdb_broken = ""
1314 conf.CHECK_CODE('''
1315 #define NO_CONFIG_H
1316 #include "replace.h"
1317 #include "system/wait.h"
1318 #include "system/network.h"
1319 #define private #error __USED_RESERVED_WORD_private__
1320 #include <talloc.h>
1321 #include <tdb.h>
1322 #include <ctdb.h>
1324 int main(void)
1326 return 0;
1328 ''',
1329 'HAVE_CTDB_H',
1330 addmain=False,
1331 includes=includes,
1332 msg='Checking for header ctdb.h')
1334 if not conf.CONFIG_SET('HAVE_CTDB_H'):
1335 have_cluster_support = False
1336 ctdb_broken = "ctdb.h is required for cluster support"
1338 if have_cluster_support:
1339 conf.CHECK_CODE('''
1340 #define NO_CONFIG_H
1341 #include "replace.h"
1342 #include "system/wait.h"
1343 #include "system/network.h"
1344 #define private #error __USED_RESERVED_WORD_private__
1345 #include <talloc.h>
1346 #include <tdb.h>
1347 #include <ctdb.h>
1348 #include <ctdb_private.h>
1350 int main(void)
1352 return 0;
1354 ''',
1355 'HAVE_CTDB_PRIVATE_H',
1356 addmain=False,
1357 includes=includes,
1358 msg='Checking for header ctdb_private.h')
1360 if not conf.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
1361 have_cluster_support = False
1362 ctdb_broken = "ctdb_private.h is required for cluster support"
1364 if have_cluster_support:
1365 conf.CHECK_CODE('''
1366 #define NO_CONFIG_H
1367 #include "replace.h"
1368 #include "system/wait.h"
1369 #include "system/network.h"
1370 #define private #error __USED_RESERVED_WORD_private__
1371 #include <talloc.h>
1372 #include <tdb.h>
1373 #include <ctdb.h>
1374 #include <ctdb_protocol.h>
1376 int main(void)
1378 return 0;
1380 ''',
1381 'HAVE_CTDB_PROTOCOL_H',
1382 addmain=False,
1383 includes=includes,
1384 msg='Checking for header ctdb_protocol.h')
1386 if have_cluster_support:
1387 conf.CHECK_CODE('''
1388 #define NO_CONFIG_H
1389 #include "replace.h"
1390 #include "system/wait.h"
1391 #include "system/network.h"
1392 #include <talloc.h>
1393 #include <tdb.h>
1394 #include <ctdb.h>
1395 #include <ctdb_private.h>
1397 int main(void)
1399 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1400 return 0;
1402 ''',
1403 'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
1404 addmain=False,
1405 includes=includes,
1406 msg='Checking for transaction support (TRANS3_COMMIT control)')
1408 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
1409 have_cluster_support = False
1410 ctdb_broken = "ctdb transaction support missing or too old"
1412 if have_cluster_support:
1413 conf.CHECK_CODE('''
1414 #define NO_CONFIG_H
1415 #include "replace.h"
1416 #include "system/wait.h"
1417 #include "system/network.h"
1418 #include <talloc.h>
1419 #include <tdb.h>
1420 #include <ctdb.h>
1421 #include <ctdb_private.h>
1423 int main(void)
1425 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1426 return 0;
1428 ''',
1429 'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
1430 addmain=False,
1431 includes=includes,
1432 msg='Checking for SCHEDULE_FOR_DELETION control')
1434 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
1435 if not Options.options.enable_old_ctdb:
1436 have_cluster_support = False
1437 ctdb_broken = "SCHEDULE_FOR_DELETION control missing"
1438 else:
1439 Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1441 if have_cluster_support:
1442 conf.CHECK_CODE('''
1443 #define NO_CONFIG_H
1444 #include "replace.h"
1445 #include "system/wait.h"
1446 #include "system/network.h"
1447 #include <talloc.h>
1448 #include <tdb.h>
1449 #include <ctdb.h>
1450 #include <ctdb_private.h>
1452 int main(void)
1454 struct ctdb_control_tcp _x;
1455 return 0;
1457 ''',
1458 'HAVE_STRUCT_CTDB_CONTROL_TCP',
1459 addmain=False,
1460 includes=includes,
1461 msg='Checking for ctdb ipv4 support')
1463 if not conf.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
1464 have_cluster_support = False
1465 ctdb_broken = "missing struct ctdb_control_tcp"
1467 if have_cluster_support:
1468 conf.CHECK_CODE('''
1469 #define NO_CONFIG_H
1470 #include "replace.h"
1471 #include "system/wait.h"
1472 #include "system/network.h"
1473 #include <talloc.h>
1474 #include <tdb.h>
1475 #include <ctdb.h>
1476 #include <ctdb_private.h>
1478 int main(void)
1480 struct ctdb_control_tcp_addr _x;
1481 return 0;
1483 ''',
1484 'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
1485 addmain=False,
1486 includes=includes,
1487 msg='Checking for ctdb ipv6 support')
1489 if have_cluster_support:
1490 conf.CHECK_CODE('''
1491 #define NO_CONFIG_H
1492 #include "replace.h"
1493 #include "system/wait.h"
1494 #include "system/network.h"
1495 #include <talloc.h>
1496 #include <tdb.h>
1497 #include <ctdb.h>
1498 #include <ctdb_private.h>
1500 int main(void)
1502 int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1503 return 0;
1505 ''',
1506 'HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL',
1507 addmain=False,
1508 includes=includes,
1509 msg='Checking for CHECK_SRVIDS control')
1511 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL'):
1512 if not Options.options.enable_old_ctdb:
1513 have_cluster_support = False
1514 ctdb_broken = "CHECK_SRVIDS control missing"
1515 else:
1516 Logs.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1518 if have_cluster_support:
1519 Logs.info("building with cluster support")
1520 conf.DEFINE('CLUSTER_SUPPORT', 1);
1521 else:
1522 if not Options.options.with_cluster_support:
1523 Logs.info("building without cluster support")
1524 else:
1525 Logs.warn("building without cluster support: " + ctdb_broken)
1526 conf.undefine('CLUSTER_SUPPORT')
1530 conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1531 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1532 addmain=False,
1533 link=False,
1534 msg='Checking whether we can compile with __attribute__((destructor))')
1536 conf.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1537 'SEEKDIR_RETURNS_VOID',
1538 headers='sys/types.h dirent.h',
1539 msg='Checking whether seekdir returns void')
1541 if Options.options.with_profiling_data:
1542 conf.DEFINE('WITH_PROFILE', 1);
1544 PTHREAD_CFLAGS='error'
1545 PTHREAD_LDFLAGS='error'
1547 if PTHREAD_LDFLAGS == 'error':
1548 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
1549 PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
1550 PTHREAD_LDFLAGS='-lpthread'
1551 if PTHREAD_LDFLAGS == 'error':
1552 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
1553 PTHREAD_CFLAGS='-D_THREAD_SAFE'
1554 PTHREAD_LDFLAGS='-lpthreads'
1555 if PTHREAD_LDFLAGS == 'error':
1556 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
1557 PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread'
1558 PTHREAD_LDFLAGS='-pthread'
1559 if PTHREAD_LDFLAGS == 'error':
1560 if conf.CHECK_FUNCS('pthread_attr_init'):
1561 PTHREAD_CFLAGS='-D_REENTRANT'
1562 PTHREAD_LDFLAGS='-lpthread'
1563 # especially for HP-UX, where the CHECK_FUNC macro fails to test for
1564 # pthread_attr_init. On pthread_mutex_lock it works there...
1565 if PTHREAD_LDFLAGS == 'error':
1566 if conf.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
1567 PTHREAD_CFLAGS='-D_REENTRANT'
1568 PTHREAD_LDFLAGS='-lpthread'
1570 if PTHREAD_CFLAGS != 'error' and PTHREAD_LDFLAGS != 'error':
1571 conf.ADD_CFLAGS(PTHREAD_CFLAGS)
1572 conf.ADD_LDFLAGS(PTHREAD_LDFLAGS)
1573 conf.CHECK_HEADERS('pthread.h')
1574 conf.DEFINE('HAVE_PTHREAD', '1')
1576 if Options.options.with_pthreadpool:
1577 if conf.CONFIG_SET('HAVE_PTHREAD'):
1578 conf.DEFINE('WITH_PTHREADPOOL', '1')
1579 else:
1580 Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
1581 conf.undefine('WITH_PTHREADPOOL')
1583 if conf.CHECK_HEADERS('gpfs_gpl.h'):
1584 conf.DEFINE('HAVE_GPFS', '1')
1586 default_static_modules.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1587 auth_sam auth_unix auth_winbind auth_wbc
1588 auth_domain auth_builtin vfs_default
1589 nss_info_template idmap_tdb idmap_passdb
1590 idmap_nss'''))
1592 default_shared_modules.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1593 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1594 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1595 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1596 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1597 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1598 vfs_media_harmony
1599 vfs_crossrename vfs_linux_xfs_sgid
1600 vfs_time_audit idmap_autorid idmap_tdb2
1601 idmap_rid idmap_hash'''))
1603 if Options.options.developer:
1604 default_static_modules.extend(TO_LIST('charset_weird'))
1605 default_shared_modules.extend(TO_LIST('perfcount_test'))
1606 default_shared_modules.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1607 default_shared_modules.extend(TO_LIST('auth_skel pdb_test'))
1609 if Options.options.enable_selftest or Options.options.developer:
1610 default_shared_modules.extend(TO_LIST('vfs_fake_acls'))
1613 if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1614 default_static_modules.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
1616 if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1617 default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
1619 if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
1620 default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1622 if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
1623 default_shared_modules.extend(TO_LIST('vfs_fileid'))
1625 if (conf.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
1626 default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
1628 if Options.options.with_pthreadpool:
1629 default_shared_modules.extend(TO_LIST('vfs_aio_pthread'))
1631 if conf.CONFIG_SET('HAVE_AIO'):
1632 default_shared_modules.extend(TO_LIST('vfs_aio_posix'))
1634 if conf.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1635 default_shared_modules.extend(TO_LIST('vfs_aio_linux'))
1637 if conf.CONFIG_SET('HAVE_LDAP'):
1638 default_static_modules.extend(TO_LIST('pdb_ldap idmap_ldap'))
1640 if conf.CONFIG_SET('DARWINOS'):
1641 default_static_modules.extend(TO_LIST('charset_macosxfs'))
1643 if conf.CONFIG_SET('HAVE_GPFS'):
1644 default_shared_modules.extend(TO_LIST('vfs_gpfs'))
1646 explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
1647 explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
1649 final_static_modules = default_static_modules
1650 final_shared_modules = default_shared_modules
1652 for m in explicit_static_modules:
1653 if m in final_shared_modules:
1654 final_shared_modules.remove(m)
1655 final_static_modules.append(m)
1656 for m in explicit_shared_modules:
1657 if m in final_static_modules:
1658 final_static_modules.remove(m)
1659 final_shared_modules.append(m)
1661 if ("auth_domain" not in final_static_modules) or \
1662 ("auth_builtin" not in final_static_modules) or \
1663 ("auth_sam" not in final_static_modules) or \
1664 ("auth_winbind" not in final_static_modules):
1665 raise Utils.WafError('These auth modules MUST be configured as static modules: auth_domain, auth_builtin, auth_sam, auth_winbind')
1667 conf.env['static_modules'] = final_static_modules
1668 conf.env['shared_modules'] = final_shared_modules
1670 conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
1672 static_list = {}
1673 shared_list = {}
1675 prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1676 conf.env['MODULE_PREFIXES'] = prefixes
1677 for p in prefixes:
1678 for m in final_static_modules:
1679 if m.find(p) == 0:
1680 if not p in static_list:
1681 static_list[p] = []
1682 static_list[p].append(m)
1683 for m in final_shared_modules:
1684 if m.find(p) == 0:
1685 if not p in shared_list:
1686 shared_list[p] = []
1687 shared_list[p].append(m)
1689 for p in prefixes:
1690 static_env = "%s_STATIC" % p.upper()
1691 shared_env = "%s_SHARED" % p.upper()
1692 conf.env[static_env] = []
1693 conf.env[shared_env] = []
1694 if p in static_list:
1695 decl_list=""
1696 for entry in static_list[p]:
1697 decl_list += "extern NTSTATUS %s_init(void); " % entry
1698 conf.env[static_env].append('%s' % entry)
1699 decl_list = decl_list.rstrip()
1700 conf.DEFINE('static_decl_%s' % p, decl_list)
1701 conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
1702 else:
1703 conf.DEFINE('static_decl_%s' % p, '')
1704 conf.DEFINE('static_init_%s' % p, '{}')
1705 if p in shared_list:
1706 for entry in shared_list[p]:
1707 conf.DEFINE('%s_init' % entry, 'samba_init_module')
1708 conf.env[shared_env].append('%s' % entry)
1710 conf.SAMBA_CONFIG_H('include/config.h')
1712 def ctags(ctx):
1713 "build 'tags' file using ctags"
1714 import Utils
1715 source_root = os.path.dirname(Utils.g_module.root_path)
1716 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1717 print("Running: %s" % cmd)
1718 os.system(cmd)