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