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