Inside _talloc_realloc(), keep track of size changes over malloc/realloc/free.
[Samba.git] / source3 / wscript
blob10aa23263ca0d4b960a38072d1a0b4c6053d30ed
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('ads', default=None) # None means autodetection
27 opt.SAMBA3_ADD_OPTION('ldap')
28 opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
29 opt.SAMBA3_ADD_OPTION('iprint', with_name="enable", without_name="disable")
30 opt.SAMBA3_ADD_OPTION('pam')
31 opt.SAMBA3_ADD_OPTION('pam_smbpass')
32 opt.SAMBA3_ADD_OPTION('quotas')
33 opt.SAMBA3_ADD_OPTION('sendfile-support')
34 opt.SAMBA3_ADD_OPTION('utmp')
35 opt.SAMBA3_ADD_OPTION('pthreadpool', with_name="enable", without_name="disable", default=True)
36 opt.SAMBA3_ADD_OPTION('avahi', with_name="enable", without_name="disable")
37 opt.SAMBA3_ADD_OPTION('iconv')
38 opt.SAMBA3_ADD_OPTION('acl-support')
39 opt.SAMBA3_ADD_OPTION('dnsupdate')
40 opt.SAMBA3_ADD_OPTION('syslog')
41 opt.SAMBA3_ADD_OPTION('automount')
42 opt.SAMBA3_ADD_OPTION('aio-support')
43 opt.SAMBA3_ADD_OPTION('dmapi', default=None) # None means autodetection
44 opt.SAMBA3_ADD_OPTION('fam', default=None) # None means autodetection
45 opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
47 opt.SAMBA3_ADD_OPTION('cluster-support', default=None)
49 opt.SAMBA3_ADD_OPTION('regedit', default=None)
51 opt.add_option('--with-ctdb-dir',
52 help=("Directory under which ctdb is installed"),
53 action="store", dest='ctdb_dir', default=None)
54 opt.add_option('--enable-old-ctdb',
55 help=("enable building against (too) old version of ctdb (default=false)"),
56 action="store_true", dest='enable_old_ctdb', default=False)
58 opt.add_option('--with-libcephfs',
59 help=("Directory under which libcephfs is installed"),
60 action="store", dest='libcephfs_dir', default=None)
62 opt.SAMBA3_ADD_OPTION('glusterfs', with_name="enable", without_name="disable", default=True)
65 def configure(conf):
66 from samba_utils import TO_LIST
68 default_static_modules = []
69 default_shared_modules = []
71 if Options.options.developer:
72 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
73 conf.env.developer = True
75 if sys.platform != 'openbsd5':
76 conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
78 conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
79 conf.CHECK_HEADERS('linux/falloc.h')
81 conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
82 conf.CHECK_FUNCS('strtol strchr strupr chflags')
83 conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
84 conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
85 conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
86 conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
87 conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
88 conf.CHECK_FUNCS('atexit grantpt posix_openpt fallocate posix_fallocate')
89 conf.CHECK_FUNCS('fseeko setluid')
90 conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
91 conf.CHECK_FUNCS('fdopendir')
92 conf.CHECK_FUNCS('fstatat')
93 conf.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
94 conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
95 conf.CHECK_FUNCS_IN('nanosleep', 'rt')
96 conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
97 conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
98 conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
99 conf.CHECK_FUNCS('shmget')
100 conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
101 #FIXME: for some reason this one still fails
102 conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
103 conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
104 conf.CHECK_FUNCS_IN('dn_expand', 'inet')
105 conf.CHECK_DECLS('fdatasync', reverse=True)
106 conf.CHECK_DECLS('readahead', reverse=True, headers='fcntl.h')
108 if conf.CONFIG_SET('HAVE_LONG_LONG'):
109 conf.DEFINE('HAVE_LONGLONG', 1)
111 if conf.CHECK_CODE('''
112 #if defined(HAVE_UNISTD_H)
113 #include <unistd.h>
114 #endif
115 long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
116 ''',
117 'HAVE_LINUX_SPLICE',
118 headers='fcntl.h'):
119 conf.CHECK_DECLS('splice', reverse=True, headers='fcntl.h')
121 # Check for inotify support
122 conf.CHECK_HEADERS('sys/inotify.h')
123 if "HAVE_SYS_INOTIFY_H" in conf.env:
124 conf.DEFINE('HAVE_INOTIFY', 1)
126 # Check for kernel change notify support
127 conf.CHECK_CODE('''
128 #ifndef F_NOTIFY
129 #define F_NOTIFY 1026
130 #endif
131 main() {
132 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
133 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
134 headers='fcntl.h signal.h',
135 msg="Checking for kernel change notify support")
137 # Check for Linux kernel oplocks
138 conf.CHECK_CODE('''
139 #include <sys/types.h>
140 #include <fcntl.h>
141 #include <signal.h>
142 #ifndef F_NOTIFY
143 #define F_NOTIFY 1026
144 #endif
145 main() {
146 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
147 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
148 msg="Checking for Linux kernel oplocks")
150 # Check for IRIX kernel oplock types
151 conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
152 'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
153 msg="Checking for IRIX kernel oplock types")
155 # Check for kernel share modes
156 conf.CHECK_CODE('''
157 #include <sys/types.h>
158 #include <fcntl.h>
159 #include <signal.h>
160 #include <sys/file.h>
161 #ifndef LOCK_MAND
162 #define LOCK_MAND 32
163 #define LOCK_READ 64
164 #endif
165 main() {
166 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
167 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
168 msg="Checking for kernel share modes")
170 # check for fam libs
171 samba_fam_libs=None
172 check_for_fam=False
173 if Options.options.with_fam is None:
174 check_for_fam=True
175 elif Options.options.with_fam == True:
176 check_for_fam=True
178 if check_for_fam and conf.CHECK_HEADERS('fam.h'):
179 if conf.CHECK_FUNCS_IN('FAMOpen2', 'fam'):
180 samba_fam_libs='fam'
181 elif conf.CHECK_FUNCS_IN('FAMOpen2', 'fam C'):
182 samba_fam_libs='fam C'
183 conf.CHECK_TYPE('enum FAMCodes', headers='fam.h',
184 define='HAVE_FAM_H_FAMCODES_TYPEDEF',
185 msg='Checking whether enum FAMCodes is available')
186 conf.CHECK_FUNCS_IN('FAMNoExists', 'fam')
188 if samba_fam_libs is not None:
189 conf.DEFINE('SAMBA_FAM_LIBS', samba_fam_libs)
190 else:
191 if Options.options.with_fam == True:
192 conf.fatal('FAM support requested, but no suitable FAM library found')
193 elif check_for_fam:
194 Logs.warn('no suitable FAM library found')
196 # check for DMAPI libs
197 if Options.options.with_dmapi == False:
198 have_dmapi = False
199 else:
200 have_dmapi = True
201 Logs.info("Checking for DMAPI library existence")
202 samba_dmapi_lib = ''
203 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dm'):
204 samba_dmapi_lib = 'dm'
205 else:
206 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'jfsdm'):
207 samba_dmapi_lib = 'jfsdm'
208 else:
209 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dmapi'):
210 samba_dmapi_lib = 'dmapi'
211 else:
212 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'xdsm'):
213 samba_dmapi_lib = 'xdsm'
214 # only bother to test headers and compilation when a candidate
215 # library has been found
216 if samba_dmapi_lib == '':
217 have_dmapi = False
218 broken_dmapi = "no suitable DMAPI library found"
220 if have_dmapi:
221 conf.CHECK_HEADERS('sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h dmapi.h')
222 conf.CHECK_CODE('''
223 #include <time.h> /* needed by Tru64 */
224 #include <sys/types.h> /* needed by AIX */
225 #ifdef HAVE_XFS_DMAPI_H
226 #include <xfs/dmapi.h>
227 #elif defined(HAVE_SYS_DMI_H)
228 #include <sys/dmi.h>
229 #elif defined(HAVE_SYS_JFSDMAPI_H)
230 #include <sys/jfsdmapi.h>
231 #elif defined(HAVE_SYS_DMAPI_H)
232 #include <sys/dmapi.h>
233 #elif defined(HAVE_DMAPI_H)
234 #include <dmapi.h>
235 #endif
237 /* This link test is designed to fail on IRI 6.4, but should
238 * succeed on Linux, IRIX 6.5 and AIX.
240 int main(int argc, char **argv)
242 char * version;
243 dm_eventset_t events;
244 /* This doesn't take an argument on IRIX 6.4. */
245 dm_init_service(&version);
246 /* IRIX 6.4 expects events to be a pointer. */
247 DMEV_ISSET(DM_EVENT_READ, events);
249 return 0;
251 ''',
252 'USEABLE_DMAPI_LIBRARY',
253 addmain=False,
254 execute=False,
255 lib=samba_dmapi_lib,
256 msg='Checking whether DMAPI lib '+samba_dmapi_lib+' can be used')
257 if not conf.CONFIG_SET('USEABLE_DMAPI_LIBRARY'):
258 have_dmapi = False
259 broken_dmapi = "no usable DMAPI library found"
261 if have_dmapi:
262 Logs.info("Building with DMAPI support.")
263 conf.env['dmapi_lib'] = samba_dmapi_lib
264 conf.DEFINE('USE_DMAPI', 1)
265 else:
266 if Options.options.with_dmapi == False:
267 Logs.info("Building without DMAPI support (--without-dmapi).")
268 elif Options.options.with_dmapi == True:
269 Logs.error("DMAPI support not available: " + broken_dmapi)
270 conf.fatal('DMAPI support requested but not found.');
271 else:
272 Logs.warn("Building without DMAPI support: " + broken_dmapi)
273 conf.env['dmapi_lib'] = ''
275 # Check for various members of the stat structure
276 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
277 headers='sys/stat.h')
278 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
279 headers='sys/stat.h')
280 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define='HAVE_STAT_ST_FLAGS',
281 headers='sys/types.h sys/stat.h unistd.h')
283 if "HAVE_BLKCNT_T" in conf.env:
284 conf.CHECK_CODE('''
285 return sizeof(blkcnt_t) == 4 ? 0 : 1''',
286 'SIZEOF_BLKCNT_T_4', execute=True,
287 headers='replace.h sys/types.h sys/stat.h unistd.h',
288 msg="Checking whether blkcnt_t is 32 bit")
290 if "HAVE_BLKCNT_T" in conf.env:
291 conf.CHECK_CODE('''
292 return sizeof(blkcnt_t) == 8 ? 0 : 1''',
293 'SIZEOF_BLKCNT_T_8', execute=True,
294 headers='replace.h sys/types.h sys/stat.h unistd.h',
295 msg="Checking whether blkcnt_t is 64 bit")
297 # Check for POSIX capability support
298 conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
300 if "HAVE_SYS_CAPABILITY_H" in conf.env:
301 conf.CHECK_CODE('''
302 cap_t cap;
303 cap_value_t vals[1];
304 if (!(cap = cap_get_proc())) exit(1);
305 vals[0] = CAP_CHOWN;
306 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
307 cap_set_proc(cap);''',
308 'HAVE_POSIX_CAPABILITIES', execute=True, lib="cap",
309 headers='sys/capability.h',
310 msg="Checking whether POSIX capabilities are available")
312 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
313 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
314 # -- JRA.
315 if conf.CONFIG_SET("HAVE_RPC_RPC_H"):
316 conf.CHECK_TYPE('int16', headers='rpc/rpc.h',
317 define='HAVE_INT16_FROM_RPC_RPC_H',
318 msg="Checking for int16 typedef included by rpc/rpc.h")
319 conf.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
320 headers='sys/types.h rpc/rpc.h',
321 msg="Checking for uint16 typedef included by rpc/rpc.h")
322 conf.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
323 headers='sys/types.h rpc/rpc.h',
324 msg="Checking for int32 typedef included by rpc/rpc.h")
325 conf.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
326 headers='sys/types.h rpc/rpc.h',
327 msg="Checking for uint32 typedef included by rpc/rpc.h")
328 conf.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
329 headers='sys/types.h sys/acl.h rpcsvc/nis.h',
330 msg="Checking for broken nisplus include files")
332 # Check if the compiler will optimize out functions
333 conf.CHECK_CODE('''
334 if (0) {
335 this_function_does_not_exist();
336 } else {
337 return 1;
338 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
339 msg="Checking if the compiler will optimize out functions")
341 # Check if the compiler supports the LL suffix on long long integers
342 # AIX needs this
343 conf.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
344 headers='stdio.h',
345 msg="Checking for LL suffix on long long integers")
347 conf.CHECK_FUNCS('''
348 _acl __acl atexit
349 _chdir __chdir chflags chmod _close __close _closedir
350 __closedir crypt16 devnm dirfd
351 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
352 _facl __facl _fchdir
353 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
354 _fork __fork fseeko
355 fsetxattr _fstat __fstat fsync
356 futimens futimes __fxstat getauthuid
357 getcwd _getcwd __getcwd getdents __getdents getdirentries
358 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
359 getpwanam getpwent_r getrlimit
360 glob grantpt hstrerror initgroups innetgr
361 llseek _llseek __llseek _lseek __lseek
362 _lstat __lstat lutimes
363 __lxstat memalign mknod mlock mlockall munlock munlockall
364 _open __open _opendir __opendir
365 pathconf poll posix_fallocate
366 posix_memalign pread _pread __pread
367 pwrite _pwrite __pwrite
368 rdchk _read __read _readdir __readdir
369 _seekdir __seekdir
370 select setenv setgidx setgroups setlocale setluid
371 setmntent setpgid setpriv setsid setuidx
372 shmget shm_open sigaction sigblock sigprocmask sigset
373 _stat __stat statvfs
374 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
375 __sys_llseek syslog _telldir __telldir timegm
376 utimensat vsyslog _write __write __xstat
377 ''')
379 conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
381 # FIXME: these should be tests for features, but the old build system just
382 # checks for OSes.
383 host_os = sys.platform
384 Logs.info("building on %s" % host_os)
386 # Python doesn't have case switches... :/
387 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
388 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
390 conf.SET_TARGET_TYPE('sunacl', 'EMPTY')
391 if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('qnx') > -1):
392 if host_os.rfind('linux') > -1:
393 conf.DEFINE('LINUX', '1')
394 elif host_os.rfind('qnx') > -1:
395 conf.DEFINE('QNX', '1')
396 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
397 elif (host_os.rfind('darwin') > -1):
398 conf.DEFINE('DARWINOS', 1)
399 conf.ADD_CFLAGS('-fno-common')
400 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
401 elif (host_os.rfind('freebsd') > -1):
402 conf.DEFINE('FREEBSD', 1)
403 if conf.CHECK_HEADERS('sunacl.h'):
404 conf.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
405 conf.CHECK_FUNCS_IN('acl', 'sunacl')
406 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
407 elif (host_os.rfind('irix') > -1):
408 conf.DEFINE('IRIX', 1)
409 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
410 elif (host_os.rfind('aix') > -1):
411 conf.DEFINE('AIX', 1)
412 conf.DEFINE('STAT_ST_BLOCKSIZE', 'DEV_BSIZE')
413 elif (host_os.rfind('hpux') > -1):
414 conf.DEFINE('HPUX', 1)
415 conf.DEFINE('STAT_ST_BLOCKSIZE', '8192')
416 elif (host_os.rfind('osf') > -1):
417 conf.DEFINE('OSF1', 1)
418 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
420 # FIXME: Add more checks here.
421 else:
422 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
424 if Options.options.with_acl_support:
425 if (host_os.rfind('sysv5') > -1) and conf.CHECK_FUNCS_IN('sec', 'facl', checklibc=True):
426 Logs.info('Using UnixWare ACLs')
427 conf.DEFINE('HAVE_UNIXWARE_ACLS',1)
428 default_static_modules.extend(TO_LIST('vfs_solarisacl'))
429 elif (host_os.rfind('solaris') > -1) and conf.CHECK_FUNCS_IN('sec', 'facl'):
430 Logs.info('Using solaris ACLs')
431 conf.DEFINE('HAVE_SOLARIS_ACLS',1)
432 default_static_modules.extend(TO_LIST('vfs_solarisacl'))
433 elif (host_os.rfind('hpux') > -1):
434 Logs.info('Using HPUX ACLs')
435 conf.DEFINE('HAVE_HPUX_ACLS',1)
436 conf.DEFINE('POSIX_ACL_NEEDS_MASK',1)
437 default_static_modules.extend(TO_LIST('vfs_hpuxacl'))
438 elif (host_os.rfind('aix') > -1):
439 Logs.info('Using AIX ACLs')
440 conf.DEFINE('HAVE_AIX_ACLS',1)
441 default_static_modules.extend(TO_LIST('vfs_aixacl vfs_aixacl2'))
442 elif (host_os.rfind('osf') > -1) and conf.CHECK_FUNCS_IN('pacl', 'acl_get_fd'):
443 Logs.info('Using Tru64 ACLs')
444 conf.DEFINE('HAVE_TRU64_ACLS',1)
445 default_static_modules.extend(TO_LIST('vfs_tru64acl'))
446 elif (host_os.rfind('darwin') > -1):
447 Logs.warn('ACLs on Dwarwin currently not supported')
448 else:
449 conf.CHECK_FUNCS_IN('acl_get_file', 'acl')
450 if conf.CHECK_CODE('''
451 acl_t acl;
452 int entry_id;
453 acl_entry_t *entry_p;
454 return acl_get_entry(acl, entry_id, entry_p);
455 ''',
456 'HAVE_POSIX_ACLS',
457 headers='sys/types.h sys/acl.h', link=False,
458 msg="Checking for POSIX ACL support") :
459 conf.CHECK_CODE('''
460 acl_permset_t permset_d;
461 acl_perm_t perm;
462 return acl_get_perm_np(permset_d, perm);
463 ''',
464 'HAVE_ACL_GET_PERM_NP',
465 headers='sys/types.h sys/acl.h', link=True,
466 msg="Checking whether acl_get_perm_np() is available")
467 default_static_modules.extend(TO_LIST('vfs_posixacl'))
470 if conf.CHECK_FUNCS('dirfd'):
471 conf.DEFINE('HAVE_DIRFD_DECL', 1)
473 conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
474 'HAVE_STATFS_F_FSID',
475 msg="vfs_fileid checking for statfs() and struct statfs.f_fsid",
476 headers='sys/types.h sys/statfs.h',
477 execute=True)
479 if conf.CONFIG_SET('HAVE_FALLOCATE'):
480 conf.CHECK_CODE('''
481 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
482 'HAVE_LINUX_FALLOCATE',
483 msg="Checking whether the Linux 'fallocate' function is available",
484 headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
485 conf.CHECK_CODE('''
486 ssize_t err = readahead(0,0,0x80000);''',
487 'HAVE_LINUX_READAHEAD',
488 msg="Checking whether Linux readahead is available",
489 headers='unistd.h fcntl.h')
490 conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
492 conf.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
493 'HAVE_OPENAT',
494 msg='Checking for openat',
495 headers='fcntl.h')
497 if Options.options.with_aio_support:
498 conf.CHECK_FUNCS_IN('aio_read', 'aio')
499 conf.CHECK_FUNCS_IN('aio_read', 'rt')
500 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);',
501 'HAVE_AIO',
502 msg='Checking for asynchronous io support',
503 headers='sys/types.h aio.h',
504 lib='aio rt')
505 if conf.CONFIG_SET('HAVE_AIO'):
506 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg='Checking for aio_read', headers='aio.h', lib='aio rt')
507 conf.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg='Checking for aio_write', headers='aio.h', lib='aio rt')
508 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')
509 conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
510 conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
511 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')
512 conf.CHECK_CODE('const struct aiocb * const a[1]; struct timespec t; return aio_suspend(&a, 1, &t);', 'HAVE_AIO_SUSPEND', msg='Checking for aio_suspend', headers='aio.h', lib='aio rt')
513 if not conf.CONFIG_SET('HAVE_AIO'):
514 conf.DEFINE('HAVE_NO_AIO', '1')
515 else:
516 conf.DEFINE('HAVE_NO_AIO', '1')
518 if host_os.rfind('linux') > -1:
519 conf.CHECK_FUNCS_IN('io_submit', 'aio')
520 conf.CHECK_CODE('''
521 struct io_event ioev;
522 struct iocb *ioc;
523 io_context_t ctx;
524 struct timespec ts;
525 int fd;
526 char *buf;
527 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
528 io_queue_init(128,&ctx);
529 io_prep_pwrite(ioc, 1, buf, 1, 0);
530 io_prep_pread(ioc, 1, buf, 1, 0);
531 io_set_eventfd(ioc, fd);
532 io_set_callback(ioc, (io_callback_t)(0));
533 io_submit(ctx, 1, &ioc);
534 io_getevents(ctx, 1, 1, &ioev, &ts);
535 ''',
536 'HAVE_LINUX_KERNEL_AIO',
537 msg='Checking for linux kernel asynchronous io support',
538 headers='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
539 lib='aio')
541 conf.CHECK_CODE('''
542 struct msghdr msg;
543 union {
544 struct cmsghdr cm;
545 char control[CMSG_SPACE(sizeof(int))];
546 } control_un;
547 msg.msg_control = control_un.control;
548 msg.msg_controllen = sizeof(control_un.control);
549 ''',
550 'HAVE_MSGHDR_MSG_CONTROL',
551 msg='Checking if we can use msg_control for passing file descriptors',
552 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
553 conf.CHECK_CODE('''
554 struct msghdr msg;
555 int fd;
556 msg.msg_acctrights = (caddr_t) &fd;
557 msg.msg_acctrightslen = sizeof(fd);
558 ''',
559 'HAVE_MSGHDR_MSG_ACCTRIGHTS',
560 msg='Checking if we can use msg_acctrights for passing file descriptors',
561 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
563 if Options.options.with_winbind:
564 conf.env.build_winbind = True
565 conf.DEFINE('WITH_WINBIND', '1')
567 conf.find_program('awk', var='AWK')
569 conf.CHECK_HEADERS('asm/types.h')
571 conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
572 headers='unistd.h sys/types.h',
573 msg="Checking for major macro")
575 conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
576 headers='unistd.h sys/types.h',
577 msg="Checking for minor macro")
579 conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
580 headers='unistd.h sys/types.h dirent.h',
581 define='HAVE_DIRENT_D_OFF')
583 conf.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
584 if conf.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
585 netgrent_cflags = '-Werror-implicit-function-declaration'
586 else:
587 netgrent_cflags = ''
588 conf.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
589 msg="Checking for setnetgrent prototype",
590 headers='netdb.h netgroup.h',
591 cflags=netgrent_cflags)
592 conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
593 msg="Checking for getnetgrent prototype",
594 headers='netdb.h netgroup.h',
595 cflags=netgrent_cflags)
596 conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
597 msg="Checking for endnetgrent prototype",
598 headers='netdb.h netgroup.h',
599 cflags=netgrent_cflags)
602 # Look for CUPS
603 if Options.options.with_cups:
604 conf.find_program('cups-config', var='CUPS_CONFIG')
605 if conf.env.CUPS_CONFIG:
606 # we would normally use --libs here, but cups-config incorrectly adds
607 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
608 # of an in-tree heimdal kerberos
609 conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
610 package="", uselib_store="CUPS")
611 conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
612 conf.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
613 if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
614 conf.DEFINE('HAVE_CUPS', '1')
615 else:
616 conf.undefine('HAVE_CUPS')
617 conf.SET_TARGET_TYPE('cups', 'EMPTY')
618 else:
619 # define an empty subsystem for cups, to allow it to be used as an empty dependency
620 conf.SET_TARGET_TYPE('cups', 'EMPTY')
622 if Options.options.with_iprint:
623 if conf.CONFIG_SET('HAVE_CUPS'):
624 conf.DEFINE('HAVE_IPRINT', '1')
625 else:
626 Logs.warn("--enable-iprint=yes but cups support not sufficient")
627 if Options.options.with_syslog:
628 conf.DEFINE('WITH_SYSLOG', '1')
629 if Options.options.with_automount:
630 conf.DEFINE('WITH_AUTOMOUNT', '1')
632 # Check for LDAP
633 if Options.options.with_ldap:
634 conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
635 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
636 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
637 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
639 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
640 # for the samba logs
641 conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
642 define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
644 conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
645 conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
647 # Check if ldap_set_rebind_proc() takes three arguments
648 if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
649 'LDAP_SET_REBIND_PROC_ARGS',
650 msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
651 headers='ldap.h lber.h', link=False):
652 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
653 else:
654 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
656 # last but not least, if ldap_init() exists, we want to use ldap
657 if conf.CONFIG_SET('HAVE_LDAP_INIT') and conf.CONFIG_SET('HAVE_LDAP_H'):
658 conf.DEFINE('HAVE_LDAP', '1')
659 conf.DEFINE('LDAP_DEPRECATED', '1')
660 conf.env['HAVE_LDAP'] = '1'
661 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
662 # SASL wrapping hooks
663 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
664 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
665 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
666 else:
667 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
668 conf.SET_TARGET_TYPE('lber', 'EMPTY')
670 if Options.options.with_ads == False:
671 use_ads = False
672 use_ads_krb5 = False
673 use_ads_ldap = False
674 else:
675 use_ads = True
676 use_ads_krb5 = True
677 use_ads_ldap = True
678 if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
679 not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
680 Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
681 use_ads_krb5 = False
682 if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
683 Logs.warn("krb5_mk_req_extended not found in -lkrb5")
684 use_ads_krb5 = False
685 if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
686 Logs.warn("krb5_get_host_realm not found in -lkrb5")
687 use_ads_krb5 = False
688 if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
689 Logs.warn("krb5_free_host_realm not found in -lkrb5")
690 use_ads_krb5 = False
691 if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
692 Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
693 use_ads_krb5 = False
694 if not conf.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
695 Logs.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
696 use_ads_krb5 = False
697 if not conf.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
698 Logs.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
699 use_ads_krb5 = False
700 if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
701 Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
702 use_ads_krb5 = False
703 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
704 Logs.warn("krb5_principal_compare_any_realm not found in -lkrb5")
705 use_ads_krb5 = False
706 if not conf.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
707 not conf.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
708 Logs.warn("krb5_c_string_to_key not found in -lkrb5")
709 use_ads_krb5 = False
710 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
711 not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
712 Logs.warn("no CREATE_KEY_FUNCTIONS detected")
713 use_ads_krb5 = False
714 if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
715 not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
716 Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
717 use_ads_krb5 = False
718 if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
719 not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
720 Logs.warn("no KT_FREE_FUNCTION detected")
721 use_ads_krb5 = False
722 if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
723 Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
724 use_ads_krb5 = False
726 # We don't actually use
727 # gsskrb5_extract_authz_data_from_sec_context, but it is a
728 # clue that this Heimdal, which does the PAC processing we
729 # need on the standard gss_inquire_sec_context_by_oid
730 if not conf.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
731 not (conf.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
732 conf.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
733 Logs.warn("need either gss_get_name_attribute or gsskrb5_extract_authz_data_from_sec_context and gss_inquire_sec_context_by_oid in -lgssapi for PAC support")
734 use_ads_krb5 = False
736 if not conf.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
737 Logs.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
738 use_ads_krb5 = False
740 if use_ads_krb5:
741 conf.DEFINE('HAVE_KRB5', '1')
742 conf.env['HAVE_KRB5'] = '1'
743 else:
744 conf.undefine('HAVE_KRB5_H')
745 conf.undefine('HAVE_GSSAPI_H')
746 conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
747 conf.undefine('HAVE_GSSAPI_GSSAPI_H')
748 use_ads = False
750 if not conf.CONFIG_SET('HAVE_LDAP'):
751 use_ads = False
752 use_ads_ldap = False
754 if use_ads:
755 conf.DEFINE('WITH_ADS', '1')
756 conf.env['HAVE_ADS'] = '1'
757 Logs.info("Building with Active Directory support.")
758 elif Options.options.with_ads == False:
759 Logs.info("Building without Active Directory support (--without-ads).")
760 else:
761 if not use_ads_krb5:
762 Logs.warn("Active Directory support not available: krb5 libs don't have all required features")
763 if not use_ads_ldap:
764 Logs.warn("Active Directory support not available: LDAP support ist not available.")
765 if Options.options.with_ads:
766 conf.fatal("Active Directory support not found. Use --without-ads for building without Active Directory support.")
767 else:
768 # this is the auto-mode case
769 Logs.warn("Building without Active Directory support.")
772 if Options.options.with_utmp:
773 conf.env.with_utmp = True
774 if not conf.CHECK_HEADERS('utmp.h'): conf.env.with_utmp = False
775 conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
776 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
777 define='HAVE_UT_UT_NAME')
778 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers='utmp.h',
779 define='HAVE_UT_UT_USER')
780 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers='utmp.h',
781 define='HAVE_UT_UT_ID')
782 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers='utmp.h',
783 define='HAVE_UT_UT_HOST')
784 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers='utmp.h',
785 define='HAVE_UT_UT_TIME')
786 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers='utmp.h',
787 define='HAVE_UT_UT_TV')
788 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers='utmp.h',
789 define='HAVE_UT_UT_TYPE')
790 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers='utmp.h',
791 define='HAVE_UT_UT_PID')
792 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers='utmp.h',
793 define='HAVE_UT_UT_EXIT')
794 conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers='utmpx.h',
795 define='HAVE_UX_UT_SYSLEN')
796 conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
797 'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
798 msg="Checking whether pututline returns pointer")
799 conf.CHECK_SIZEOF(['((struct utmp *)NULL)->ut_line'], headers='utmp.h',
800 define='SIZEOF_UTMP_UT_LINE')
801 if not conf.CONFIG_SET('SIZEOF_UTMP_UT_LINE'):
802 conf.env.with_utmp = False
803 elif int(conf.env.SIZEOF_UTMP_UT_LINE) < 15:
804 conf.env.with_utmp = False
805 if conf.env.with_utmp:
806 conf.DEFINE('WITH_UTMP', 1)
807 else:
808 Logs.warn("--with-utmp but utmp support not sufficient")
810 if Options.options.with_avahi:
811 conf.env.with_avahi = True
812 if not conf.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf.env.with_avahi = False
813 if not conf.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf.env.with_avahi = False
814 if not conf.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf.env.with_avahi = False
815 if conf.env.with_avahi:
816 conf.DEFINE('WITH_AVAHI_SUPPORT', 1)
817 else:
818 conf.SET_TARGET_TYPE('avahi-common', 'EMPTY')
819 conf.SET_TARGET_TYPE('avahi-client', 'EMPTY')
821 if Options.options.with_iconv:
822 conf.env.with_iconv = True
823 if not conf.CHECK_FUNCS_IN('iconv_open', 'iconv', headers='iconv.h'):
824 conf.env.with_iconv = False
825 if conf.env.with_iconv:
826 conf.DEFINE('HAVE_ICONV', 1)
828 if Options.options.with_pam:
829 use_pam=True
830 conf.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
831 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
832 Logs.warn("--with-pam=yes but pam_appl.h not found")
833 use_pam=False
834 conf.CHECK_FUNCS_IN('pam_get_data', 'pam')
835 conf.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
836 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
837 Logs.warn("--with-pam=yes but pam_modules.h not found")
838 use_pam=False
839 conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
840 conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
841 conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
842 conf.CHECK_CODE('''
843 #if defined(HAVE_SECURITY_PAM_APPL_H)
844 #include <security/pam_appl.h>
845 #elif defined(HAVE_PAM_PAM_APPL_H)
846 #include <pam/pam_appl.h>
847 #endif
848 pam_set_item(0, PAM_RHOST, 0);
849 ''',
850 'HAVE_PAM_RHOST',
851 lib='pam',
852 msg="Checking whether PAM_RHOST is available");
853 conf.CHECK_CODE('''
854 #if defined(HAVE_SECURITY_PAM_APPL_H)
855 #include <security/pam_appl.h>
856 #elif defined(HAVE_PAM_PAM_APPL_H)
857 #include <pam/pam_appl.h>
858 #endif
859 pam_set_item(0, PAM_TTY, 0);
860 ''',
861 'HAVE_PAM_TTY',
862 lib='pam',
863 msg="Checking whether PAM_TTY is available");
864 conf.CHECK_CODE('''
865 #if (!defined(LINUX))
867 #define PAM_EXTERN extern
868 #if defined(HAVE_SECURITY_PAM_APPL_H)
869 #include <security/pam_appl.h>
870 #elif defined(HAVE_PAM_PAM_APPL_H)
871 #include <pam/pam_appl.h>
872 #endif
874 #endif
876 #if defined(HAVE_SECURITY_PAM_MODULES_H)
877 #include <security/pam_modules.h>
878 #elif defined(HAVE_PAM_PAM_MODULES_H)
879 #include <pam/pam_modules.h>
880 #endif
882 #if defined(HAVE_SECURITY__PAM_MACROS_H)
883 #include <security/_pam_macros.h>
884 #elif defined(HAVE_PAM__PAM_MACROS_H)
885 #include <pam/_pam_macros.h>
886 #endif
888 #ifdef HAVE_SECURITY_PAM_EXT_H
889 #include <security/pam_ext.h>
890 #endif
892 int i; i = PAM_RADIO_TYPE;
893 ''',
894 'HAVE_PAM_RADIO_TYPE',
895 lib='pam',
896 msg="Checking whether PAM_RADIO_TYPE is available");
897 if use_pam:
898 conf.DEFINE('WITH_PAM', 1)
899 conf.DEFINE('WITH_PAM_MODULES', 1)
901 if Options.options.with_pam_smbpass:
902 conf.env.with_pam_smbpass = True
904 seteuid = False
907 # Ensure we select the correct set of system calls on Linux.
909 if (host_os.rfind('linux') > -1):
910 conf.CHECK_CODE('''
911 #if defined(HAVE_UNISTD_H)
912 #include <unistd.h>
913 #endif
914 #include <stdlib.h>
915 #include <stdio.h>
916 #include <sys/types.h>
917 #include <errno.h>
919 #ifdef HAVE_SYS_PRIV_H
920 #include <sys/priv.h>
921 #endif
922 #ifdef HAVE_SYS_ID_H
923 #include <sys/id.h>
924 #endif
926 #if defined(HAVE_SYSCALL_H)
927 #include <syscall.h>
928 #endif
930 #if defined(HAVE_SYS_SYSCALL_H)
931 #include <sys/syscall.h>
932 #endif
934 syscall(SYS_setresuid32, -1, -1, -1);
935 syscall(SYS_setresgid32, -1, -1, -1);
936 syscall(SYS_setreuid32, -1, -1);
937 syscall(SYS_setregid32, -1, -1);
938 syscall(SYS_setuid32, -1);
939 syscall(SYS_setgid32, -1);
940 syscall(SYS_setgroups32, 0, NULL);
941 ''',
942 'USE_LINUX_32BIT_SYSCALLS',
943 msg="Checking whether Linux should use 32-bit credential calls");
945 if (conf.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
946 seteuid = conf.CHECK_CODE('''
947 #define AUTOCONF_TEST 1
948 #define USE_LINUX_THREAD_CREDENTIALS 1
949 #define USE_LINUX_32BIT_SYSCALLS 1
950 #include "../lib/util/setid.c"
951 #include "./lib/util_sec.c"
952 ''',
953 'USE_LINUX_THREAD_CREDENTIALS',
954 addmain=False,
955 execute=True,
956 msg="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
957 else:
958 seteuid = conf.CHECK_CODE('''
959 #define AUTOCONF_TEST 1
960 #define USE_LINUX_THREAD_CREDENTIALS 1
961 #include "../lib/util/setid.c"
962 #include "./lib/util_sec.c"
963 ''',
964 'USE_LINUX_THREAD_CREDENTIALS',
965 addmain=False,
966 execute=True,
967 msg="Checking whether we can use Linux thread-specific credentials")
968 if not seteuid:
969 seteuid = conf.CHECK_CODE('''
970 #define AUTOCONF_TEST 1
971 #define USE_SETREUID 1
972 #include "../lib/util/setid.c"
973 #include "./lib/util_sec.c"
974 ''',
975 'USE_SETREUID',
976 addmain=False,
977 execute=True,
978 msg="Checking whether setreuid is available")
979 if not seteuid:
980 seteuid = conf.CHECK_CODE('''
981 #define AUTOCONF_TEST 1
982 #define USE_SETRESUID 1
983 #include "../lib/util/setid.c"
984 #include "./lib/util_sec.c"
985 ''',
986 'USE_SETRESUID',
987 addmain=False,
988 execute=True,
989 msg="Checking whether setresuid is available")
990 if not seteuid:
991 seteuid = conf.CHECK_CODE('''
992 #define AUTOCONF_TEST 1
993 #define USE_SETEUID 1
994 #include "../lib/util/setid.c"
995 #include "./lib/util_sec.c"
996 ''',
997 'USE_SETEUID',
998 addmain=False,
999 execute=True,
1000 msg="Checking whether seteuid is available")
1001 if not seteuid:
1002 seteuid = conf.CHECK_CODE('''
1003 #define AUTOCONF_TEST 1
1004 #define USE_SETUIDX 1
1005 #include "../lib/util/setid.c"
1006 #include "./lib/util_sec.c"
1007 ''',
1008 'USE_SETUIDX',
1009 addmain=False,
1010 execute=True,
1011 mandatory=True,
1012 msg="Checking whether setuidx is available")
1013 if Options.options.with_dnsupdate:
1014 if not conf.CONFIG_SET('HAVE_KRB5'):
1015 Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
1016 else:
1017 conf.DEFINE('WITH_DNS_UPDATES', 1)
1018 conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
1019 if Options.options.developer:
1020 if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
1021 conf.DEFINE('VALGRIND', '1')
1023 if conf.CHECK_CODE('''
1024 #include <bits/sockaddr.h>
1025 #include <linux/netlink.h>
1026 ''',
1027 'HAVE_LINUX_NETLINK_H',
1028 msg="Checking whether Linux netlink is available"):
1030 conf.CHECK_CODE('''
1031 #include <bits/sockaddr.h>
1032 #include <linux/netlink.h>
1033 #include <linux/rtnetlink.h>
1034 ''',
1035 'HAVE_LINUX_RTNETLINK_H',
1036 msg='Checking whether Linux rtnetlink is available')
1038 conf.CHECK_CODE('''
1039 #include "../tests/fcntl_lock.c"
1040 ''',
1041 'HAVE_FCNTL_LOCK',
1042 addmain=False,
1043 execute=True,
1044 msg='Checking whether fcntl locking is available')
1046 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
1047 if not conf.CHECK_CODE('''
1048 #define _XOPEN_SOURCE 600
1049 #include <stdlib.h>
1050 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
1051 #error probably broken posix_fallocate
1052 #endif
1053 ''',
1054 '_HAVE_UNBROKEN_POSIX_FALLOCATE',
1055 msg='Checking for broken posix_fallocate'):
1056 conf.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
1059 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1060 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1061 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1062 define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1063 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1064 define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1065 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1066 define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1067 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1068 define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1069 if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1070 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1071 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1072 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1073 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1074 conf.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1076 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1077 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1078 define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1079 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1080 define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1081 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1082 define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1084 conf.CHECK_CODE('''
1085 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1086 ''',
1087 'HAVE_POSIX_FADVISE',
1088 msg='Checking whether posix_fadvise is available',
1089 headers='unistd.h fcntl.h')
1091 for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1092 conf.CHECK_CODE('''
1093 #include <unistd.h>
1094 return sysconf(%s) == -1 ? 1 : 0;
1095 ''' % v,
1096 'SYSCONF%s' % v,
1097 msg='Checking whether sysconf(%s) is available' % v)
1099 conf.CHECK_CODE('''
1100 #include <sys/syscall.h>
1101 #include <unistd.h>
1102 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1103 ''',
1104 'HAVE_DARWIN_INITGROUPS',
1105 msg='Checking whether to use the Darwin-specific initgroups system call')
1107 conf.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1108 'HAVE_UTIMBUF',
1109 headers='sys/types.h utime.h',
1110 msg='Checking whether struct utimbuf is available')
1112 if conf.CHECK_CODE('''struct sigevent s;''',
1113 'HAVE_STRUCT_SIGEVENT',
1114 headers='sys/types.h stdlib.h stddef.h signal.h',
1115 msg='Checking whether we have the struct sigevent'):
1116 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1117 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1118 headers='signal.h');
1119 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1120 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1121 headers='signal.h');
1123 if os.path.exists('/proc/sys/kernel/core_pattern'):
1124 conf.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
1126 if conf.CHECK_CODE('''
1127 #include <time.h>
1128 main() {
1129 struct tm *tm;
1130 if (sizeof(time_t) == 8) {
1131 time_t max_time = 0x7fffffffffffffffll;
1132 tm = gmtime(&max_time);
1133 /* This should fail with 32-bit tm_year. */
1134 if (tm == NULL) {
1135 /* Max time_t that works with 32-bit int tm_year in struct tm. */
1136 max_time = 67768036191676799ll;
1137 tm = gmtime(&max_time);
1138 if (tm) {
1139 exit(0);
1143 exit(1);
1144 }''',
1145 '__TIME_T_MAX',
1146 addmain=False,
1147 execute=True,
1148 msg="Checking for the maximum value of the 'time_t' type"):
1149 conf.DEFINE('TIME_T_MAX', '67768036191676799ll')
1151 conf.CHECK_CODE('''
1152 #if defined(HAVE_UNISTD_H)
1153 #include <unistd.h>
1154 #endif
1155 #include <sys/types.h>
1156 main() { dev_t dev = makedev(1,2); return 0; }
1157 ''',
1158 'HAVE_MAKEDEV',
1159 addmain=False,
1160 msg='Checking whether the macro for makedev is available')
1162 conf.CHECK_CODE('''
1163 #include <stdio.h>
1164 #include <limits.h>
1165 #include <signal.h>
1167 void exit_on_core(int ignored) {
1168 exit(1);
1171 main() {
1172 char *newpath;
1173 signal(SIGSEGV, exit_on_core);
1174 newpath = realpath("/tmp", NULL);
1175 exit((newpath != NULL) ? 0 : 1);
1177 ''',
1178 'REALPATH_TAKES_NULL',
1179 addmain=False,
1180 execute=True,
1181 msg='Checking whether the realpath function allows a NULL argument')
1183 conf.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1184 'HAVE_FTRUNCATE_EXTEND',
1185 msg='Checking for ftruncate extend',
1186 addmain=False,
1187 execute=True)
1189 if Options.options.with_sendfile_support:
1190 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):
1191 conf.CHECK_CODE('''
1192 int tofd, fromfd;
1193 off_t offset;
1194 size_t total;
1195 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1196 ''',
1197 '_HAVE_SENDFILE',
1198 headers='sys/sendfile.h',
1199 msg='Checking for linux sendfile support')
1201 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1202 conf.DEFINE('HAVE_SENDFILE', '1')
1203 conf.DEFINE('LINUX_SENDFILE_API', '1')
1204 conf.DEFINE('WITH_SENDFILE', '1')
1205 elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
1206 conf.CHECK_CODE('''
1207 #include <sys/types.h>
1208 #include <unistd.h>
1209 #include <sys/socket.h>
1210 #include <sys/uio.h>
1211 int fromfd, tofd, ret, total=0;
1212 off_t offset, nwritten;
1213 struct sf_hdtr hdr;
1214 struct iovec hdtrl;
1215 hdr.headers = &hdtrl;
1216 hdr.hdr_cnt = 1;
1217 hdr.trailers = NULL;
1218 hdr.trl_cnt = 0;
1219 hdtrl.iov_base = NULL;
1220 hdtrl.iov_len = 0;
1221 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1222 ''',
1223 '_HAVE_SENDFILE',
1224 msg='Checking for freebsd sendfile support')
1225 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1226 conf.DEFINE('HAVE_SENDFILE', '1')
1227 conf.DEFINE('FREEBSD_SENDFILE_API', '1')
1228 conf.DEFINE('WITH_SENDFILE', '1')
1229 elif (host_os.rfind('darwin') > -1):
1230 conf.CHECK_CODE('''
1231 #include <sys/types.h>
1232 #include <sys/socket.h>
1233 #include <sys/uio.h>
1234 int fromfd, tofd, ret;
1235 off_t offset, nwritten;
1236 struct sf_hdtr hdr;
1237 struct iovec hdtrl;
1238 hdr.headers = &hdtrl;
1239 hdr.hdr_cnt = 1;
1240 hdr.trailers = (void *)0;
1241 hdr.trl_cnt = 0;
1242 hdtrl.iov_base = (void *)0;
1243 hdtrl.iov_len = 0;
1244 ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1245 ''',
1246 '_HAVE_SENDFILE',
1247 msg='Checking for darwin sendfile support')
1248 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1249 conf.DEFINE('HAVE_SENDFILE', '1')
1250 conf.DEFINE('DARWIN_SENDFILE_API', '1')
1251 conf.DEFINE('WITH_SENDFILE', '1')
1252 elif (host_os.rfind('hpux') > -1) or (host_os.rfind('osf') > -1):
1253 conf.CHECK_CODE('''
1254 #include <sys/socket.h>
1255 #include <sys/uio.h>
1256 int fromfd, tofd;
1257 size_t total=0;
1258 struct iovec hdtrl[2];
1259 ssize_t nwritten;
1260 off_t offset;
1261 hdtrl[0].iov_base = 0;
1262 hdtrl[0].iov_len = 0;
1263 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1264 ''',
1265 '_HAVE_SENDFILE',
1266 msg='Checking for osf/hpux sendfile support')
1267 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1268 conf.DEFINE('HAVE_SENDFILE', '1')
1269 conf.DEFINE('HPUX_SENDFILE_API', '1')
1270 conf.DEFINE('WITH_SENDFILE', '1')
1271 elif (host_os.rfind('solaris') > -1):
1272 conf.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1273 conf.CHECK_CODE('''
1274 #include <sys/sendfile.h>,
1275 int sfvcnt;
1276 size_t xferred;
1277 struct sendfilevec vec[2];
1278 ssize_t nwritten;
1279 int tofd;
1280 sfvcnt = 2;
1281 vec[0].sfv_fd = SFV_FD_SELF;
1282 vec[0].sfv_flag = 0;
1283 vec[0].sfv_off = 0;
1284 vec[0].sfv_len = 0;
1285 vec[1].sfv_fd = 0;
1286 vec[1].sfv_flag = 0;
1287 vec[1].sfv_off = 0;
1288 vec[1].sfv_len = 0;
1289 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1290 ''',
1291 '_HAVE_SENDFILEV',
1292 msg='Checking for solaris sendfilev support')
1293 if conf.CONFIG_SET('_HAVE_SENDFILEV'):
1294 conf.DEFINE('HAVE_SENDFILEV', '1')
1295 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1296 conf.DEFINE('WITH_SENDFILE', '1')
1297 elif (host_os.rfind('aix') > -1):
1298 conf.CHECK_CODE('''
1299 #include <sys/socket.h>
1300 int fromfd, tofd;
1301 size_t total=0;
1302 struct sf_parms hdtrl;
1303 ssize_t nwritten;
1304 hdtrl.header_data = 0;
1305 hdtrl.header_length = 0;
1306 hdtrl.file_descriptor = fromfd;
1307 hdtrl.file_offset = 0;
1308 hdtrl.file_bytes = 0;
1309 hdtrl.trailer_data = 0;
1310 hdtrl.trailer_length = 0;
1311 nwritten = send_file(&tofd, &hdtrl, 0);
1312 ''',
1313 '_HAVE_SENDFILE',
1314 msg='Checking for AIX send_file support')
1315 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1316 conf.DEFINE('HAVE_SENDFILE', '1')
1317 conf.DEFINE('AIX_SENDFILE_API', '1')
1318 conf.DEFINE('WITH_SENDFILE', '1')
1320 # Check for getcwd allowing a NULL arg.
1321 conf.CHECK_CODE('''
1322 #include <unistd.h>
1323 main() {
1324 char *s = getcwd(NULL,0);
1325 exit(s != NULL ? 0 : 1);
1326 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
1327 msg="getcwd takes a NULL argument")
1330 # UnixWare 7.x has its getspnam in -lgen
1331 conf.CHECK_FUNCS_IN('getspnam', 'gen')
1332 conf.CHECK_FUNCS_IN('getspnam', 'security')
1333 conf.CHECK_FUNCS_IN('getspnam', 'sec')
1335 if Options.options.with_quotas:
1336 # For quotas on Veritas VxFS filesystems
1337 conf.CHECK_HEADERS('sys/fs/vx_quota.h')
1338 # For sys/quota.h and linux/quota.h
1339 conf.CHECK_HEADERS('sys/quota.h')
1340 # For quotas on BSD systems
1341 conf.CHECK_HEADERS('ufs/ufs/quota.h')
1342 # For quotas on Linux XFS filesystems
1343 if conf.CHECK_HEADERS('xfs/xqm.h'):
1344 conf.DEFINE('HAVE_XFS_QUOTAS', '1')
1345 else:
1346 # For Irix XFS
1347 conf.CHECK_CODE('''
1348 #include "confdefs.h"
1349 #ifdef HAVE_SYS_TYPES_H
1350 #include <sys/types.h>
1351 #endif
1352 #ifdef HAVE_ASM_TYPES_H
1353 #include <asm/types.h>
1354 #endif
1355 #include <sys/quota.h>
1356 int i = Q_XGETQUOTA;''',
1357 define='HAVE_XFS_QUOTAS',
1358 msg='for XFS QUOTA in <sys/quota.h>',
1359 execute=False,
1360 local_include=False)
1362 # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
1363 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define='HAVE_DQB_FSOFTLIMIT',
1364 headers='sys/quota.h')
1365 #darwin style quota bytecount
1366 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_curbytes', define='HAVE_STRUCT_DQBLK_DQB_CURBYTES',
1367 headers='sys/quota.h')
1368 if conf.CHECK_HEADERS('rpcsvc/rquota.h'):
1369 conf.DEFINE('HAVE_NFS_QUOTAS', '1')
1370 conf.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1371 define='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1372 headers='rpcsvc/rquota.h')
1374 if (host_os.rfind('linux') > -1):
1375 conf.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1376 elif not conf.CONFIG_SET("HAVE_XFS_QUOTAS"):
1377 if not conf.CHECK_CODE('''
1378 #define HAVE_QUOTACTL_4A 1
1379 #define AUTOCONF_TEST 1
1380 #include "../tests/sysquotas.c"
1381 ''',
1382 cflags=conf.env['WERROR_CFLAGS'],
1383 define='HAVE_QUOTACTL_4A',
1384 msg='for QUOTACTL_4A: long quotactl(int cmd, char *special, qid_t id, caddr_t addr)',
1385 execute=True,
1386 addmain=False):
1388 conf.CHECK_CODE('''
1389 #define HAVE_QUOTACTL_4B 1
1390 #define AUTOCONF_TEST 1
1391 #include "../tests/sysquotas.c"
1392 ''',
1393 cflags=conf.env['WERROR_CFLAGS'],
1394 define='HAVE_QUOTACTL_4B',
1395 msg='for QUOTACTL_4B: int quotactl(const char *path, int cmd, int id, char *addr)',
1396 execute=True,
1397 addmain=False)
1399 conf.CHECK_CODE('''
1400 clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
1401 ''',
1402 headers="rpc/rpc.h rpc/types.h rpcsvc/rquota.h rpc/nettype.h rpc/xdr.h",
1403 define='HAVE_NFS_QUOTAS',
1404 msg='for NFS QUOTAS',
1405 execute=True,
1406 local_include=False)
1408 if conf.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1409 conf.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1410 conf.CONFIG_SET('HAVE_QUOTACTL_4B') or \
1411 conf.CONFIG_SET('HAVE_XFS_QUOTAS'):
1412 conf.DEFINE('HAVE_SYS_QUOTAS', '1')
1413 conf.DEFINE('WITH_QUOTAS', '1')
1416 # checking for clustering extensions (CTDB)
1418 if Options.options.with_cluster_support == False:
1419 # configure is called with --without-cluster-support,
1420 # so don't check for and build w/o ctdb support.
1421 have_cluster_support = False
1423 else:
1425 if Options.options.ctdb_dir:
1426 conf.ADD_EXTRA_INCLUDES(Options.options.ctdb_dir + '/include')
1428 srcdir = os.path.realpath(conf.srcdir)
1429 if 'EXTRA_INCLUDES' in conf.env:
1430 includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/')
1431 else:
1432 includes = ''
1434 if not conf.env.USING_SYSTEM_TDB:
1435 includes = includes + ' ' + srcdir + '/lib/tdb/include'
1437 if not conf.env.USING_SYSTEM_TALLOC:
1438 includes = includes + ' ' + srcdir + '/lib/talloc'
1440 have_cluster_support = True
1441 ctdb_broken = ""
1443 conf.CHECK_CODE('''
1444 #define NO_CONFIG_H
1445 #include "replace.h"
1446 #include "system/wait.h"
1447 #include "system/network.h"
1448 #define private #error __USED_RESERVED_WORD_private__
1449 #include <talloc.h>
1450 #include <tdb.h>
1451 #include <ctdb.h>
1453 int main(void)
1455 return 0;
1457 ''',
1458 'HAVE_CTDB_H',
1459 addmain=False,
1460 includes=includes,
1461 msg='Checking for header ctdb.h')
1463 if not conf.CONFIG_SET('HAVE_CTDB_H'):
1464 have_cluster_support = False
1465 ctdb_broken = "ctdb.h is required for cluster support"
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 #define private #error __USED_RESERVED_WORD_private__
1474 #include <talloc.h>
1475 #include <tdb.h>
1476 #include <ctdb.h>
1477 #include <ctdb_private.h>
1479 int main(void)
1481 return 0;
1483 ''',
1484 'HAVE_CTDB_PRIVATE_H',
1485 addmain=False,
1486 includes=includes,
1487 msg='Checking for header ctdb_private.h')
1489 if not conf.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
1490 have_cluster_support = False
1491 ctdb_broken = "ctdb_private.h is required for cluster support"
1493 if have_cluster_support:
1494 conf.CHECK_CODE('''
1495 #define NO_CONFIG_H
1496 #include "replace.h"
1497 #include "system/wait.h"
1498 #include "system/network.h"
1499 #define private #error __USED_RESERVED_WORD_private__
1500 #include <talloc.h>
1501 #include <tdb.h>
1502 #include <ctdb.h>
1503 #include <ctdb_protocol.h>
1505 int main(void)
1507 return 0;
1509 ''',
1510 'HAVE_CTDB_PROTOCOL_H',
1511 addmain=False,
1512 includes=includes,
1513 msg='Checking for header ctdb_protocol.h')
1515 if have_cluster_support:
1516 conf.CHECK_CODE('''
1517 #define NO_CONFIG_H
1518 #include "replace.h"
1519 #include "system/wait.h"
1520 #include "system/network.h"
1521 #include <talloc.h>
1522 #include <tdb.h>
1523 #include <ctdb.h>
1524 #include <ctdb_private.h>
1526 int main(void)
1528 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1529 return 0;
1531 ''',
1532 'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
1533 addmain=False,
1534 includes=includes,
1535 msg='Checking for transaction support (TRANS3_COMMIT control)')
1537 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
1538 have_cluster_support = False
1539 ctdb_broken = "ctdb transaction support missing or too old"
1541 if have_cluster_support:
1542 conf.CHECK_CODE('''
1543 #define NO_CONFIG_H
1544 #include "replace.h"
1545 #include "system/wait.h"
1546 #include "system/network.h"
1547 #include <talloc.h>
1548 #include <tdb.h>
1549 #include <ctdb.h>
1550 #include <ctdb_private.h>
1552 int main(void)
1554 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1555 return 0;
1557 ''',
1558 'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
1559 addmain=False,
1560 includes=includes,
1561 msg='Checking for SCHEDULE_FOR_DELETION control')
1563 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
1564 if not Options.options.enable_old_ctdb:
1565 have_cluster_support = False
1566 ctdb_broken = "SCHEDULE_FOR_DELETION control missing"
1567 else:
1568 Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1570 if have_cluster_support:
1571 conf.CHECK_CODE('''
1572 #define NO_CONFIG_H
1573 #include "replace.h"
1574 #include "system/wait.h"
1575 #include "system/network.h"
1576 #include <talloc.h>
1577 #include <tdb.h>
1578 #include <ctdb.h>
1580 int main(void)
1582 int i = (int)CTDB_WANT_READONLY;
1583 return 0;
1585 ''',
1586 'HAVE_CTDB_WANT_READONLY_DECL',
1587 addmain=False,
1588 includes=includes,
1589 msg='Checking for CTDB readonly records support')
1591 if not conf.CONFIG_SET('HAVE_CTDB_WANT_READONLY_DECL'):
1592 if not Options.options.enable_old_ctdb:
1593 have_cluster_support = False
1594 ctdb_broken = "support for CTDB readonly records missing"
1595 else:
1596 Logs.warn("ignoring missing READONLY support (--enable-old-ctdb)")
1598 if have_cluster_support:
1599 conf.CHECK_CODE('''
1600 #define NO_CONFIG_H
1601 #include "replace.h"
1602 #include "system/wait.h"
1603 #include "system/network.h"
1604 #include <talloc.h>
1605 #include <tdb.h>
1606 #include <ctdb.h>
1607 #include <ctdb_private.h>
1609 int main(void)
1611 struct ctdb_control_tcp _x;
1612 return 0;
1614 ''',
1615 'HAVE_STRUCT_CTDB_CONTROL_TCP',
1616 addmain=False,
1617 includes=includes,
1618 msg='Checking for ctdb ipv4 support')
1620 if not conf.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
1621 have_cluster_support = False
1622 ctdb_broken = "missing struct ctdb_control_tcp"
1624 if have_cluster_support:
1625 conf.CHECK_CODE('''
1626 #define NO_CONFIG_H
1627 #include "replace.h"
1628 #include "system/wait.h"
1629 #include "system/network.h"
1630 #include <talloc.h>
1631 #include <tdb.h>
1632 #include <ctdb.h>
1633 #include <ctdb_private.h>
1635 int main(void)
1637 struct ctdb_control_tcp_addr _x;
1638 return 0;
1640 ''',
1641 'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
1642 addmain=False,
1643 includes=includes,
1644 msg='Checking for ctdb ipv6 support')
1646 if have_cluster_support:
1647 conf.CHECK_CODE('''
1648 #define NO_CONFIG_H
1649 #include "replace.h"
1650 #include "system/wait.h"
1651 #include "system/network.h"
1652 #include <talloc.h>
1653 #include <tdb.h>
1654 #include <ctdb.h>
1655 #include <ctdb_private.h>
1657 int main(void)
1659 int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1660 return 0;
1662 ''',
1663 'HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL',
1664 addmain=False,
1665 includes=includes,
1666 msg='Checking for CHECK_SRVIDS control')
1668 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL'):
1669 if not Options.options.enable_old_ctdb:
1670 have_cluster_support = False
1671 ctdb_broken = "CHECK_SRVIDS control missing"
1672 else:
1673 Logs.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1675 if have_cluster_support:
1676 Logs.info("building with cluster support")
1677 conf.DEFINE('CLUSTER_SUPPORT', 1);
1678 else:
1679 if Options.options.with_cluster_support == False:
1680 Logs.info("building without cluster support (--without-cluster-support)")
1681 elif Options.options.with_cluster_support == True:
1682 Logs.error("Cluster support not available: " + ctdb_broken)
1683 conf.fatal("Cluster support not found, but --with-cluster-support was specified")
1684 else:
1685 Logs.info("building without cluster support: " + ctdb_broken)
1686 conf.undefine('CLUSTER_SUPPORT')
1689 conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1690 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1691 addmain=False,
1692 link=False,
1693 msg='Checking whether we can compile with __attribute__((destructor))')
1695 conf.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1696 'SEEKDIR_RETURNS_VOID',
1697 headers='sys/types.h dirent.h',
1698 msg='Checking whether seekdir returns void')
1700 if Options.options.with_profiling_data:
1701 conf.DEFINE('WITH_PROFILE', 1);
1703 PTHREAD_CFLAGS='error'
1704 PTHREAD_LDFLAGS='error'
1706 if PTHREAD_LDFLAGS == 'error':
1707 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
1708 PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
1709 PTHREAD_LDFLAGS='-lpthread'
1710 if PTHREAD_LDFLAGS == 'error':
1711 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
1712 PTHREAD_CFLAGS='-D_THREAD_SAFE'
1713 PTHREAD_LDFLAGS='-lpthreads'
1714 if PTHREAD_LDFLAGS == 'error':
1715 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
1716 PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread'
1717 PTHREAD_LDFLAGS='-pthread'
1718 if PTHREAD_LDFLAGS == 'error':
1719 if conf.CHECK_FUNCS('pthread_attr_init'):
1720 PTHREAD_CFLAGS='-D_REENTRANT'
1721 PTHREAD_LDFLAGS='-lpthread'
1722 # especially for HP-UX, where the CHECK_FUNC macro fails to test for
1723 # pthread_attr_init. On pthread_mutex_lock it works there...
1724 if PTHREAD_LDFLAGS == 'error':
1725 if conf.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
1726 PTHREAD_CFLAGS='-D_REENTRANT'
1727 PTHREAD_LDFLAGS='-lpthread'
1729 if PTHREAD_CFLAGS != 'error' and PTHREAD_LDFLAGS != 'error':
1730 conf.ADD_CFLAGS(PTHREAD_CFLAGS)
1731 conf.ADD_LDFLAGS(PTHREAD_LDFLAGS)
1732 conf.CHECK_HEADERS('pthread.h')
1733 conf.DEFINE('HAVE_PTHREAD', '1')
1735 if Options.options.with_pthreadpool:
1736 if conf.CONFIG_SET('HAVE_PTHREAD'):
1737 conf.DEFINE('WITH_PTHREADPOOL', '1')
1738 else:
1739 Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
1740 conf.undefine('WITH_PTHREADPOOL')
1742 if conf.CHECK_HEADERS('gpfs_gpl.h'):
1743 conf.DEFINE('HAVE_GPFS', '1')
1745 if conf.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h'):
1746 conf.DEFINE('HAVE_LINUX_IOCTL', '1')
1748 conf.env['CCFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64"
1749 if Options.options.libcephfs_dir:
1750 conf.env['CPPPATH_CEPHFS'] = Options.options.libcephfs_dir + '/include'
1751 conf.env['LIBPATH_CEPHFS'] = Options.options.libcephfs_dir + '/lib'
1753 if conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and conf.CHECK_LIB('cephfs'):
1754 conf.DEFINE('HAVE_CEPH', '1')
1756 if Options.options.with_glusterfs:
1757 conf.check_cfg(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs',
1758 msg='Checking for glusterfs-api >= 4', uselib_store="GFAPI")
1759 conf.CHECK_HEADERS('api/glfs.h', lib='gfapi')
1760 conf.CHECK_LIB('gfapi', shlib=True)
1762 if conf.CONFIG_SET('HAVE_API_GLFS_H'):
1763 conf.DEFINE('HAVE_GLUSTERFS', '1')
1764 else:
1765 conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
1766 conf.undefine('HAVE_GLUSTERFS')
1767 else:
1768 conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
1769 conf.undefine('HAVE_GLUSTERFS')
1771 conf.env.build_regedit = False
1772 if not Options.options.with_regedit == False:
1773 conf.PROCESS_SEPARATE_RULE('system_ncurses')
1774 if conf.CONFIG_SET('HAVE_NCURSES'):
1775 conf.env.build_regedit = True
1777 if conf.env.build_regedit:
1778 Logs.info("building regedit")
1779 else:
1780 if Options.options.with_regedit == False:
1781 Logs.info("not building regedit (--without-regedit)")
1782 elif Options.options.with_regedit == True:
1783 Logs.error("ncurses not available, cannot build regedit")
1784 conf.fatal("ncurses not available, but --with-regedit was specified")
1785 else:
1786 Logs.info("ncurses not available, not building regedit")
1789 default_static_modules.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1790 auth_sam auth_unix auth_winbind auth_wbc
1791 auth_domain auth_builtin vfs_default
1792 nss_info_template idmap_tdb idmap_passdb
1793 idmap_nss'''))
1795 default_shared_modules.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1796 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1797 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1798 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1799 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1800 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1801 vfs_media_harmony
1802 vfs_commit
1803 vfs_crossrename vfs_linux_xfs_sgid
1804 vfs_time_audit idmap_autorid idmap_tdb2
1805 idmap_rid idmap_hash idmap_rfc2307'''))
1807 if Options.options.developer:
1808 default_static_modules.extend(TO_LIST('charset_weird'))
1809 default_shared_modules.extend(TO_LIST('perfcount_test'))
1810 default_shared_modules.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1811 default_shared_modules.extend(TO_LIST('auth_skel pdb_test'))
1813 if Options.options.enable_selftest or Options.options.developer:
1814 default_shared_modules.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr'))
1817 if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1818 default_static_modules.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
1820 if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1821 default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
1823 if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
1824 default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1826 if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
1827 default_shared_modules.extend(TO_LIST('vfs_fileid'))
1829 if (conf.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
1830 default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
1832 if Options.options.with_pthreadpool:
1833 default_shared_modules.extend(TO_LIST('vfs_aio_pthread'))
1835 if conf.CONFIG_SET('HAVE_AIO'):
1836 default_shared_modules.extend(TO_LIST('vfs_aio_posix'))
1838 if conf.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1839 default_shared_modules.extend(TO_LIST('vfs_aio_linux'))
1841 if conf.CONFIG_SET('HAVE_LDAP'):
1842 default_static_modules.extend(TO_LIST('pdb_ldapsam idmap_ldap'))
1844 if conf.CONFIG_SET('DARWINOS'):
1845 default_static_modules.extend(TO_LIST('charset_macosxfs'))
1847 if conf.CONFIG_SET('HAVE_GPFS'):
1848 default_shared_modules.extend(TO_LIST('vfs_gpfs'))
1850 if conf.CONFIG_SET('HAVE_LINUX_IOCTL'):
1851 default_shared_modules.extend(TO_LIST('vfs_btrfs'))
1853 if conf.CONFIG_SET('SAMBA_FAM_LIBS'):
1854 default_shared_modules.extend(TO_LIST('vfs_notify_fam'))
1856 if conf.CONFIG_SET("HAVE_CEPH"):
1857 default_shared_modules.extend(TO_LIST('vfs_ceph'))
1859 if conf.CONFIG_SET('HAVE_GLUSTERFS'):
1860 default_shared_modules.extend(TO_LIST('vfs_glusterfs'))
1862 explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
1863 explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
1865 def replace_list_item(lst, item, value):
1866 try:
1867 idx = lst.index(item)
1868 lst[idx] = value
1869 except:
1870 pass
1871 # PDB module file name should have the same name as module registers itself
1872 # In Autoconf build we export LDAP passdb module as ldapsam but WAF build
1873 # was always exporting pdb_ldap. In order to support existing packages
1874 # allow referring to pdb_ldapsam as pdb_ldap but use proper name internally.
1875 replace_list_item(explicit_shared_modules, 'pdb_ldap', 'pdb_ldapsam')
1876 replace_list_item(explicit_static_modules, 'pdb_ldap', 'pdb_ldapsam')
1878 final_static_modules = default_static_modules
1879 final_shared_modules = default_shared_modules
1881 for m in explicit_static_modules:
1882 if m in final_shared_modules:
1883 final_shared_modules.remove(m)
1884 final_static_modules.append(m)
1885 for m in explicit_shared_modules:
1886 if m in final_static_modules:
1887 final_static_modules.remove(m)
1888 final_shared_modules.append(m)
1890 if ("auth_domain" not in final_static_modules) or \
1891 ("auth_builtin" not in final_static_modules) or \
1892 ("auth_sam" not in final_static_modules) or \
1893 ("auth_winbind" not in final_static_modules):
1894 raise Utils.WafError('These auth modules MUST be configured as static modules: auth_domain, auth_builtin, auth_sam, auth_winbind')
1896 conf.env['static_modules'] = final_static_modules
1897 conf.env['shared_modules'] = final_shared_modules
1899 conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
1901 static_list = {}
1902 shared_list = {}
1904 prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1905 conf.env['MODULE_PREFIXES'] = prefixes
1906 for p in prefixes:
1907 for m in final_static_modules:
1908 if m.find(p) == 0:
1909 if not p in static_list:
1910 static_list[p] = []
1911 static_list[p].append(m)
1912 for m in final_shared_modules:
1913 if m.find(p) == 0:
1914 if not p in shared_list:
1915 shared_list[p] = []
1916 shared_list[p].append(m)
1918 for p in prefixes:
1919 static_env = "%s_STATIC" % p.upper()
1920 shared_env = "%s_SHARED" % p.upper()
1921 conf.env[static_env] = []
1922 conf.env[shared_env] = []
1923 if p in static_list:
1924 decl_list=""
1925 for entry in static_list[p]:
1926 decl_list += "extern NTSTATUS %s_init(void); " % entry
1927 conf.env[static_env].append('%s' % entry)
1928 decl_list = decl_list.rstrip()
1929 conf.DEFINE('static_decl_%s' % p, decl_list)
1930 conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
1931 else:
1932 conf.DEFINE('static_decl_%s' % p, '')
1933 conf.DEFINE('static_init_%s' % p, '{}')
1934 if p in shared_list:
1935 for entry in shared_list[p]:
1936 conf.DEFINE('%s_init' % entry, 'samba_init_module')
1937 conf.env[shared_env].append('%s' % entry)
1939 conf.SAMBA_CONFIG_H('include/config.h')
1941 def ctags(ctx):
1942 "build 'tags' file using ctags"
1943 import Utils
1944 source_root = os.path.dirname(Utils.g_module.root_path)
1945 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1946 print("Running: %s" % cmd)
1947 os.system(cmd)