librpc/rpc: add DCERPC_AUTH_PAD_LENGTH(stub_length) helper macro
[Samba.git] / source3 / wscript
bloba5c83583d16d398c271a2b60aa1df5c55b7aa452
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 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
324 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
325 # -- JRA.
326 if conf.CONFIG_SET("HAVE_RPC_RPC_H"):
327 conf.CHECK_TYPE('int16', headers='rpc/rpc.h',
328 define='HAVE_INT16_FROM_RPC_RPC_H',
329 msg="Checking for int16 typedef included by rpc/rpc.h")
330 conf.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
331 headers='sys/types.h rpc/rpc.h',
332 msg="Checking for uint16 typedef included by rpc/rpc.h")
333 conf.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
334 headers='sys/types.h rpc/rpc.h',
335 msg="Checking for int32 typedef included by rpc/rpc.h")
336 conf.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
337 headers='sys/types.h rpc/rpc.h',
338 msg="Checking for uint32 typedef included by rpc/rpc.h")
339 conf.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
340 headers='sys/types.h sys/acl.h rpcsvc/nis.h',
341 msg="Checking for broken nisplus include files")
343 # Check if the compiler will optimize out functions
344 conf.CHECK_CODE('''
345 if (0) {
346 this_function_does_not_exist();
347 } else {
348 return 1;
349 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
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 elif conf.CHECK_FUNCS_IN(['facl'], 'sec'):
473 Logs.info('Using solaris or UnixWare ACLs')
474 conf.DEFINE('HAVE_SOLARIS_UNIXWARE_ACLS',1)
475 default_static_modules.extend(TO_LIST('vfs_solarisacl'))
476 elif conf.CHECK_FUNCS_IN(['acl_get_fd'], 'pacl'):
477 Logs.info('Using Tru64 ACLs')
478 conf.DEFINE('HAVE_TRU64_ACLS',1)
479 default_static_modules.extend(TO_LIST('vfs_tru64acl'))
480 else:
481 conf.fatal("ACL support not found. Try installing libacl1-dev "
482 "or libacl-devel. "
483 "Otherwise, use --without-acl-support to build "
484 "without ACL support. "
485 "ACL support is required to change permissions from "
486 "Windows clients.")
488 if conf.CHECK_FUNCS('dirfd'):
489 conf.DEFINE('HAVE_DIRFD_DECL', 1)
491 conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
492 'HAVE_STATFS_F_FSID',
493 msg="vfs_fileid checking for statfs() and struct statfs.f_fsid",
494 headers='sys/types.h sys/statfs.h',
495 execute=True)
497 if conf.CONFIG_SET('HAVE_FALLOCATE'):
498 conf.CHECK_CODE('''
499 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
500 'HAVE_LINUX_FALLOCATE',
501 msg="Checking whether the Linux 'fallocate' function is available",
502 headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
503 conf.CHECK_CODE('''
504 ssize_t err = readahead(0,0,0x80000);''',
505 'HAVE_LINUX_READAHEAD',
506 msg="Checking whether Linux readahead is available",
507 headers='unistd.h fcntl.h')
508 conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
510 conf.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
511 'HAVE_OPENAT',
512 msg='Checking for openat',
513 headers='fcntl.h')
515 if Options.options.with_aio_support:
516 conf.CHECK_FUNCS_IN('aio_read', 'aio')
517 conf.CHECK_FUNCS_IN('aio_read', 'rt')
518 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);',
519 'HAVE_AIO',
520 msg='Checking for asynchronous io support',
521 headers='sys/types.h aio.h',
522 lib='aio rt')
523 if conf.CONFIG_SET('HAVE_AIO'):
524 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg='Checking for aio_read', headers='aio.h', lib='aio rt')
525 conf.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg='Checking for aio_write', headers='aio.h', lib='aio rt')
526 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')
527 conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
528 conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
529 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')
530 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')
531 if not conf.CONFIG_SET('HAVE_AIO'):
532 conf.DEFINE('HAVE_NO_AIO', '1')
533 else:
534 conf.DEFINE('HAVE_NO_AIO', '1')
536 if host_os.rfind('linux') > -1:
537 conf.CHECK_FUNCS_IN('io_submit', 'aio')
538 conf.CHECK_CODE('''
539 struct io_event ioev;
540 struct iocb *ioc;
541 io_context_t ctx;
542 struct timespec ts;
543 int fd;
544 char *buf;
545 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
546 io_queue_init(128,&ctx);
547 io_prep_pwrite(ioc, 1, buf, 1, 0);
548 io_prep_pread(ioc, 1, buf, 1, 0);
549 io_set_eventfd(ioc, fd);
550 io_set_callback(ioc, (io_callback_t)(0));
551 io_submit(ctx, 1, &ioc);
552 io_getevents(ctx, 1, 1, &ioev, &ts);
553 ''',
554 'HAVE_LINUX_KERNEL_AIO',
555 msg='Checking for linux kernel asynchronous io support',
556 headers='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
557 lib='aio')
559 conf.CHECK_CODE('''
560 struct msghdr msg;
561 union {
562 struct cmsghdr cm;
563 char control[CMSG_SPACE(sizeof(int))];
564 } control_un;
565 msg.msg_control = control_un.control;
566 msg.msg_controllen = sizeof(control_un.control);
567 ''',
568 'HAVE_STRUCT_MSGHDR_MSG_CONTROL',
569 msg='Checking if we can use msg_control for passing file descriptors',
570 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
571 conf.CHECK_CODE('''
572 struct msghdr msg;
573 int fd;
574 msg.msg_accrights = (caddr_t) &fd;
575 msg.msg_accrightslen = sizeof(fd);
576 ''',
577 'HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS',
578 msg='Checking if we can use msg_accrights for passing file descriptors',
579 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
581 if Options.options.with_winbind:
582 conf.env.build_winbind = True
583 conf.DEFINE('WITH_WINBIND', '1')
585 conf.find_program('awk', var='AWK')
587 conf.CHECK_HEADERS('asm/types.h')
589 conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
590 headers='unistd.h sys/types.h',
591 msg="Checking for major macro")
593 conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
594 headers='unistd.h sys/types.h',
595 msg="Checking for minor macro")
597 conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
598 headers='unistd.h sys/types.h dirent.h',
599 define='HAVE_DIRENT_D_OFF')
601 conf.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
602 if conf.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
603 netgrent_cflags = '-Werror-implicit-function-declaration'
604 else:
605 netgrent_cflags = ''
606 conf.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
607 msg="Checking for setnetgrent prototype",
608 headers='netdb.h netgroup.h',
609 cflags=netgrent_cflags)
610 conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
611 msg="Checking for getnetgrent prototype",
612 headers='netdb.h netgroup.h',
613 cflags=netgrent_cflags)
614 conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
615 msg="Checking for endnetgrent prototype",
616 headers='netdb.h netgroup.h',
617 cflags=netgrent_cflags)
620 # Look for CUPS
621 if Options.options.with_cups:
622 conf.find_program('cups-config', var='CUPS_CONFIG')
623 if conf.env.CUPS_CONFIG:
624 # we would normally use --libs here, but cups-config incorrectly adds
625 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
626 # of an in-tree heimdal kerberos
627 conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
628 package="", uselib_store="CUPS")
629 conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
630 conf.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
631 if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
632 conf.DEFINE('HAVE_CUPS', '1')
633 else:
634 conf.undefine('HAVE_CUPS')
635 conf.SET_TARGET_TYPE('cups', 'EMPTY')
636 else:
637 # define an empty subsystem for cups, to allow it to be used as an empty dependency
638 conf.SET_TARGET_TYPE('cups', 'EMPTY')
640 if Options.options.with_iprint:
641 if conf.CONFIG_SET('HAVE_CUPS'):
642 conf.DEFINE('HAVE_IPRINT', '1')
643 else:
644 Logs.warn("--enable-iprint=yes but cups support not sufficient")
645 if Options.options.with_syslog:
646 conf.DEFINE('WITH_SYSLOG', '1')
647 if Options.options.with_automount:
648 conf.DEFINE('WITH_AUTOMOUNT', '1')
650 # Check for LDAP
651 if Options.options.with_ldap:
652 conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
653 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
654 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
655 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
657 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
658 # for the samba logs
659 conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
660 define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
662 conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
663 conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
665 # Check if ldap_set_rebind_proc() takes three arguments
666 if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
667 'LDAP_SET_REBIND_PROC_ARGS',
668 msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
669 headers='ldap.h lber.h', link=False):
670 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
671 else:
672 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
674 # last but not least, if ldap_init() exists, we want to use ldap
675 if conf.CONFIG_SET('HAVE_LDAP_INIT') and conf.CONFIG_SET('HAVE_LDAP_H'):
676 conf.DEFINE('HAVE_LDAP', '1')
677 conf.DEFINE('LDAP_DEPRECATED', '1')
678 conf.env['HAVE_LDAP'] = '1'
679 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
680 # SASL wrapping hooks
681 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
682 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
683 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
684 else:
685 conf.fatal("LDAP support not found. "
686 "Try installing libldap2-dev or openldap-devel. "
687 "Otherwise, use --without-ldap to build without "
688 "LDAP support. "
689 "LDAP support is required for the LDAP passdb backend, "
690 "LDAP idmap backends and ADS. "
691 "ADS support improves communication with "
692 "Active Directory domain controllers.")
693 else:
694 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
695 conf.SET_TARGET_TYPE('lber', 'EMPTY')
697 if Options.options.with_ads == False:
698 use_ads = False
699 use_ads_krb5 = False
700 use_ads_ldap = False
701 else:
702 use_ads = True
703 use_ads_krb5 = True
704 use_ads_ldap = True
705 if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
706 not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
707 Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
708 use_ads_krb5 = False
709 if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
710 Logs.warn("krb5_mk_req_extended not found in -lkrb5")
711 use_ads_krb5 = False
712 if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
713 Logs.warn("krb5_get_host_realm not found in -lkrb5")
714 use_ads_krb5 = False
715 if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
716 Logs.warn("krb5_free_host_realm not found in -lkrb5")
717 use_ads_krb5 = False
718 if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
719 Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
720 use_ads_krb5 = False
721 if not conf.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
722 Logs.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
723 use_ads_krb5 = False
724 if not conf.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
725 Logs.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
726 use_ads_krb5 = False
727 if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
728 Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
729 use_ads_krb5 = False
730 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
731 Logs.warn("krb5_principal_compare_any_realm not found in -lkrb5")
732 use_ads_krb5 = False
733 if not conf.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
734 not conf.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
735 Logs.warn("krb5_c_string_to_key not found in -lkrb5")
736 use_ads_krb5 = False
737 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
738 not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
739 Logs.warn("no CREATE_KEY_FUNCTIONS detected")
740 use_ads_krb5 = False
741 if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
742 not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
743 Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
744 use_ads_krb5 = False
745 if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
746 not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
747 Logs.warn("no KT_FREE_FUNCTION detected")
748 use_ads_krb5 = False
749 if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
750 Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
751 use_ads_krb5 = False
753 # We don't actually use
754 # gsskrb5_extract_authz_data_from_sec_context, but it is a
755 # clue that this Heimdal, which does the PAC processing we
756 # need on the standard gss_inquire_sec_context_by_oid
757 if not conf.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
758 not (conf.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
759 conf.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
760 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")
761 use_ads_krb5 = False
763 if not conf.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
764 Logs.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
765 use_ads_krb5 = False
767 if use_ads_krb5:
768 conf.DEFINE('HAVE_KRB5', '1')
769 conf.env['HAVE_KRB5'] = '1'
770 else:
771 conf.undefine('HAVE_KRB5_H')
772 conf.undefine('HAVE_GSSAPI_H')
773 conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
774 conf.undefine('HAVE_GSSAPI_GSSAPI_H')
775 use_ads = False
777 if not conf.CONFIG_SET('HAVE_LDAP'):
778 use_ads = False
779 use_ads_ldap = False
781 if use_ads:
782 conf.DEFINE('WITH_ADS', '1')
783 conf.env['HAVE_ADS'] = '1'
784 Logs.info("Building with Active Directory support.")
785 elif Options.options.with_ads == False:
786 Logs.info("Building without Active Directory support (--without-ads).")
787 else:
788 if not use_ads_krb5:
789 Logs.warn("Active Directory support not available: krb5 libs don't have all required features")
790 if not use_ads_ldap:
791 Logs.warn("Active Directory support not available: LDAP support is not available.")
792 if Options.options.with_ads:
793 conf.fatal("Active Directory support not found. Use --without-ads "
794 "for building without Active Directory support. "
795 "ADS support improves communication with "
796 "Active Directory domain controllers.")
797 else:
798 # this is the auto-mode case
799 Logs.warn("Building without Active Directory support.")
802 if Options.options.with_utmp:
803 conf.env.with_utmp = True
804 if not conf.CHECK_HEADERS('utmp.h'): conf.env.with_utmp = False
805 conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
806 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
807 define='HAVE_UT_UT_NAME')
808 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers='utmp.h',
809 define='HAVE_UT_UT_USER')
810 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers='utmp.h',
811 define='HAVE_UT_UT_ID')
812 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers='utmp.h',
813 define='HAVE_UT_UT_HOST')
814 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers='utmp.h',
815 define='HAVE_UT_UT_TIME')
816 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers='utmp.h',
817 define='HAVE_UT_UT_TV')
818 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers='utmp.h',
819 define='HAVE_UT_UT_TYPE')
820 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers='utmp.h',
821 define='HAVE_UT_UT_PID')
822 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers='utmp.h',
823 define='HAVE_UT_UT_EXIT')
824 conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers='utmpx.h',
825 define='HAVE_UX_UT_SYSLEN')
826 conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
827 'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
828 msg="Checking whether pututline returns pointer")
829 conf.CHECK_SIZEOF(['((struct utmp *)NULL)->ut_line'], headers='utmp.h',
830 define='SIZEOF_UTMP_UT_LINE', critical=False)
831 if not conf.CONFIG_SET('SIZEOF_UTMP_UT_LINE'):
832 conf.env.with_utmp = False
833 elif int(conf.env.SIZEOF_UTMP_UT_LINE) < 15:
834 conf.env.with_utmp = False
835 if conf.env.with_utmp:
836 conf.DEFINE('WITH_UTMP', 1)
837 else:
838 Logs.warn("--with-utmp but utmp support not sufficient")
840 if Options.options.with_avahi:
841 conf.env.with_avahi = True
842 if not conf.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf.env.with_avahi = False
843 if not conf.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf.env.with_avahi = False
844 if not conf.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf.env.with_avahi = False
845 if conf.env.with_avahi:
846 conf.DEFINE('WITH_AVAHI_SUPPORT', 1)
847 else:
848 conf.SET_TARGET_TYPE('avahi-common', 'EMPTY')
849 conf.SET_TARGET_TYPE('avahi-client', 'EMPTY')
851 if Options.options.with_iconv:
852 conf.env.with_iconv = True
853 if not conf.CHECK_FUNCS_IN('iconv_open', 'iconv', headers='iconv.h'):
854 conf.env.with_iconv = False
855 if conf.env.with_iconv:
856 conf.DEFINE('HAVE_ICONV', 1)
858 if Options.options.with_pam:
859 use_pam=True
860 conf.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
861 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
862 Logs.warn("--with-pam=yes but pam_appl.h not found")
863 use_pam=False
864 conf.CHECK_FUNCS_IN('pam_get_data', 'pam')
865 conf.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
866 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
867 Logs.warn("--with-pam=yes but pam_modules.h not found")
868 use_pam=False
869 conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
870 conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
871 conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
872 conf.CHECK_CODE('''
873 #if defined(HAVE_SECURITY_PAM_APPL_H)
874 #include <security/pam_appl.h>
875 #elif defined(HAVE_PAM_PAM_APPL_H)
876 #include <pam/pam_appl.h>
877 #endif
878 pam_set_item(0, PAM_RHOST, 0);
879 ''',
880 'HAVE_PAM_RHOST',
881 lib='pam',
882 msg="Checking whether PAM_RHOST is available");
883 conf.CHECK_CODE('''
884 #if defined(HAVE_SECURITY_PAM_APPL_H)
885 #include <security/pam_appl.h>
886 #elif defined(HAVE_PAM_PAM_APPL_H)
887 #include <pam/pam_appl.h>
888 #endif
889 pam_set_item(0, PAM_TTY, 0);
890 ''',
891 'HAVE_PAM_TTY',
892 lib='pam',
893 msg="Checking whether PAM_TTY is available");
894 conf.CHECK_CODE('''
895 #if (!defined(LINUX))
897 #define PAM_EXTERN extern
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
904 #endif
906 #if defined(HAVE_SECURITY_PAM_MODULES_H)
907 #include <security/pam_modules.h>
908 #elif defined(HAVE_PAM_PAM_MODULES_H)
909 #include <pam/pam_modules.h>
910 #endif
912 #if defined(HAVE_SECURITY__PAM_MACROS_H)
913 #include <security/_pam_macros.h>
914 #elif defined(HAVE_PAM__PAM_MACROS_H)
915 #include <pam/_pam_macros.h>
916 #endif
918 #ifdef HAVE_SECURITY_PAM_EXT_H
919 #include <security/pam_ext.h>
920 #endif
922 int i; i = PAM_RADIO_TYPE;
923 ''',
924 'HAVE_PAM_RADIO_TYPE',
925 lib='pam',
926 msg="Checking whether PAM_RADIO_TYPE is available");
927 if use_pam:
928 conf.DEFINE('WITH_PAM', 1)
929 conf.DEFINE('WITH_PAM_MODULES', 1)
931 if Options.options.with_pam_smbpass:
932 conf.env.with_pam_smbpass = True
934 seteuid = False
937 # Ensure we select the correct set of system calls on Linux.
939 if (host_os.rfind('linux') > -1):
940 conf.CHECK_CODE('''
941 #if defined(HAVE_UNISTD_H)
942 #include <unistd.h>
943 #endif
944 #include <stdlib.h>
945 #include <stdio.h>
946 #include <sys/types.h>
947 #include <errno.h>
949 #ifdef HAVE_SYS_PRIV_H
950 #include <sys/priv.h>
951 #endif
952 #ifdef HAVE_SYS_ID_H
953 #include <sys/id.h>
954 #endif
956 #if defined(HAVE_SYSCALL_H)
957 #include <syscall.h>
958 #endif
960 #if defined(HAVE_SYS_SYSCALL_H)
961 #include <sys/syscall.h>
962 #endif
964 syscall(SYS_setresuid32, -1, -1, -1);
965 syscall(SYS_setresgid32, -1, -1, -1);
966 syscall(SYS_setreuid32, -1, -1);
967 syscall(SYS_setregid32, -1, -1);
968 syscall(SYS_setuid32, -1);
969 syscall(SYS_setgid32, -1);
970 syscall(SYS_setgroups32, 0, NULL);
971 ''',
972 'USE_LINUX_32BIT_SYSCALLS',
973 msg="Checking whether Linux should use 32-bit credential calls");
975 if (conf.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
976 seteuid = conf.CHECK_CODE('''
977 #define AUTOCONF_TEST 1
978 #define USE_LINUX_THREAD_CREDENTIALS 1
979 #define USE_LINUX_32BIT_SYSCALLS 1
980 #include "../lib/util/setid.c"
981 #include "./lib/util_sec.c"
982 ''',
983 'USE_LINUX_THREAD_CREDENTIALS',
984 addmain=False,
985 execute=True,
986 msg="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
987 else:
988 seteuid = conf.CHECK_CODE('''
989 #define AUTOCONF_TEST 1
990 #define USE_LINUX_THREAD_CREDENTIALS 1
991 #include "../lib/util/setid.c"
992 #include "./lib/util_sec.c"
993 ''',
994 'USE_LINUX_THREAD_CREDENTIALS',
995 addmain=False,
996 execute=True,
997 msg="Checking whether we can use Linux thread-specific credentials")
998 if not seteuid:
999 seteuid = conf.CHECK_CODE('''
1000 #define AUTOCONF_TEST 1
1001 #define USE_SETREUID 1
1002 #include "../lib/util/setid.c"
1003 #include "./lib/util_sec.c"
1004 ''',
1005 'USE_SETREUID',
1006 addmain=False,
1007 execute=True,
1008 msg="Checking whether setreuid is available")
1009 if not seteuid:
1010 seteuid = conf.CHECK_CODE('''
1011 #define AUTOCONF_TEST 1
1012 #define USE_SETRESUID 1
1013 #include "../lib/util/setid.c"
1014 #include "./lib/util_sec.c"
1015 ''',
1016 'USE_SETRESUID',
1017 addmain=False,
1018 execute=True,
1019 msg="Checking whether setresuid is available")
1020 if not seteuid:
1021 seteuid = conf.CHECK_CODE('''
1022 #define AUTOCONF_TEST 1
1023 #define USE_SETEUID 1
1024 #include "../lib/util/setid.c"
1025 #include "./lib/util_sec.c"
1026 ''',
1027 'USE_SETEUID',
1028 addmain=False,
1029 execute=True,
1030 msg="Checking whether seteuid is available")
1031 if not seteuid:
1032 seteuid = conf.CHECK_CODE('''
1033 #define AUTOCONF_TEST 1
1034 #define USE_SETUIDX 1
1035 #include "../lib/util/setid.c"
1036 #include "./lib/util_sec.c"
1037 ''',
1038 'USE_SETUIDX',
1039 addmain=False,
1040 execute=True,
1041 mandatory=True,
1042 msg="Checking whether setuidx is available")
1043 if Options.options.with_dnsupdate:
1044 if not conf.CONFIG_SET('HAVE_KRB5'):
1045 Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
1046 else:
1047 conf.DEFINE('WITH_DNS_UPDATES', 1)
1048 conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
1049 if Options.options.developer:
1050 if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
1051 conf.DEFINE('VALGRIND', '1')
1053 if conf.CHECK_CODE('''
1054 #include <bits/sockaddr.h>
1055 #include <linux/netlink.h>
1056 ''',
1057 'HAVE_LINUX_NETLINK_H',
1058 msg="Checking whether Linux netlink is available"):
1060 conf.CHECK_CODE('''
1061 #include <bits/sockaddr.h>
1062 #include <linux/netlink.h>
1063 #include <linux/rtnetlink.h>
1064 ''',
1065 'HAVE_LINUX_RTNETLINK_H',
1066 msg='Checking whether Linux rtnetlink is available')
1068 conf.CHECK_CODE('''
1069 #include "../tests/fcntl_lock.c"
1070 ''',
1071 'HAVE_FCNTL_LOCK',
1072 addmain=False,
1073 execute=True,
1074 msg='Checking whether fcntl locking is available')
1076 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
1077 if not conf.CHECK_CODE('''
1078 #define _XOPEN_SOURCE 600
1079 #include <stdlib.h>
1080 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
1081 #error probably broken posix_fallocate
1082 #endif
1083 ''',
1084 '_HAVE_UNBROKEN_POSIX_FALLOCATE',
1085 msg='Checking for broken posix_fallocate'):
1086 conf.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
1089 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1090 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1091 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1092 define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1093 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1094 define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1095 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1096 define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1097 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1098 define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1099 if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1100 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1101 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1102 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1103 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1104 conf.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1106 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1107 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1108 define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1109 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1110 define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1111 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1112 define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1114 conf.CHECK_CODE('''
1115 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1116 ''',
1117 'HAVE_POSIX_FADVISE',
1118 msg='Checking whether posix_fadvise is available',
1119 headers='unistd.h fcntl.h')
1121 for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1122 conf.CHECK_CODE('''
1123 #include <unistd.h>
1124 return sysconf(%s) == -1 ? 1 : 0;
1125 ''' % v,
1126 'SYSCONF%s' % v,
1127 msg='Checking whether sysconf(%s) is available' % v)
1129 conf.CHECK_CODE('''
1130 #include <sys/syscall.h>
1131 #include <unistd.h>
1132 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1133 ''',
1134 'HAVE_DARWIN_INITGROUPS',
1135 msg='Checking whether to use the Darwin-specific initgroups system call')
1137 conf.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1138 'HAVE_UTIMBUF',
1139 headers='sys/types.h utime.h',
1140 msg='Checking whether struct utimbuf is available')
1142 if conf.CHECK_CODE('''struct sigevent s;''',
1143 'HAVE_STRUCT_SIGEVENT',
1144 headers='sys/types.h stdlib.h stddef.h signal.h',
1145 msg='Checking whether we have the struct sigevent'):
1146 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1147 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1148 headers='signal.h');
1149 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1150 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1151 headers='signal.h');
1153 if os.path.exists('/proc/sys/kernel/core_pattern'):
1154 conf.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
1156 if conf.CHECK_CODE('''
1157 #include <time.h>
1158 main() {
1159 struct tm *tm;
1160 if (sizeof(time_t) == 8) {
1161 time_t max_time = 0x7fffffffffffffffll;
1162 tm = gmtime(&max_time);
1163 /* This should fail with 32-bit tm_year. */
1164 if (tm == NULL) {
1165 /* Max time_t that works with 32-bit int tm_year in struct tm. */
1166 max_time = 67768036191676799ll;
1167 tm = gmtime(&max_time);
1168 if (tm) {
1169 exit(0);
1173 exit(1);
1174 }''',
1175 '__TIME_T_MAX',
1176 addmain=False,
1177 execute=True,
1178 msg="Checking for the maximum value of the 'time_t' type"):
1179 conf.DEFINE('TIME_T_MAX', '67768036191676799ll')
1181 conf.CHECK_CODE('''
1182 #if defined(HAVE_UNISTD_H)
1183 #include <unistd.h>
1184 #endif
1185 #include <sys/types.h>
1186 main() { dev_t dev = makedev(1,2); return 0; }
1187 ''',
1188 'HAVE_MAKEDEV',
1189 addmain=False,
1190 msg='Checking whether the macro for makedev is available')
1192 conf.CHECK_CODE('''
1193 #include <stdio.h>
1194 #include <limits.h>
1195 #include <signal.h>
1197 void exit_on_core(int ignored) {
1198 exit(1);
1201 main() {
1202 char *newpath;
1203 signal(SIGSEGV, exit_on_core);
1204 newpath = realpath("/tmp", NULL);
1205 exit((newpath != NULL) ? 0 : 1);
1207 ''',
1208 'REALPATH_TAKES_NULL',
1209 addmain=False,
1210 execute=True,
1211 msg='Checking whether the realpath function allows a NULL argument')
1213 conf.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1214 'HAVE_FTRUNCATE_EXTEND',
1215 msg='Checking for ftruncate extend',
1216 addmain=False,
1217 execute=True)
1219 if Options.options.with_sendfile_support:
1220 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):
1221 conf.CHECK_CODE('''
1222 int tofd, fromfd;
1223 off_t offset;
1224 size_t total;
1225 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1226 ''',
1227 '_HAVE_SENDFILE',
1228 headers='sys/sendfile.h',
1229 msg='Checking for linux sendfile support')
1231 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1232 conf.DEFINE('HAVE_SENDFILE', '1')
1233 conf.DEFINE('LINUX_SENDFILE_API', '1')
1234 conf.DEFINE('WITH_SENDFILE', '1')
1235 elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
1236 conf.CHECK_CODE('''
1237 #include <sys/types.h>
1238 #include <unistd.h>
1239 #include <sys/socket.h>
1240 #include <sys/uio.h>
1241 int fromfd, tofd, ret, total=0;
1242 off_t offset, nwritten;
1243 struct sf_hdtr hdr;
1244 struct iovec hdtrl;
1245 hdr.headers = &hdtrl;
1246 hdr.hdr_cnt = 1;
1247 hdr.trailers = NULL;
1248 hdr.trl_cnt = 0;
1249 hdtrl.iov_base = NULL;
1250 hdtrl.iov_len = 0;
1251 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1252 ''',
1253 '_HAVE_SENDFILE',
1254 msg='Checking for freebsd sendfile support')
1255 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1256 conf.DEFINE('HAVE_SENDFILE', '1')
1257 conf.DEFINE('FREEBSD_SENDFILE_API', '1')
1258 conf.DEFINE('WITH_SENDFILE', '1')
1259 elif (host_os.rfind('darwin') > -1):
1260 conf.CHECK_CODE('''
1261 #include <sys/types.h>
1262 #include <sys/socket.h>
1263 #include <sys/uio.h>
1264 int fromfd, tofd, ret;
1265 off_t offset, nwritten;
1266 struct sf_hdtr hdr;
1267 struct iovec hdtrl;
1268 hdr.headers = &hdtrl;
1269 hdr.hdr_cnt = 1;
1270 hdr.trailers = (void *)0;
1271 hdr.trl_cnt = 0;
1272 hdtrl.iov_base = (void *)0;
1273 hdtrl.iov_len = 0;
1274 ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1275 ''',
1276 '_HAVE_SENDFILE',
1277 msg='Checking for darwin sendfile support')
1278 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1279 conf.DEFINE('HAVE_SENDFILE', '1')
1280 conf.DEFINE('DARWIN_SENDFILE_API', '1')
1281 conf.DEFINE('WITH_SENDFILE', '1')
1282 elif (host_os.rfind('hpux') > -1) or (host_os.rfind('osf') > -1):
1283 conf.CHECK_CODE('''
1284 #include <sys/socket.h>
1285 #include <sys/uio.h>
1286 int fromfd, tofd;
1287 size_t total=0;
1288 struct iovec hdtrl[2];
1289 ssize_t nwritten;
1290 off_t offset;
1291 hdtrl[0].iov_base = 0;
1292 hdtrl[0].iov_len = 0;
1293 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1294 ''',
1295 '_HAVE_SENDFILE',
1296 msg='Checking for osf/hpux sendfile support')
1297 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1298 conf.DEFINE('HAVE_SENDFILE', '1')
1299 conf.DEFINE('HPUX_SENDFILE_API', '1')
1300 conf.DEFINE('WITH_SENDFILE', '1')
1301 elif (host_os.rfind('solaris') > -1):
1302 conf.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1303 conf.CHECK_CODE('''
1304 #include <sys/sendfile.h>,
1305 int sfvcnt;
1306 size_t xferred;
1307 struct sendfilevec vec[2];
1308 ssize_t nwritten;
1309 int tofd;
1310 sfvcnt = 2;
1311 vec[0].sfv_fd = SFV_FD_SELF;
1312 vec[0].sfv_flag = 0;
1313 vec[0].sfv_off = 0;
1314 vec[0].sfv_len = 0;
1315 vec[1].sfv_fd = 0;
1316 vec[1].sfv_flag = 0;
1317 vec[1].sfv_off = 0;
1318 vec[1].sfv_len = 0;
1319 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1320 ''',
1321 '_HAVE_SENDFILEV',
1322 msg='Checking for solaris sendfilev support')
1323 if conf.CONFIG_SET('_HAVE_SENDFILEV'):
1324 conf.DEFINE('HAVE_SENDFILEV', '1')
1325 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1326 conf.DEFINE('WITH_SENDFILE', '1')
1327 elif (host_os.rfind('aix') > -1):
1328 conf.CHECK_CODE('''
1329 #include <sys/socket.h>
1330 int fromfd, tofd;
1331 size_t total=0;
1332 struct sf_parms hdtrl;
1333 ssize_t nwritten;
1334 hdtrl.header_data = 0;
1335 hdtrl.header_length = 0;
1336 hdtrl.file_descriptor = fromfd;
1337 hdtrl.file_offset = 0;
1338 hdtrl.file_bytes = 0;
1339 hdtrl.trailer_data = 0;
1340 hdtrl.trailer_length = 0;
1341 nwritten = send_file(&tofd, &hdtrl, 0);
1342 ''',
1343 '_HAVE_SENDFILE',
1344 msg='Checking for AIX send_file support')
1345 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1346 conf.DEFINE('HAVE_SENDFILE', '1')
1347 conf.DEFINE('AIX_SENDFILE_API', '1')
1348 conf.DEFINE('WITH_SENDFILE', '1')
1350 # Check for getcwd allowing a NULL arg.
1351 conf.CHECK_CODE('''
1352 #include <unistd.h>
1353 main() {
1354 char *s = getcwd(NULL,0);
1355 exit(s != NULL ? 0 : 1);
1356 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
1357 msg="getcwd takes a NULL argument")
1360 # UnixWare 7.x has its getspnam in -lgen
1361 conf.CHECK_FUNCS_IN('getspnam', 'gen')
1362 conf.CHECK_FUNCS_IN('getspnam', 'security')
1363 conf.CHECK_FUNCS_IN('getspnam', 'sec')
1365 if Options.options.with_quotas:
1366 # For quotas on Veritas VxFS filesystems
1367 conf.CHECK_HEADERS('sys/fs/vx_quota.h')
1368 # For sys/quota.h and linux/quota.h
1369 conf.CHECK_HEADERS('sys/quota.h')
1370 # For quotas on BSD systems
1371 conf.CHECK_HEADERS('ufs/ufs/quota.h')
1372 # For quotas on Linux XFS filesystems
1373 if conf.CHECK_HEADERS('xfs/xqm.h'):
1374 conf.DEFINE('HAVE_XFS_QUOTAS', '1')
1375 else:
1376 # For Irix XFS
1377 conf.CHECK_CODE('''
1378 #include "confdefs.h"
1379 #ifdef HAVE_SYS_TYPES_H
1380 #include <sys/types.h>
1381 #endif
1382 #ifdef HAVE_ASM_TYPES_H
1383 #include <asm/types.h>
1384 #endif
1385 #include <sys/quota.h>
1386 int i = Q_XGETQUOTA;''',
1387 define='HAVE_XFS_QUOTAS',
1388 msg='for XFS QUOTA in <sys/quota.h>',
1389 execute=False,
1390 local_include=False)
1392 # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
1393 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define='HAVE_DQB_FSOFTLIMIT',
1394 headers='sys/quota.h')
1395 #darwin style quota bytecount
1396 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_curbytes', define='HAVE_STRUCT_DQBLK_DQB_CURBYTES',
1397 headers='sys/quota.h')
1398 if conf.CHECK_HEADERS('rpcsvc/rquota.h'):
1399 conf.DEFINE('HAVE_NFS_QUOTAS', '1')
1400 conf.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1401 define='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1402 headers='rpcsvc/rquota.h')
1404 if (host_os.rfind('linux') > -1):
1405 conf.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1406 elif not conf.CONFIG_SET("HAVE_XFS_QUOTAS"):
1407 if not conf.CHECK_CODE('''
1408 #define HAVE_QUOTACTL_4A 1
1409 #define AUTOCONF_TEST 1
1410 #include "../tests/sysquotas.c"
1411 ''',
1412 cflags=conf.env['WERROR_CFLAGS'],
1413 define='HAVE_QUOTACTL_4A',
1414 msg='for QUOTACTL_4A: long quotactl(int cmd, char *special, qid_t id, caddr_t addr)',
1415 execute=True,
1416 addmain=False):
1418 conf.CHECK_CODE('''
1419 #define HAVE_QUOTACTL_4B 1
1420 #define AUTOCONF_TEST 1
1421 #include "../tests/sysquotas.c"
1422 ''',
1423 cflags=conf.env['WERROR_CFLAGS'],
1424 define='HAVE_QUOTACTL_4B',
1425 msg='for QUOTACTL_4B: int quotactl(const char *path, int cmd, int id, char *addr)',
1426 execute=True,
1427 addmain=False)
1429 conf.CHECK_CODE('''
1430 clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
1431 ''',
1432 headers="rpc/rpc.h rpc/types.h rpcsvc/rquota.h rpc/nettype.h rpc/xdr.h",
1433 define='HAVE_NFS_QUOTAS',
1434 msg='for NFS QUOTAS',
1435 execute=True,
1436 local_include=False)
1438 if conf.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1439 conf.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1440 conf.CONFIG_SET('HAVE_QUOTACTL_4B') or \
1441 conf.CONFIG_SET('HAVE_XFS_QUOTAS'):
1442 conf.DEFINE('HAVE_SYS_QUOTAS', '1')
1443 conf.DEFINE('WITH_QUOTAS', '1')
1446 # cluster support (CTDB)
1448 if not Options.options.with_cluster_support:
1449 Logs.info("building without cluster support (--without-cluster-support)")
1450 conf.env.with_ctdb = False
1451 else:
1452 Logs.info("building with cluster support")
1453 conf.env['CTDB_CFLAGS'] = '-DCLUSTER_SUPPORT=1'
1454 conf.env['CTDB_INCLUDE'] = conf.srcdir + '/ctdb/include'
1455 conf.env.with_ctdb = True
1457 conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1458 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1459 addmain=False,
1460 link=False,
1461 msg='Checking whether we can compile with __attribute__((destructor))')
1463 conf.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1464 'SEEKDIR_RETURNS_VOID',
1465 headers='sys/types.h dirent.h',
1466 msg='Checking whether seekdir returns void')
1468 if Options.options.with_profiling_data:
1469 conf.DEFINE('WITH_PROFILE', 1);
1471 if Options.options.with_pthreadpool:
1472 if conf.CONFIG_SET('HAVE_PTHREAD'):
1473 conf.DEFINE('WITH_PTHREADPOOL', '1')
1474 else:
1475 Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
1476 conf.undefine('WITH_PTHREADPOOL')
1478 if conf.CHECK_HEADERS('gpfs_gpl.h'):
1479 conf.DEFINE('HAVE_GPFS', '1')
1481 if (conf.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
1482 conf.CHECK_DECLS('FS_IOC_GETFLAGS FS_COMPR_FL', headers='linux/fs.h')):
1483 conf.DEFINE('HAVE_LINUX_IOCTL', '1')
1485 conf.env['CCFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64"
1486 if Options.options.libcephfs_dir:
1487 conf.env['CPPPATH_CEPHFS'] = Options.options.libcephfs_dir + '/include'
1488 conf.env['LIBPATH_CEPHFS'] = Options.options.libcephfs_dir + '/lib'
1490 if conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and conf.CHECK_LIB('cephfs'):
1491 conf.DEFINE('HAVE_CEPH', '1')
1493 if Options.options.with_glusterfs:
1494 conf.check_cfg(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs',
1495 msg='Checking for glusterfs-api >= 4', uselib_store="GFAPI")
1496 conf.CHECK_HEADERS('api/glfs.h', lib='gfapi')
1497 conf.CHECK_LIB('gfapi', shlib=True)
1499 if conf.CONFIG_SET('HAVE_API_GLFS_H'):
1500 conf.DEFINE('HAVE_GLUSTERFS', '1')
1501 else:
1502 conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
1503 conf.undefine('HAVE_GLUSTERFS')
1504 else:
1505 conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
1506 conf.undefine('HAVE_GLUSTERFS')
1508 if Options.options.enable_vxfs:
1509 conf.DEFINE('HAVE_VXFS', '1')
1511 if conf.check_cfg(package='dbus-1', args='--cflags --libs',
1512 msg='Checking for dbus', uselib_store="DBUS-1"):
1513 if (conf.CHECK_HEADERS('dbus/dbus.h', lib='dbus-1')
1514 and conf.CHECK_LIB('dbus-1', shlib=True)):
1515 conf.DEFINE('HAVE_DBUS', '1')
1517 conf.env.build_regedit = False
1518 if not Options.options.with_regedit == False:
1519 conf.PROCESS_SEPARATE_RULE('system_ncurses')
1520 if conf.CONFIG_SET('HAVE_NCURSES'):
1521 conf.env.build_regedit = True
1523 if conf.env.build_regedit:
1524 Logs.info("building regedit")
1525 else:
1526 if Options.options.with_regedit == False:
1527 Logs.info("not building regedit (--without-regedit)")
1528 elif Options.options.with_regedit == True:
1529 Logs.error("ncurses not available, cannot build regedit")
1530 conf.fatal("ncurses not available, but --with-regedit was specified")
1531 else:
1532 Logs.info("ncurses not available, not building regedit")
1534 conf.CHECK_FUNCS_IN('DES_pcbc_encrypt', 'crypto')
1535 if Options.options.with_fake_kaserver == True:
1536 conf.CHECK_HEADERS('afs/param.h afs/stds.h', together=True)
1537 conf.CHECK_HEADERS('afs/param.h afs/stds.h', together=True)
1538 if (conf.CONFIG_SET('HAVE_AFS_PARAM_H') and conf.CONFIG_SET('HAVE_AFS_STDS_H') and conf.CONFIG_SET('HAVE_DES_PCBC_ENCRYPT')):
1539 conf.DEFINE('WITH_FAKE_KASERVER', '1')
1540 else:
1541 conf.fatal('AFS headers not available, but --with-fake-kaserver was specified')
1545 default_static_modules.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1546 auth_sam auth_unix auth_winbind auth_wbc
1547 auth_domain auth_builtin vfs_default
1548 nss_info_template idmap_tdb idmap_passdb
1549 idmap_nss'''))
1551 default_shared_modules.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1552 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1553 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
1554 auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1555 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1556 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1557 vfs_media_harmony vfs_fruit
1558 vfs_commit
1559 vfs_worm
1560 vfs_crossrename vfs_linux_xfs_sgid
1561 vfs_time_audit idmap_autorid idmap_tdb2
1562 idmap_ad
1563 idmap_rid idmap_hash idmap_rfc2307'''))
1565 if Options.options.developer:
1566 default_static_modules.extend(TO_LIST('charset_weird'))
1567 default_shared_modules.extend(TO_LIST('perfcount_test'))
1568 default_shared_modules.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1569 default_shared_modules.extend(TO_LIST('auth_skel pdb_test'))
1571 if Options.options.enable_selftest or Options.options.developer:
1572 default_shared_modules.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr'))
1575 if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1576 default_static_modules.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
1578 if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1579 default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
1581 if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
1582 default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1584 if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
1585 default_shared_modules.extend(TO_LIST('vfs_fileid'))
1587 if (conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS')):
1588 default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
1590 if Options.options.with_pthreadpool:
1591 default_shared_modules.extend(TO_LIST('vfs_aio_pthread'))
1593 if conf.CONFIG_SET('HAVE_AIO'):
1594 default_shared_modules.extend(TO_LIST('vfs_aio_posix'))
1596 if conf.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1597 default_shared_modules.extend(TO_LIST('vfs_aio_linux'))
1599 if conf.CONFIG_SET('HAVE_LDAP'):
1600 default_static_modules.extend(TO_LIST('pdb_ldapsam idmap_ldap'))
1602 if conf.CONFIG_SET('DARWINOS'):
1603 default_static_modules.extend(TO_LIST('charset_macosxfs'))
1605 if conf.CONFIG_SET('HAVE_GPFS'):
1606 default_shared_modules.extend(TO_LIST('vfs_gpfs'))
1608 if conf.CONFIG_SET('HAVE_LINUX_IOCTL'):
1609 default_shared_modules.extend(TO_LIST('vfs_btrfs'))
1611 if conf.CONFIG_SET('SAMBA_FAM_LIBS'):
1612 default_shared_modules.extend(TO_LIST('vfs_notify_fam'))
1614 if conf.CONFIG_SET("HAVE_CEPH"):
1615 default_shared_modules.extend(TO_LIST('vfs_ceph'))
1617 if conf.CONFIG_SET('HAVE_GLUSTERFS'):
1618 default_shared_modules.extend(TO_LIST('vfs_glusterfs'))
1620 if conf.CONFIG_SET('HAVE_VXFS'):
1621 default_shared_modules.extend(TO_LIST('vfs_vxfs'))
1623 if conf.CONFIG_SET('HAVE_DBUS'):
1624 default_shared_modules.extend(TO_LIST('vfs_snapper'))
1626 explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
1627 explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
1629 def replace_list_item(lst, item, value):
1630 try:
1631 idx = lst.index(item)
1632 lst[idx] = value
1633 except:
1634 pass
1635 # PDB module file name should have the same name as module registers itself
1636 # In Autoconf build we export LDAP passdb module as ldapsam but WAF build
1637 # was always exporting pdb_ldap. In order to support existing packages
1638 # allow referring to pdb_ldapsam as pdb_ldap but use proper name internally.
1639 replace_list_item(explicit_shared_modules, 'pdb_ldap', 'pdb_ldapsam')
1640 replace_list_item(explicit_static_modules, 'pdb_ldap', 'pdb_ldapsam')
1642 final_static_modules = default_static_modules
1643 final_shared_modules = default_shared_modules
1645 for m in explicit_static_modules:
1646 if m in final_shared_modules:
1647 final_shared_modules.remove(m)
1648 final_static_modules.append(m)
1649 for m in explicit_shared_modules:
1650 if m in final_static_modules:
1651 final_static_modules.remove(m)
1652 final_shared_modules.append(m)
1654 if ("auth_domain" not in final_static_modules) or \
1655 ("auth_builtin" not in final_static_modules) or \
1656 ("auth_sam" not in final_static_modules) or \
1657 ("auth_winbind" not in final_static_modules):
1658 raise Utils.WafError('These auth modules MUST be configured as static modules: auth_domain, auth_builtin, auth_sam, auth_winbind')
1660 conf.env['static_modules'] = final_static_modules
1661 conf.env['shared_modules'] = final_shared_modules
1663 conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
1665 static_list = {}
1666 shared_list = {}
1668 prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1669 conf.env['MODULE_PREFIXES'] = prefixes
1670 for p in prefixes:
1671 for m in final_static_modules:
1672 if m.find(p) == 0:
1673 if not p in static_list:
1674 static_list[p] = []
1675 static_list[p].append(m)
1676 for m in final_shared_modules:
1677 if m.find(p) == 0:
1678 if not p in shared_list:
1679 shared_list[p] = []
1680 shared_list[p].append(m)
1682 for p in prefixes:
1683 static_env = "%s_STATIC" % p.upper()
1684 shared_env = "%s_SHARED" % p.upper()
1685 conf.env[static_env] = []
1686 conf.env[shared_env] = []
1687 if p in static_list:
1688 decl_list=""
1689 for entry in static_list[p]:
1690 decl_list += "extern NTSTATUS %s_init(void); " % entry
1691 conf.env[static_env].append('%s' % entry)
1692 decl_list = decl_list.rstrip()
1693 conf.DEFINE('static_decl_%s' % p, decl_list)
1694 conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
1695 else:
1696 conf.DEFINE('static_decl_%s' % p, '')
1697 conf.DEFINE('static_init_%s' % p, '{}')
1698 if p in shared_list:
1699 for entry in shared_list[p]:
1700 conf.DEFINE('%s_init' % entry, 'samba_init_module')
1701 conf.env[shared_env].append('%s' % entry)
1703 conf.SAMBA_CONFIG_H('include/config.h')
1705 def ctags(ctx):
1706 "build 'tags' file using ctags"
1707 import Utils
1708 source_root = os.path.dirname(Utils.g_module.root_path)
1709 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1710 print("Running: %s" % cmd)
1711 os.system(cmd)