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