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