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