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