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