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