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