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