s3:lib/afs fix some compiler warnings
[Samba/bb.git] / source3 / wscript
blobbe011af232daaad2d060e9a1e84327e4600c077a
1 #! /usr/bin/env python
3 srcdir = '..'
4 blddir = 'bin'
6 APPNAME='samba'
7 VERSION=None
9 import sys, os
10 from optparse import SUPPRESS_HELP
11 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
12 sys.path.insert(0, "source3")
13 import wafsamba, Options, Logs, Utils, Scripting
14 import build.charset
15 import samba_utils, samba_version
16 import samba3
18 Options.default_prefix = '/usr/local/samba'
20 def set_options(opt):
21 if not os.getenv('TOPLEVEL_BUILD'):
22 opt.BUILTIN_DEFAULT('NONE')
23 opt.PRIVATE_EXTENSION_DEFAULT('s3')
24 opt.RECURSE('../lib/replace')
25 opt.RECURSE('../dynconfig')
26 opt.RECURSE('selftest')
27 opt.RECURSE('../lib/nss_wrapper')
28 opt.RECURSE('../lib/socket_wrapper')
29 opt.RECURSE('../lib/tevent')
30 opt.RECURSE('../lib/tdb_compat')
32 opt.add_option('--with-static-modules',
33 help=("Comma-separated list of names of modules to statically link in"),
34 action="store", dest='static_modules', default=None)
35 opt.add_option('--with-shared-modules',
36 help=("Comma-separated list of names of modules to build shared"),
37 action="store", dest='shared_modules', default=None)
38 opt.add_option('--enable-selftest',
39 help=("enable options necessary for selftest"),
40 action="store_true", dest='enable_selftest', default=False)
42 opt.SAMBA3_ADD_OPTION('winbind')
43 opt.SAMBA3_ADD_OPTION('swat')
44 opt.SAMBA3_ADD_OPTION('ads')
45 opt.SAMBA3_ADD_OPTION('krb5')
46 opt.SAMBA3_ADD_OPTION('ldap')
47 opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
48 opt.SAMBA3_ADD_OPTION('iprint', with_name="enable", without_name="disable")
49 opt.SAMBA3_ADD_OPTION('merged-build', with_name="enable", without_name="disable")
50 opt.SAMBA3_ADD_OPTION('pam')
51 opt.SAMBA3_ADD_OPTION('pam_smbpass')
52 opt.SAMBA3_ADD_OPTION('quotas')
53 opt.SAMBA3_ADD_OPTION('sys-quotas')
54 opt.SAMBA3_ADD_OPTION('sendfile-support')
55 opt.SAMBA3_ADD_OPTION('utmp')
56 opt.SAMBA3_ADD_OPTION('pthreadpool', with_name="enable", without_name="disable")
57 opt.SAMBA3_ADD_OPTION('avahi', with_name="enable", without_name="disable")
58 opt.SAMBA3_ADD_OPTION('iconv')
59 opt.SAMBA3_ADD_OPTION('acl-support')
60 opt.SAMBA3_ADD_OPTION('dnsupdate')
61 opt.SAMBA3_ADD_OPTION('syslog')
62 opt.SAMBA3_ADD_OPTION('automount')
63 opt.SAMBA3_ADD_OPTION('aio-support')
64 opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
66 opt.SAMBA3_ADD_OPTION('cluster-support')
68 opt.add_option('--with-ctdb-dir',
69 help=("Directory under which ctdb is installed"),
70 action="store", dest='ctdb_dir', default=None)
71 opt.add_option('--enable-old-ctdb',
72 help=("enable building against (too) old version of ctdb (default=false)"),
73 action="store_true", dest='enable_old_ctdb', default=False)
77 def configure(conf):
78 from samba_utils import TO_LIST
80 if not conf.env.toplevel_build:
81 version = samba_version.load_version(env=conf.env)
82 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
83 conf.DEFINE('_SAMBA_WAF_BUILD_', version.MAJOR)
84 conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
85 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
87 if Options.options.developer:
88 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
89 conf.env.developer = True
91 if Options.options.with_swat:
92 conf.env['build_swat'] = True
94 if not conf.env.toplevel_build:
96 conf.RECURSE('../lib/replace')
98 conf.find_program('python', var='PYTHON', mandatory=True)
99 conf.find_program('perl', var='PERL', mandatory=True)
100 conf.find_program('xsltproc', var='XSLTPROC')
102 # enable tool to build python extensions
103 conf.check_tool('python')
104 conf.check_python_version((2,4,2))
105 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
107 if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
108 # Mac OSX needs to have this and it's also needed that the python is compiled with this
109 # otherwise you face errors about common symbols
110 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
111 conf.ADD_CFLAGS('-fno-common')
112 if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
113 conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
114 if int(conf.env['PYTHON_VERSION'][0]) >= 3:
115 raise Utils.WafError('Python version 3.x is not supported by Samba yet')
117 conf.RECURSE('../dynconfig')
118 conf.RECURSE('../lib/ccan')
119 conf.RECURSE('../lib/tdb_compat')
120 conf.RECURSE('../lib/talloc')
121 conf.RECURSE('../lib/tevent')
122 conf.RECURSE('../lib/popt')
123 conf.RECURSE('../lib/nss_wrapper')
124 conf.RECURSE('../lib/socket_wrapper')
125 conf.RECURSE('../lib/zlib')
126 conf.RECURSE('../libcli/smbreadline')
127 conf.RECURSE('../lib/util')
129 conf.ADD_EXTRA_INCLUDES('''#source3 #source3/include #lib/replace #lib''')
130 if not conf.env.USING_SYSTEM_TDB:
131 conf.ADD_EXTRA_INCLUDES('#lib/tdb_compat')
132 if not conf.env.USING_SYSTEM_TEVENT:
133 conf.ADD_EXTRA_INCLUDES('#lib/tevent')
134 if not conf.env.USING_SYSTEM_TALLOC:
135 conf.ADD_EXTRA_INCLUDES('#lib/talloc')
136 if not conf.env.USING_SYSTEM_POPT:
137 conf.ADD_EXTRA_INCLUDES('#lib/popt')
139 conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
141 conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
142 conf.CHECK_HEADERS('linux/falloc.h')
144 conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
145 conf.CHECK_FUNCS('strtol strchr strupr chflags')
146 conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
147 conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
148 conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
149 conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
150 conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf stat64 fstat64')
151 conf.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 fallocate fallocate64 posix_fallocate posix_fallocate64')
152 conf.CHECK_FUNCS('fseek64 fseeko64 ftell64 ftello64 setluid')
153 conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
154 conf.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
155 conf.CHECK_FUNCS('fdopendir fdopendir64')
156 conf.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
157 conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
158 conf.CHECK_FUNCS_IN('nanosleep', 'rt')
159 conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
160 conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
161 conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
162 conf.CHECK_FUNCS('shmget')
163 conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
164 conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain bind_textdomain_codeset')
165 #FIXME: for some reason this one still fails
166 conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
167 conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
168 conf.CHECK_DECLS('fdatasync', reverse=True)
169 conf.CHECK_DECLS('readahead', reverse=True, headers='fcntl.h')
171 if conf.CONFIG_SET('HAVE_LONG_LONG'):
172 conf.DEFINE('HAVE_LONGLONG', 1)
174 if conf.CHECK_CODE('''
175 #if defined(HAVE_UNISTD_H)
176 #include <unistd.h>
177 #endif
178 long ret = splice(0,0,1,0,400,0);
179 ''',
180 'HAVE_LINUX_SPLICE',
181 headers='fcntl.h'):
182 conf.CHECK_DECLS('splice', reverse=True, headers='fcntl.h')
184 # Check for inotify support
185 conf.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
186 conf.CHECK_FUNCS('inotify_init')
187 if "HAVE_LINUX_INOTIFY_H" in conf.env and "HAVE_INOTIFY_INIT" in conf.env:
188 conf.DEFINE('HAVE_INOTIFY', 1)
190 # Check for kernel change notify support
191 conf.CHECK_CODE('''
192 #ifndef F_NOTIFY
193 #define F_NOTIFY 1026
194 #endif
195 main() {
196 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
197 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
198 headers='fcntl.h signal.h',
199 msg="Checking for kernel change notify support")
201 # Check for Linux kernel oplocks
202 conf.CHECK_CODE('''
203 #include <sys/types.h>
204 #include <fcntl.h>
205 #include <signal.h>
206 #ifndef F_NOTIFY
207 #define F_NOTIFY 1026
208 #endif
209 main() {
210 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
211 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
212 msg="Checking for Linux kernel oplocks")
214 # Check for IRIX kernel oplock types
215 conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
216 'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
217 msg="Checking for IRIX kernel oplock types")
219 # Check for kernel share modes
220 conf.CHECK_CODE('''
221 #include <sys/types.h>
222 #include <fcntl.h>
223 #include <signal.h>
224 #include <sys/file.h>
225 #ifndef LOCK_MAND
226 #define LOCK_MAND 32
227 #define LOCK_READ 64
228 #endif
229 main() {
230 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
231 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
232 msg="Checking for krenel share modes")
234 # Check for various members of the stat structure
235 conf.CHECK_TYPES('blksize_t blkcnt_t')
236 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
237 headers='sys/stat.h')
238 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
239 headers='sys/stat.h')
240 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define='HAVE_STAT_ST_FLAGS',
241 headers='sys/types.h sys/stat.h unistd.h')
243 # Check for POSIX capability support
244 conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
246 if "HAVE_SYS_CAPABILITY_H" in conf.env:
247 conf.CHECK_CODE('''
248 cap_t cap;
249 cap_value_t vals[1];
250 if (!(cap = cap_get_proc())) exit(1);
251 vals[0] = CAP_CHOWN;
252 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
253 cap_set_proc(cap);''',
254 'HAVE_POSIX_CAPABILITIES', execute=True, lib="cap",
255 headers='sys/capability.h',
256 msg="Checking whether POSIX capabilities are available")
258 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
259 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
260 # -- JRA.
261 if conf.CONFIG_SET("HAVE_RPC_RPC_H"):
262 conf.CHECK_TYPE('int16', headers='rpc/rpc.h',
263 define='HAVE_INT16_FROM_RPC_RPC_H',
264 msg="Checking for int16 typedef included by rpc/rpc.h")
265 conf.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
266 headers='sys/types.h rpc/rpc.h',
267 msg="Checking for uint16 typedef included by rpc/rpc.h")
268 conf.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
269 headers='sys/types.h rpc/rpc.h',
270 msg="Checking for int32 typedef included by rpc/rpc.h")
271 conf.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
272 headers='sys/types.h rpc/rpc.h',
273 msg="Checking for uint32 typedef included by rpc/rpc.h")
274 conf.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
275 headers='sys/types.h sys/acl.h rpcsvc/nis.h',
276 msg="Checking for broken nisplus include files")
278 # Check if the compiler will optimize out functions
279 conf.CHECK_CODE('''
280 if (0) {
281 this_function_does_not_exist();
282 } else {
283 return 1;
284 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
285 msg="Checking if the compiler will optimize out functions")
287 # Check if the compiler supports the LL suffix on long long integers
288 # AIX needs this
289 conf.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
290 headers='stdio.h',
291 msg="Checking for LL suffix on long long integers")
293 conf.CHECK_FUNCS('''
294 _acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
295 attropen attr_remove attr_removef attr_set attr_setf backtrace_symbols
296 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
297 __closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
298 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
299 extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
300 extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
301 extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
302 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
303 fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
304 _fork __fork fremoveea fremovexattr fseek64 fseeko64 fsetea
305 fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
306 ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
307 getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
308 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
309 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
310 glob grantpt hstrerror initgroups innetgr
311 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
312 llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
313 lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
314 __lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
315 _open __open open64 _open64 __open64 _opendir __opendir
316 opendir64 pathconf poll posix_fallocate posix_fallocate64
317 posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
318 pwrite _pwrite __pwrite pwrite64 _pwrite64
319 __pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
320 __readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
321 seekdir64 select setea setenv setgidx setgroups setlocale setluid
322 setmntent setpgid setpriv setproplist setsid setuidx
323 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
324 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
325 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
326 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
327 utimensat vsyslog _write __write __xstat
328 ''')
330 conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
332 # FIXME: these should be tests for features, but the old build system just
333 # checks for OSes.
334 host_os = sys.platform
335 Logs.info("building on %s" % host_os)
337 # Python doesn't have case switches... :/
338 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
339 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
341 conf.SET_TARGET_TYPE('sunacl', 'EMPTY')
342 if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('qnx') > -1):
343 if host_os.rfind('linux') > -1:
344 conf.DEFINE('LINUX', '1')
345 elif host_os.rfind('qnx') > -1:
346 conf.DEFINE('QNX', '1')
347 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
348 elif (host_os.rfind('darwin') > -1):
349 conf.DEFINE('DARWINOS', 1)
350 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
351 conf.ADD_CFLAGS('-fno-common')
352 elif (host_os.rfind('freebsd') > -1):
353 if conf.CHECK_HEADERS('sunacl.h'):
354 conf.define('HAVE_FREEBSD_SUNACL_H', '1')
355 conf.CHECK_FUNCS_IN('acl', 'sunacl')
356 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
357 elif (host_os.rfind('netbsd') > -1):
358 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
359 elif (host_os.rfind('openbsd') > -1):
360 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
361 elif (host_os.rfind('sunos') > -1):
362 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
363 # FIXME: Add more checks here.
364 else:
365 Logs.warn("Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os)
367 #FIXME: add more checks
368 if Options.options.with_acl_support:
369 if host_os.rfind('linux') > -1:
370 conf.CHECK_FUNCS_IN('acl_get_file', 'acl')
371 conf.CHECK_FUNCS_IN('getxattr', 'attr')
372 if conf.CHECK_CODE('''
373 acl_t acl;
374 int entry_id;
375 acl_entry_t *entry_p;
376 return acl_get_entry(acl, entry_id, entry_p);
377 ''',
378 'HAVE_POSIX_ACLS',
379 headers='sys/types.h sys/acl.h', link=False,
380 msg="Checking for POSIX ACL support") :
381 conf.CHECK_CODE('''
382 acl_permset_t permset_d;
383 acl_perm_t perm;
384 return acl_get_perm_np(permset_d, perm);
385 ''',
386 'HAVE_ACL_GET_PERM_NP',
387 headers='sys/types.h sys/acl.h', link=True,
388 msg="Checking whether acl_get_perm_np() is available")
389 else:
390 conf.DEFINE('HAVE_NO_ACLS', 1)
391 conf.SET_TARGET_TYPE('acl', 'EMPTY')
392 else:
393 conf.DEFINE('HAVE_NO_ACLS', 1)
394 conf.SET_TARGET_TYPE('acl', 'EMPTY')
396 if conf.CHECK_FUNCS('dirfd'):
397 conf.DEFINE('HAVE_DIRFD_DECL', 1)
399 conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
400 'HAVE_STATFS_F_FSID',
401 msg="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
402 headers='sys/types.h sys/statfs.h',
403 execute=True)
405 if conf.CONFIG_SET('HAVE_FALLOCATE'):
406 conf.CHECK_CODE('''
407 #if defined(HAVE_UNISTD_H)
408 #include <unistd.h>
409 #endif
410 #include <sys/types.h>
411 #define _GNU_SOURCE
412 #include <fcntl.h>
413 #if defined(HAVE_LINUX_FALLOC_H)
414 #include <linux/falloc.h>
415 #endif
416 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
417 'HAVE_LINUX_FALLOCATE',
418 msg="Checking whether the Linux 'fallocate' function is available")
419 if conf.CONFIG_SET('HAVE_FALLOCATE64'):
420 conf.CHECK_CODE('''
421 #if defined(HAVE_UNISTD_H)
422 #include <unistd.h>
423 #endif
424 #include <sys/types.h>
425 #define _GNU_SOURCE
426 #include <fcntl.h>
427 #if defined(HAVE_LINUX_FALLOC_H)
428 #include <linux/falloc.h>
429 #endif
430 int ret = fallocate64(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
431 'HAVE_LINUX_FALLOCATE64',
432 msg="Checking whether the Linux 'fallocate64' function is available")
433 conf.CHECK_CODE('''
434 #if defined(HAVE_UNISTD_H)
435 #include <unistd.h>
436 #endif
437 #include <fcntl.h>
438 ssize_t err = readahead(0,0,0x80000);''',
439 'HAVE_LINUX_READAHEAD',
440 msg="Checking whether Linux readahead is available")
441 conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
443 conf.CHECK_CODE('''
444 #include <sys/types.h>
445 #include <sys/socket.h>],
446 struct ucred cred;
447 socklen_t cred_len;
448 int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);''',
449 'HAVE_PEERCRED',
450 msg="Checking whether we can use SO_PEERCRED to get socket credentials")
452 conf.CHECK_CODE('''
453 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
454 #include <sys/types.h>
455 #else
456 __COMPILE_ERROR_
457 #endif
458 int i;''',
459 'HAVE_EXPLICIT_LARGEFILE_SUPPORT',
460 msg="Checking whether large file support can be enabled")
462 if Options.options.with_aio_support:
463 conf.CHECK_FUNCS_IN('aio_read', 'aio')
464 conf.CHECK_FUNCS_IN('aio_read', 'rt')
465 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);',
466 'HAVE_AIO',
467 msg='Checking for asynchronous io support',
468 headers='sys/types.h aio.h',
469 lib='aio rt')
470 conf.CHECK_CODE('struct aiocb64 a; return aio_read64(&a);',
471 'HAVE_AIO64',
472 msg='Checking for 64-bit asynchronous io support',
473 headers='sys/types.h aio.h',
474 lib='aio rt')
475 if conf.CONFIG_SET('HAVE_AIO64'):
476 conf.DEFINE('HAVE_AIOCB64', '1')
477 conf.DEFINE('WITH_AIO', '1')
478 elif conf.CONFIG_SET('HAVE_AIO'):
479 conf.DEFINE('WITH_AIO', '1')
480 if conf.CONFIG_SET('HAVE_AIO'):
481 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg='Checking for aio_read', headers='aio.h', lib='aio rt')
482 conf.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg='Checking for aio_write', headers='aio.h', lib='aio rt')
483 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')
484 conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
485 conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
486 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')
487 conf.CHECK_CODE('struct aiocb a; return aio_suspend(&a, 1, NULL);', 'HAVE_AIO_SUSPEND', msg='Checking for aio_suspend', headers='aio.h', lib='aio rt')
488 if conf.CONFIG_SET('HAVE_AIO64'):
489 conf.CHECK_CODE('struct aiocb a; return aio_read64(&a);', 'HAVE_AIO_READ64', msg='Checking for aio_read64', headers='aio.h', lib='aio rt')
490 conf.CHECK_CODE('struct aiocb a; return aio_write64(&a);', 'HAVE_AIO_WRITE64', msg='Checking for aio_write64', headers='aio.h', lib='aio rt')
491 conf.CHECK_CODE('struct aiocb a; return aio_fsync64(1, &a);', 'HAVE_AIO_FSYNC64', msg='Checking for aio_fsync64', headers='aio.h', lib='aio rt')
492 conf.CHECK_CODE('struct aiocb a; return aio_return64(&a);', 'HAVE_AIO_RETURN64', msg='Checking for aio_return64', headers='aio.h', lib='aio rt')
493 conf.CHECK_CODE('struct aiocb a; return aio_error64(&a);', 'HAVE_AIO_ERROR64', msg='Checking for aio_error64', headers='aio.h', lib='aio rt')
494 conf.CHECK_CODE('struct aiocb a; return aio_cancel64(1, &a);', 'HAVE_AIO_CANCEL64', msg='Checking for aio_cancel64', headers='aio.h', lib='aio rt')
495 conf.CHECK_CODE('struct aiocb a; return aio_suspend64(&a, 1, NULL);', 'HAVE_AIO_SUSPEND64', msg='Checking for aio_suspend64', headers='aio.h', lib='aio rt')
496 if not conf.CONFIG_SET('HAVE_AIO'):
497 conf.DEFINE('HAVE_NO_AIO', '1')
498 else:
499 conf.DEFINE('HAVE_NO_AIO', '1')
501 conf.CHECK_CODE('''
502 struct msghdr msg;
503 union {
504 struct cmsghdr cm;
505 char control[CMSG_SPACE(sizeof(int))];
506 } control_un;
507 msg.msg_control = control_un.control;
508 msg.msg_controllen = sizeof(control_un.control);
509 ''',
510 'HAVE_MSGHDR_MSG_CONTROL',
511 msg='Checking if we can use msg_control for passing file descriptors',
512 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
513 conf.CHECK_CODE('''
514 struct msghdr msg;
515 int fd;
516 msg.msg_acctrights = (caddr_t) &fd;
517 msg.msg_acctrightslen = sizeof(fd);
518 ''',
519 'HAVE_MSGHDR_MSG_ACCTRIGHTS',
520 msg='Checking if we can use msg_acctrights for passing file descriptors',
521 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
523 if Options.options.with_winbind:
524 conf.env.build_winbind = True
525 conf.DEFINE('WITH_WINBIND', '1')
527 conf.find_program('awk', var='AWK')
528 conf.find_program('perl', var='PERL')
530 # Darwin has extra options to xattr-family functions
531 conf.CHECK_CODE('getxattr(0, 0, 0, 0, 0, 0);',
532 'XATTR_ADD_OPT',
533 msg="Checking whether xattr interface takes additional options",
534 headers='sys/types.h attr/xattr.h sys/xattr.h')
536 conf.CHECK_HEADERS('asm/types.h')
538 conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
539 headers='unistd.h sys/types.h',
540 msg="Checking for major macro")
542 conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
543 headers='unistd.h sys/types.h',
544 msg="Checking for minor macro")
546 conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
547 headers='unistd.h sys/types.h dirent.h',
548 define='HAVE_DIRENT_D_OFF')
550 conf.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
551 if conf.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
552 netgrent_cflags = '-Werror-implicit-function-declaration'
553 else:
554 netgrent_cflags = ''
555 conf.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
556 msg="Checking for setnetgrent prototype",
557 headers='netdb.h netgroup.h',
558 cflags=netgrent_cflags)
559 conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
560 msg="Checking for getnetgrent prototype",
561 headers='netdb.h netgroup.h',
562 cflags=netgrent_cflags)
563 conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
564 msg="Checking for endnetgrent prototype",
565 headers='netdb.h netgroup.h',
566 cflags=netgrent_cflags)
569 # Look for CUPS
570 if Options.options.with_cups:
571 conf.find_program('cups-config', var='CUPS_CONFIG')
572 if conf.env.CUPS_CONFIG:
573 # we would normally use --libs here, but cups-config incorrectly adds
574 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
575 # of an in-tree heimdal kerberos
576 conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
577 package="", uselib_store="cups")
578 conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
579 conf.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
580 if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
581 conf.DEFINE('HAVE_CUPS', '1')
582 else:
583 conf.undefine('HAVE_CUPS')
584 conf.SET_TARGET_TYPE('cups', 'EMPTY')
585 else:
586 # define an empty subsystem for cups, to allow it to be used as an empty dependency
587 conf.SET_TARGET_TYPE('cups', 'EMPTY')
589 if Options.options.with_iprint:
590 if conf.CONFIG_SET('HAVE_CUPS'):
591 conf.DEFINE('HAVE_IPRINT', '1')
592 else:
593 Logs.warn("--enable-iprint=yes but cups support not sufficient")
594 if Options.options.with_syslog:
595 conf.DEFINE('WITH_SYSLOG', '1')
596 if Options.options.with_automount:
597 conf.DEFINE('WITH_AUTOMOUNT', '1')
599 # Check for LDAP
600 if Options.options.with_ldap:
601 conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
602 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
603 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
604 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
606 # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
607 # for the samba logs
608 conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
609 define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
611 conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
612 conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
614 # Check if ldap_set_rebind_proc() takes three arguments
615 if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
616 'LDAP_SET_REBIND_PROC_ARGS',
617 msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
618 headers='ldap.h lber.h', link=False):
619 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
620 else:
621 conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
623 # last but not least, if ldap_init() exists, we want to use ldap
624 if conf.CONFIG_SET('HAVE_LDAP_INIT'):
625 conf.DEFINE('HAVE_LDAP', '1')
626 conf.DEFINE('LDAP_DEPRECATED', '1')
627 conf.env['HAVE_LDAP'] = '1'
628 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
629 # SASL wrapping hooks
630 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
631 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
632 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
633 else:
634 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
635 conf.SET_TARGET_TYPE('lber', 'EMPTY')
637 # Check for kerberos
638 have_gssapi=False
639 if Options.options.with_krb5 and not conf.env.toplevel_build:
640 Logs.info("Looking for kerberos features")
641 conf.find_program('krb5-config', var='KRB5_CONFIG')
642 if conf.env.KRB5_CONFIG:
643 conf.check_cfg(path="krb5-config", args="--cflags --libs",
644 package="gssapi", uselib_store="krb5")
645 conf.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib='krb5')
646 conf.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h gssapi/gssapi_krb5.h com_err.h', lib='krb5')
648 if conf.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
649 conf.env['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
651 conf.CHECK_FUNCS_IN('_et_list', 'com_err')
652 conf.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
653 conf.CHECK_FUNCS_IN('crypto', 'des_set_key')
654 conf.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
655 conf.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
656 if conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi') or \
657 conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi_krb5'):
658 have_gssapi=True
659 conf.CHECK_FUNCS_IN('gss_wrap_iov gss_krb5_import_cred gss_get_name_attribute gss_mech_krb5 gss_oid_equal gss_inquire_sec_context_by_oid', 'gssapi gssapi_krb5 krb5')
660 conf.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
661 conf.CHECK_FUNCS('''
662 krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
663 krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
664 krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
665 krb5_auth_con_setuseruserkey krb5_locate_kdc krb5_get_permitted_enctypes
666 krb5_get_default_in_tkt_etypes krb5_free_data_contents
667 krb5_principal_get_comp_string krb5_free_unparsed_name
668 krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
669 krb5_krbhst_get_addrinfo krb5_c_enctype_compare krb5_enctypes_compatible_keys
670 krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
671 krb5_verify_checksum krb5_c_verify_checksum krb5_principal_compare_any_realm
672 krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
673 krb5_get_renewed_creds krb5_get_kdc_cred krb5_free_error_contents
674 initialize_krb5_error_table krb5_get_init_creds_opt_alloc
675 krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
676 krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
677 krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
678 krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
679 lib='krb5 k5crypto')
680 conf.CHECK_DECLS('''krb5_get_credentials_for_user
681 krb5_auth_con_set_req_cksumtype''',
682 headers='krb5.h', always=True)
683 conf.CHECK_VARIABLE('AP_OPTS_USE_SUBKEY', headers='krb5.h')
684 conf.CHECK_VARIABLE('KV5M_KEYTAB', headers='krb5.h')
685 conf.CHECK_VARIABLE('KRB5_KU_OTHER_CKSUM', headers='krb5.h')
686 conf.CHECK_VARIABLE('KRB5_KEYUSAGE_APP_DATA_CKSUM', headers='krb5.h')
687 conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'key', headers='krb5.h',
688 define='HAVE_KRB5_KEYTAB_ENTRY_KEY')
689 conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'keyblock', headers='krb5.h',
690 define='HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK')
691 conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'magic', headers='krb5.h',
692 define='HAVE_MAGIC_IN_KRB5_ADDRESS')
693 conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'addrtype', headers='krb5.h',
694 define='HAVE_ADDRTYPE_IN_KRB5_ADDRESS')
695 conf.CHECK_STRUCTURE_MEMBER('krb5_ticket', 'enc_part2', headers='krb5.h',
696 define='HAVE_KRB5_TKT_ENC_PART2')
697 conf.CHECK_STRUCTURE_MEMBER('krb5_creds', 'keyblock', headers='krb5.h',
698 define='HAVE_KRB5_KEYBLOCK_IN_CREDS')
699 conf.CHECK_STRUCTURE_MEMBER('krb5_creds', 'session', headers='krb5.h',
700 define='HAVE_KRB5_SESSION_IN_CREDS')
701 conf.CHECK_STRUCTURE_MEMBER('krb5_ap_req', 'ticket', headers='krb5.h',
702 define='HAVE_TICKET_POINTER_IN_KRB5_AP_REQ')
704 conf.CHECK_TYPE('krb5_encrypt_block', headers='krb5.h')
706 conf.CHECK_CODE('''
707 krb5_ticket ticket;
708 krb5_kvno kvno;
709 krb5_enctype enctype;
710 enctype = ticket.enc_part.enctype;
711 kvno = ticket.enc_part.kvno;
712 ''',
713 'KRB5_TICKET_HAS_KEYINFO',
714 headers='krb5.h', link=False,
715 msg="Checking whether the krb5_ticket structure contains the kvno and enctype")
716 conf.CHECK_CODE('''
717 krb5_context ctx;
718 krb5_get_init_creds_opt *opt = NULL;
719 krb5_get_init_creds_opt_free(ctx, opt);
720 ''',
721 'KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT',
722 headers='krb5.h', link=False,
723 msg="Checking whether krb5_get_init_creds_opt_free takes a context argument")
724 conf.CHECK_CODE('krb5_mk_error(0,0,0)',
725 'HAVE_SHORT_KRB5_MK_ERROR_INTERFACE',
726 headers='krb5.h', link=False,
727 msg="Checking whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal")
728 conf.CHECK_CODE('''
729 const krb5_data *pkdata;
730 krb5_context context;
731 krb5_principal principal;
732 pkdata = krb5_princ_component(context, principal, 0);
733 ''',
734 'HAVE_KRB5_PRINC_COMPONENT',
735 headers='krb5.h', lib='krb5',
736 msg="Checking whether krb5_princ_component is available")
738 conf.CHECK_CODE('''
739 int main(void) {
740 char buf[256];
741 krb5_enctype_to_string(1, buf, 256);
742 return 0;
743 }''',
744 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG',
745 headers='krb5.h', lib='krb5 k5crypto',
746 addmain=False, cflags='-Werror',
747 msg="Checking whether krb5_enctype_to_string takes size_t argument")
749 conf.CHECK_CODE('''
750 int main(void) {
751 krb5_context context = NULL;
752 char *str = NULL;
753 krb5_enctype_to_string(context, 1, &str);
754 if (str) free (str);
755 return 0;
756 }''',
757 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG',
758 headers='krb5.h stdlib.h', lib='krb5',
759 addmain=False, cflags='-Werror',
760 msg="Checking whether krb5_enctype_to_string takes krb5_context argument")
761 conf.CHECK_CODE('''
762 int main(void) {
763 krb5_context ctx = NULL;
764 krb5_principal princ = NULL;
765 const char *str = krb5_princ_realm(ctx, princ)->data;
766 return 0;
767 }''',
768 'HAVE_KRB5_PRINC_REALM',
769 headers='krb5.h', lib='krb5',
770 addmain=False,
771 msg="Checking whether the macro krb5_princ_realm is defined")
772 conf.CHECK_CODE('''
773 int main(void) {
774 krb5_context context;
775 krb5_principal principal;
776 const char *realm; realm = krb5_principal_get_realm(context, principal);
777 return 0;
778 }''',
779 'HAVE_KRB5_PRINCIPAL_GET_REALM',
780 headers='krb5.h', lib='krb5',
781 addmain=False,
782 msg="Checking whether krb5_principal_get_realm is defined")
783 if conf.CHECK_CODE('''krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);''',
784 'KRB5_VERIFY_CHECKSUM_ARGS',
785 headers='krb5.h', lib='krb5',
786 msg="Checking whether krb5_verify_checksum takes 7 arguments"):
787 conf.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '7')
788 else:
789 conf.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '6')
791 conf.CHECK_CODE('''
792 krb5_enctype enctype;
793 enctype = ENCTYPE_ARCFOUR_HMAC_MD5;
794 ''',
795 '_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5',
796 headers='krb5.h', lib='krb5',
797 msg="Checking whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available");
798 conf.CHECK_CODE('''
799 krb5_keytype keytype;
800 keytype = KEYTYPE_ARCFOUR_56;
801 ''',
802 '_HAVE_KEYTYPE_ARCFOUR_56',
803 headers='krb5.h', lib='krb5',
804 msg="Checking whether the HAVE_KEYTYPE_ARCFOUR_56 key type definition is available");
805 if conf.CONFIG_SET('_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and conf.CONFIG_SET('_HAVE_KEYTYPE_ARCFOUR_56'):
806 conf.DEFINE('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', '1')
808 conf.CHECK_CODE('''
809 krb5_enctype enctype;
810 enctype = ENCTYPE_ARCFOUR_HMAC;
811 ''',
812 'HAVE_ENCTYPE_ARCFOUR_HMAC',
813 headers='krb5.h', lib='krb5',
814 msg="Checking whether the ENCTYPE_ARCFOUR_HMAC key type definition is available");
816 conf.CHECK_CODE('''
817 krb5_context context;
818 krb5_keytab keytab;
819 krb5_init_context(&context);
820 return krb5_kt_resolve(context, "WRFILE:api", &keytab);
821 ''',
822 'HAVE_WRFILE_KEYTAB',
823 headers='krb5.h', lib='krb5', execute=True,
824 msg="Checking whether the WRFILE:-keytab is supported");
826 # Check for KRB5_DEPRECATED handling
827 conf.CHECK_CODE('''#define KRB5_DEPRECATED 1
828 #include <krb5.h>''',
829 'HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER', addmain=False,
830 link=False,
831 msg="Checking for KRB5_DEPRECATED define taking an identifier")
832 elif not conf.env.toplevel_build:
833 conf.SET_TARGET_TYPE('krb5', 'EMPTY')
834 conf.SET_TARGET_TYPE('gssapi', 'EMPTY')
835 conf.SET_TARGET_TYPE('gssapi_krb5', 'EMPTY')
836 conf.SET_TARGET_TYPE('com_err', 'EMPTY')
837 conf.SET_TARGET_TYPE('k5crypto', 'EMPTY')
839 if Options.options.with_ads:
840 use_ads=True
841 if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
842 not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
843 Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
844 use_ads=False
845 if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
846 Logs.warn("krb5_mk_req_extended not found in -lkrb5")
847 use_ads=False
848 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
849 not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
850 Logs.warn("no CREATE_KEY_FUNCTIONS detected")
851 use_ads=False
852 if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
853 not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
854 Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
855 use_ads=False
856 if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
857 not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
858 Logs.warn("no KT_FREE_FUNCTION detected")
859 use_ads=False
860 if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM') and \
861 not conf.CONFIG_SET('HAVE_KRB5_VERIFY_CHECKSUM'):
862 Logs.warn("no KRB5_VERIFY_CHECKSUM_FUNCTION detected")
863 use_ads=False
864 if not conf.CONFIG_SET('KRB5_TICKET_HAS_KEYINFO'):
865 # We only need the following functions if we can't get the enctype
866 # and kvno out of the ticket directly (ie. on Heimdal).
867 if not conf.CONFIG_SET('HAVE_FREE_AP_REQ'):
868 Logs.warn("no KRB5_AP_REQ_FREE_FUNCTION detected")
869 use_ads=False
870 if not conf.CONFIG_SET('HAVE_KRB5_DECODE_AP_REQ'):
871 Logs.warn("no KRB5_AP_REQ_DECODING_FUNCTION detected")
872 use_ads=False
873 if use_ads:
874 conf.DEFINE('WITH_ADS', '1')
875 conf.DEFINE('HAVE_KRB5', '1')
876 if have_gssapi:
877 conf.DEFINE('HAVE_GSSAPI', '1')
878 if conf.CONFIG_SET('HAVE_LDAP'):
879 conf.env['HAVE_ADS'] = '1'
880 else:
881 Logs.warn("krb5 libs don't have all features required for Active Directory support")
882 conf.undefine('HAVE_KRB5_H')
883 conf.undefine('HAVE_GSSAPI_H')
884 conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
885 conf.undefine('HAVE_GSSAPI_GSSAPI_H')
887 if Options.options.with_utmp:
888 conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
889 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
890 define='HAVE_UT_UT_NAME')
891 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers='utmp.h',
892 define='HAVE_UT_UT_USER')
893 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers='utmp.h',
894 define='HAVE_UT_UT_ID')
895 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers='utmp.h',
896 define='HAVE_UT_UT_HOST')
897 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers='utmp.h',
898 define='HAVE_UT_UT_TIME')
899 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers='utmp.h',
900 define='HAVE_UT_UT_TV')
901 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers='utmp.h',
902 define='HAVE_UT_UT_TYPE')
903 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers='utmp.h',
904 define='HAVE_UT_UT_PID')
905 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers='utmp.h',
906 define='HAVE_UT_UT_EXIT')
907 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers='utmp.h',
908 define='HAVE_UT_UT_ADDR_V6')
909 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers='utmp.h',
910 define='HAVE_UT_UT_ADDR')
911 conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers='utmpx.h',
912 define='HAVE_UX_UT_SYSLEN')
913 conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
914 'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
915 msg="Checking whether pututline returns pointer")
916 conf.DEFINE('WITH_UTMP', 1)
918 if Options.options.with_avahi:
919 conf.env.with_avahi = True
920 if not conf.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf.env.with_avahi = False
921 if not conf.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf.env.with_avahi = False
922 if not conf.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf.env.with_avahi = False
923 if conf.env.with_avahi:
924 conf.DEFINE('WITH_AVAHI_SUPPORT', 1)
925 else:
926 conf.SET_TARGET_TYPE('avahi-common', 'EMPTY')
927 conf.SET_TARGET_TYPE('avahi-client', 'EMPTY')
929 if Options.options.with_iconv:
930 conf.env.with_iconv = True
931 if not conf.CHECK_FUNCS_IN('iconv_open', 'iconv', headers='iconv.h'):
932 conf.env.with_iconv = False
933 if conf.env.with_iconv:
934 conf.DEFINE('HAVE_ICONV', 1)
936 if Options.options.with_pam:
937 use_pam=True
938 conf.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
939 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
940 Logs.warn("--with-pam=yes but pam_appl.h not found")
941 use_pam=False
942 conf.CHECK_FUNCS_IN('pam_get_data', 'pam')
943 conf.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
944 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
945 Logs.warn("--with-pam=yes but pam_modules.h not found")
946 use_pam=False
947 conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
948 conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
949 conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
950 conf.CHECK_CODE('''
951 #if defined(HAVE_SECURITY_PAM_APPL_H)
952 #include <security/pam_appl.h>
953 #elif defined(HAVE_PAM_PAM_APPL_H)
954 #include <pam/pam_appl.h>
955 #endif
956 pam_set_item(0, PAM_RHOST, 0);
957 ''',
958 'HAVE_PAM_RHOST',
959 lib='pam',
960 msg="Checking whether PAM_RHOST is available");
961 conf.CHECK_CODE('''
962 #if defined(HAVE_SECURITY_PAM_APPL_H)
963 #include <security/pam_appl.h>
964 #elif defined(HAVE_PAM_PAM_APPL_H)
965 #include <pam/pam_appl.h>
966 #endif
967 pam_set_item(0, PAM_TTY, 0);
968 ''',
969 'HAVE_PAM_TTY',
970 lib='pam',
971 msg="Checking whether PAM_TTY is available");
972 conf.CHECK_CODE('''
973 #if (!defined(LINUX))
975 #define PAM_EXTERN extern
976 #if defined(HAVE_SECURITY_PAM_APPL_H)
977 #include <security/pam_appl.h>
978 #elif defined(HAVE_PAM_PAM_APPL_H)
979 #include <pam/pam_appl.h>
980 #endif
982 #endif
984 #if defined(HAVE_SECURITY_PAM_MODULES_H)
985 #include <security/pam_modules.h>
986 #elif defined(HAVE_PAM_PAM_MODULES_H)
987 #include <pam/pam_modules.h>
988 #endif
990 #if defined(HAVE_SECURITY__PAM_MACROS_H)
991 #include <security/_pam_macros.h>
992 #elif defined(HAVE_PAM__PAM_MACROS_H)
993 #include <pam/_pam_macros.h>
994 #endif
996 #ifdef HAVE_SECURITY_PAM_EXT_H
997 #include <security/pam_ext.h>
998 #endif
1000 int i; i = PAM_RADIO_TYPE;
1001 ''',
1002 'HAVE_PAM_RADIO_TYPE',
1003 lib='pam',
1004 msg="Checking whether PAM_RADIO_TYPE is available");
1005 if use_pam:
1006 conf.DEFINE('WITH_PAM', 1)
1007 conf.DEFINE('WITH_PAM_MODULES', 1)
1009 seteuid = False
1010 if not seteuid:
1011 seteuid = conf.CHECK_CODE('''
1012 #define AUTOCONF_TEST 1
1013 #define USE_SETREUID 1
1014 #include "./lib/util_sec.c"
1015 ''',
1016 'USE_SETREUID',
1017 addmain=False,
1018 execute=True,
1019 msg="Checking whether setreuid is available")
1020 if not seteuid:
1021 seteuid = conf.CHECK_CODE('''
1022 #define AUTOCONF_TEST 1
1023 #define USE_SETRESUID 1
1024 #include "./lib/util_sec.c"
1025 ''',
1026 'USE_SETRESUID',
1027 addmain=False,
1028 execute=True,
1029 msg="Checking whether setresuid is available")
1030 if not seteuid:
1031 seteuid = conf.CHECK_CODE('''
1032 #define AUTOCONF_TEST 1
1033 #define USE_SETEUID 1
1034 #include "./lib/util_sec.c"
1035 ''',
1036 'USE_SETEUID',
1037 addmain=False,
1038 execute=True,
1039 msg="Checking whether seteuid is available")
1040 if not seteuid:
1041 seteuid = conf.CHECK_CODE('''
1042 #define AUTOCONF_TEST 1
1043 #define USE_SETUIDX 1
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 conf.CHECK_HEADERS('uuid/uuid.h')
1053 conf.CHECK_FUNCS_IN('uuid_generate', 'uuid')
1054 if not conf.CONFIG_SET('HAVE_UUID_UUID_H') and not conf.CONFIG_SET('HAVE_UUID_GENERATE'):
1055 Logs.warn("--with-dnsupdate=yes but uuid support not sufficient")
1056 elif not conf.CONFIG_SET('HAVE_GSSAPI'):
1057 Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
1058 else:
1059 conf.DEFINE('WITH_DNS_UPDATES', 1)
1060 else:
1061 conf.SET_TARGET_TYPE('uuid', 'EMPTY')
1062 conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
1063 if Options.options.developer:
1064 if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
1065 conf.DEFINE('VALGRIND', '1')
1067 if conf.CHECK_CODE('''
1068 #include <bits/sockaddr.h>
1069 #include <linux/netlink.h>
1070 ''',
1071 'HAVE_LINUX_NETLINK_H',
1072 msg="Checking whether Linux netlink is available"):
1073 conf.CHECK_CODE('''
1074 #include <bits/sockaddr.h>
1075 #include <linux/netlink.h>
1076 #include <linux/rtnetlink.h>
1077 ''',
1078 'HAVE_LINUX_RTNETLINK_H',
1079 msg='Checking whether Linux rtnetlink is available')
1080 if conf.CHECK_TYPE('struct dirent64', headers='sys/types.h dirent.h') and conf.CONFIG_SET('HAVE_READDIR64'):
1081 conf.DEFINE('HAVE_STRUCT_DIRENT64', '1')
1082 else:
1083 conf.undefine('HAVE_STRUCT_DIRENT64')
1085 conf.CHECK_CODE('''
1086 #include "../tests/fcntl_lock.c"
1087 ''',
1088 'HAVE_FCNTL_LOCK',
1089 addmain=False,
1090 execute=True,
1091 msg='Checking whether fcntl locking is available')
1093 conf.CHECK_CODE('''
1094 #include "../tests/fcntl_lock64.c"
1095 ''',
1096 'HAVE_BROKEN_FCNTL64_LOCKS',
1097 addmain=False,
1098 execute=True,
1099 msg='Checking whether fcntl64 locks are broken')
1101 if not conf.CONFIG_SET('HAVE_BROKEN_FCNTL64_LOCKS'):
1102 conf.CHECK_CODE('''
1103 #if defined(HAVE_UNISTD_H)
1104 #include <unistd.h>
1105 #endif
1106 #include <stdio.h>
1107 #include <stdlib.h>
1109 #ifdef HAVE_FCNTL_H
1110 #include <fcntl.h>
1111 #endif
1113 #ifdef HAVE_SYS_FCNTL_H
1114 #include <sys/fcntl.h>
1115 #endif
1116 main() { struct flock64 fl64;
1117 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1118 exit(0);
1119 #else
1120 exit(1);
1121 #endif
1123 ''',
1124 'HAVE_STRUCT_FLOCK64',
1125 addmain=False,
1126 execute=True,
1127 msg="Checking whether the flock64 struct is available")
1129 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1130 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1131 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1132 define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1133 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1134 define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1135 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1136 define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1137 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1138 define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1139 if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1140 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1141 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1142 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1143 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1144 conf.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1146 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1147 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1148 define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1149 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1150 define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1151 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1152 define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1154 conf.CHECK_CODE('''
1155 #if defined(HAVE_UNISTD_H)
1156 #include <unistd.h>
1157 #endif
1158 #include <fcntl.h>],
1159 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1160 ''',
1161 'HAVE_POSIX_FADVISE',
1162 msg='Checking whether posix_fadvise is available')
1164 for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1165 conf.CHECK_CODE('''
1166 #include <unistd.h>
1167 return sysconf(%s) == -1 ? 1 : 0;
1168 ''' % v,
1169 'SYSCONF%s' % v,
1170 msg='Checking whether sysconf(%s) is available' % v)
1172 conf.CHECK_DECLS('__NR_inotify_init', reverse=True, headers='asm/unistd.h')
1174 conf.CHECK_CODE('''
1175 #include <sys/syscall.h>
1176 #include <unistd.h>
1177 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1178 ''',
1179 'HAVE_DARWIN_INITGROUPS',
1180 msg='Checking whether to use the Darwin-specific initgroups system call')
1182 conf.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1183 'HAVE_UTIMBUF',
1184 headers='sys/types.h utime.h',
1185 msg='Checking whether struct utimbuf is available')
1187 if conf.CHECK_CODE('''struct sigevent s;''',
1188 'HAVE_STRUCT_SIGEVENT',
1189 headers='sys/types.h stdlib.h stddef.h signal.h',
1190 msg='Checking whether we have the struct sigevent'):
1191 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1192 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1193 headers='signal.h');
1194 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1195 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1196 headers='signal.h');
1198 if os.path.exists('/proc/sys/kernel/core_pattern'):
1199 conf.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
1201 if conf.CHECK_CODE('''
1202 #include <time.h>
1203 main() {
1204 struct tm *tm;
1205 if (sizeof(time_t) == 8) {
1206 time_t max_time = 0x7fffffffffffffffll;
1207 tm = gmtime(&max_time);
1208 /* This should fail with 32-bit tm_year. */
1209 if (tm == NULL) {
1210 /* Max time_t that works with 32-bit int tm_year in struct tm. */
1211 max_time = 67768036191676799ll;
1212 tm = gmtime(&max_time);
1213 if (tm) {
1214 exit(0);
1218 exit(1);
1219 }''',
1220 '__TIME_T_MAX',
1221 addmain=False,
1222 execute=True,
1223 msg="Checking for the maximum value of the 'time_t' type"):
1224 conf.DEFINE('TIME_T_MAX', '67768036191676799ll')
1226 conf.CHECK_CODE('''
1227 #if defined(HAVE_UNISTD_H)
1228 #include <unistd.h>
1229 #endif
1230 #include <sys/types.h>
1231 main() { dev_t dev = makedev(1,2); return 0; }
1232 ''',
1233 'HAVE_MAKEDEV',
1234 addmain=False,
1235 msg='Checking whether the macro for makedev is available')
1237 conf.CHECK_CODE('''
1238 #include <stdio.h>
1239 #include <limits.h>
1240 #include <signal.h>
1242 void exit_on_core(int ignored) {
1243 exit(1);
1246 main() {
1247 char *newpath;
1248 signal(SIGSEGV, exit_on_core);
1249 newpath = realpath("/tmp", NULL);
1250 exit((newpath != NULL) ? 0 : 1);
1252 ''',
1253 'REALPATH_TAKES_NULL',
1254 addmain=False,
1255 execute=True,
1256 msg='Checking whether the realpath function allows a NULL argument')
1258 conf.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1259 'HAVE_FTRUNCATE_EXTEND',
1260 msg='Checking for ftruncate extend',
1261 addmain=False,
1262 execute=True)
1263 if os.getenv('RUN_FROM_BUILD_FARM'):
1264 Logs.info("enabling buildfarm hacks")
1265 conf.DEFINE('ENABLE_BUILD_FARM_HACKS', '1')
1267 if Options.options.with_sendfile_support:
1268 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):
1269 conf.CHECK_CODE('''
1270 int tofd, fromfd;
1271 off64_t offset;
1272 size_t total;
1273 ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
1274 ''',
1275 '_HAVE_SENDFILE64',
1276 headers='sys/sendfile',
1277 msg='Checking for linux sendfile64 support')
1278 conf.CHECK_CODE('''
1279 int tofd, fromfd;
1280 off_t offset;
1281 size_t total;
1282 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1283 ''',
1284 '_HAVE_SENDFILE',
1285 headers='sys/sendfile',
1286 msg='Checking for linux sendfile support')
1288 # Try and cope with broken Linux sendfile....
1289 conf.CHECK_CODE('''#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
1290 #undef _FILE_OFFSET_BITS
1291 #endif
1292 #include <sys/sendfile.h>
1293 int tofd, fromfd;
1294 off_t offset;
1295 size_t total;
1296 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1297 ''',
1298 '_HAVE_BROKEN_LINUX_SENDFILE',
1299 msg='Checking for broken linux sendfile support')
1300 if conf.CONFIG_SET('_HAVE_SENDFILE64'):
1301 conf.DEFINE('HAVE_SENDFILE64', '1')
1302 conf.DEFINE('LINUX_SENDFILE_API', '1')
1303 conf.DEFINE('WITH_SENDFILE', '1')
1304 elif conf.CONFIG_SET('_HAVE_SENDFILE'):
1305 conf.DEFINE('HAVE_SENDFILE', '1')
1306 conf.DEFINE('LINUX_SENDFILE_API', '1')
1307 conf.DEFINE('WITH_SENDFILE', '1')
1308 elif conf.CONFIG_SET('_HAVE_BROKEN_LINUX_SENDFILE'):
1309 conf.DEFINE('LINUX_BROKEN_SENDFILE_API', '1')
1310 conf.DEFINE('WITH_SENDFILE', '1')
1311 elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
1312 conf.CHECK_CODE('''
1313 #include <sys/types.h>
1314 #include <unistd.h>
1315 #include <sys/socket.h>
1316 #include <sys/uio.h>
1317 int fromfd, tofd, ret, total=0;
1318 off_t offset, nwritten;
1319 struct sf_hdtr hdr;
1320 struct iovec hdtrl;
1321 hdr.headers = &hdtrl;
1322 hdr.hdr_cnt = 1;
1323 hdr.trailers = NULL;
1324 hdr.trl_cnt = 0;
1325 hdtrl.iov_base = NULL;
1326 hdtrl.iov_len = 0;
1327 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1328 ''',
1329 '_HAVE_SENDFILE',
1330 msg='Checking for freebsd sendfile support')
1331 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1332 conf.DEFINE('HAVE_SENDFILE', '1')
1333 conf.DEFINE('FREEBSD_SENDFILE_API', '1')
1334 conf.DEFINE('WITH_SENDFILE', '1')
1335 elif (host_os.rfind('hpux') > -1):
1336 conf.CHECK_CODE('''
1337 #include <sys/socket.h>
1338 #include <sys/uio.h>
1339 int fromfd, tofd;
1340 size_t total=0;
1341 struct iovec hdtrl[2];
1342 ssize_t nwritten;
1343 off64_t offset;
1344 hdtrl[0].iov_base = 0;
1345 hdtrl[0].iov_len = 0;
1346 nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
1347 ''',
1348 '_HAVE_SENDFILE64',
1349 msg='Checking for hpux sendfile64 support')
1350 conf.CHECK_CODE('''
1351 #include <sys/socket.h>
1352 #include <sys/uio.h>
1353 int fromfd, tofd;
1354 size_t total=0;
1355 struct iovec hdtrl[2];
1356 ssize_t nwritten;
1357 off_t offset;
1358 hdtrl[0].iov_base = 0;
1359 hdtrl[0].iov_len = 0;
1360 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1361 ''',
1362 '_HAVE_SENDFILE',
1363 msg='Checking for hpux sendfile support')
1364 if conf.CONFIG_SET('_HAVE_SENDFILE64'):
1365 conf.DEFINE('HAVE_SENDFILE64', '1')
1366 conf.DEFINE('HPUX_SENDFILE_API', '1')
1367 conf.DEFINE('WITH_SENDFILE', '1')
1368 elif conf.CONFIG_SET('_HAVE_SENDFILE'):
1369 conf.DEFINE('HAVE_SENDFILE', '1')
1370 conf.DEFINE('HPUX_SENDFILE_API', '1')
1371 conf.DEFINE('WITH_SENDFILE', '1')
1372 elif (host_os.rfind('solaris') > -1):
1373 conf.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1374 conf.CHECK_CODE('''
1375 #include <sys/sendfile.h>
1376 int sfvcnt;
1377 size_t xferred;
1378 struct sendfilevec vec[2];
1379 ssize_t nwritten;
1380 int tofd;
1381 sfvcnt = 2;
1382 vec[0].sfv_fd = SFV_FD_SELF;
1383 vec[0].sfv_flag = 0;
1384 vec[0].sfv_off = 0;
1385 vec[0].sfv_len = 0;
1386 vec[1].sfv_fd = 0;
1387 vec[1].sfv_flag = 0;
1388 vec[1].sfv_off = 0;
1389 vec[1].sfv_len = 0;
1390 nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
1391 ''',
1392 '_HAVE_SENDFILEV64',
1393 msg='Checking for solaris sendfilev64 support')
1394 conf.CHECK_CODE('''
1395 #include <sys/sendfile.h>,
1396 int sfvcnt;
1397 size_t xferred;
1398 struct sendfilevec vec[2];
1399 ssize_t nwritten;
1400 int tofd;
1401 sfvcnt = 2;
1402 vec[0].sfv_fd = SFV_FD_SELF;
1403 vec[0].sfv_flag = 0;
1404 vec[0].sfv_off = 0;
1405 vec[0].sfv_len = 0;
1406 vec[1].sfv_fd = 0;
1407 vec[1].sfv_flag = 0;
1408 vec[1].sfv_off = 0;
1409 vec[1].sfv_len = 0;
1410 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1411 ''',
1412 '_HAVE_SENDFILEV',
1413 msg='Checking for solaris sendfilev support')
1414 if conf.CONFIG_SET('_HAVE_SENDFILEV64'):
1415 conf.DEFINE('HAVE_SENDFILEV64', '1')
1416 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1417 conf.DEFINE('WITH_SENDFILE', '1')
1418 elif conf.CONFIG_SET('_HAVE_SENDFILEV'):
1419 conf.DEFINE('HAVE_SENDFILEV', '1')
1420 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1421 conf.DEFINE('WITH_SENDFILE', '1')
1422 elif (host_os.rfind('aix') > -1):
1423 conf.CHECK_CODE('''
1424 #include <sys/socket.h>
1425 int fromfd, tofd;
1426 size_t total=0;
1427 struct sf_parms hdtrl;
1428 ssize_t nwritten;
1429 off64_t offset;
1430 hdtrl.header_data = 0;
1431 hdtrl.header_length = 0;
1432 hdtrl.file_descriptor = fromfd;
1433 hdtrl.file_offset = 0;
1434 hdtrl.file_bytes = 0;
1435 hdtrl.trailer_data = 0;
1436 hdtrl.trailer_length = 0;
1437 nwritten = send_file(&tofd, &hdtrl, 0);
1438 ''',
1439 '_HAVE_SENDFILE',
1440 msg='Checking for AIX send_file support')
1441 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1442 conf.DEFINE('HAVE_SENDFILE', '1')
1443 conf.DEFINE('AIX_SENDFILE_API', '1')
1444 conf.DEFINE('WITH_SENDFILE', '1')
1446 # Check for getcwd allowing a NULL arg.
1447 conf.CHECK_CODE('''
1448 #include <unistd.h>
1449 main() {
1450 char *s = getcwd(NULL,0);
1451 exit(s != NULL ? 0 : 1);
1452 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
1453 msg="getcwd takes a NULL argument")
1456 conf.CHECK_CODE('''enum TDB_ERROR err = TDB_ERR_NESTING''',
1457 'HAVE_TDB_ERR_NESTING',
1458 headers='tdb.h',
1459 msg='Checking whether we have TDB_ERR_NESTING')
1461 # UnixWare 7.x has its getspnam in -lgen
1462 conf.CHECK_FUNCS_IN('getspnam', 'gen')
1463 conf.CHECK_FUNCS_IN('getspnam', 'security')
1464 conf.CHECK_FUNCS_IN('getspnam', 'sec')
1466 if Options.options.with_quotas:
1467 # For quotas on Veritas VxFS filesystems
1468 conf.CHECK_HEADERS('sys/fs/vx_quota.h')
1469 # For quotas on Linux XFS filesystems
1470 conf.CHECK_HEADERS('linux/dqblk_xfs.h')
1471 # For sys/quota.h and linux/quota.h
1472 conf.CHECK_HEADERS('sys/quota.h')
1476 # checking for clustering extensions (CTDB)
1478 if not Options.options.with_cluster_support:
1479 have_cluster_support = False
1481 else:
1483 if Options.options.ctdb_dir:
1484 conf.ADD_EXTRA_INCLUDES(Options.options.ctdb_dir + '/include')
1486 srcdir = os.path.realpath(conf.srcdir)
1487 if 'EXTRA_INCLUDES' in conf.env:
1488 includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/')
1489 else:
1490 includes = ''
1492 have_cluster_support = True
1493 ctdb_broken = ""
1495 conf.CHECK_CODE('''
1496 #define NO_CONFIG_H
1497 #include "replace.h"
1498 #include "system/wait.h"
1499 #include "system/network.h"
1500 #define private #error __USED_RESERVED_WORD_private__
1501 #include <talloc.h>
1502 #include <tdb.h>
1503 #include <ctdb.h>
1505 int main(void)
1507 return 0;
1509 ''',
1510 'HAVE_CTDB_H',
1511 addmain=False,
1512 includes=includes,
1513 msg='Checking for header ctdb.h')
1515 if not conf.CONFIG_SET('HAVE_CTDB_H'):
1516 have_cluster_support = False
1517 ctdb_broken = "ctdb.h is required for cluster support"
1519 if have_cluster_support:
1520 conf.CHECK_CODE('''
1521 #define NO_CONFIG_H
1522 #include "replace.h"
1523 #include "system/wait.h"
1524 #include "system/network.h"
1525 #define private #error __USED_RESERVED_WORD_private__
1526 #include <talloc.h>
1527 #include <tdb.h>
1528 #include <ctdb.h>
1529 #include <ctdb_private.h>
1531 int main(void)
1533 return 0;
1535 ''',
1536 'HAVE_CTDB_PRIVATE_H',
1537 addmain=False,
1538 includes=includes,
1539 msg='Checking for header ctdb_private.h')
1541 if not conf.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
1542 have_cluster_support = False
1543 ctdb_broken = "ctdb_private.h is required for cluster support"
1545 if have_cluster_support:
1546 conf.CHECK_CODE('''
1547 #define NO_CONFIG_H
1548 #include "replace.h"
1549 #include "system/wait.h"
1550 #include "system/network.h"
1551 #include <talloc.h>
1552 #include <tdb.h>
1553 #include <ctdb.h>
1554 #include <ctdb_private.h>
1556 int main(void)
1558 int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1559 return 0;
1561 ''',
1562 'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
1563 addmain=False,
1564 includes=includes,
1565 msg='Checking for transaction support (TRANS3_COMMIT control)')
1567 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
1568 have_cluster_support = False
1569 ctdb_broken = "ctdb transaction support missing or too old"
1571 if have_cluster_support:
1572 conf.CHECK_CODE('''
1573 #define NO_CONFIG_H
1574 #include "replace.h"
1575 #include "system/wait.h"
1576 #include "system/network.h"
1577 #include <talloc.h>
1578 #include <tdb.h>
1579 #include <ctdb.h>
1580 #include <ctdb_private.h>
1582 int main(void)
1584 int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1585 return 0;
1587 ''',
1588 'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
1589 addmain=False,
1590 includes=includes,
1591 msg='Checking for SCHEDULE_FOR_DELETION control')
1593 if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
1594 if not Options.options.enable_old_ctdb:
1595 have_cluster_support = False
1596 ctdb_broken = "SCHEDULE_FOR_DELETION control missing"
1597 else:
1598 Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1600 if have_cluster_support:
1601 conf.CHECK_CODE('''
1602 #define NO_CONFIG_H
1603 #include "replace.h"
1604 #include "system/wait.h"
1605 #include "system/network.h"
1606 #include <talloc.h>
1607 #include <tdb.h>
1608 #include <ctdb.h>
1609 #include <ctdb_private.h>
1611 int main(void)
1613 struct ctdb_control_tcp _x;
1614 return 0;
1616 ''',
1617 'HAVE_STRUCT_CTDB_CONTROL_TCP',
1618 addmain=False,
1619 includes=includes,
1620 msg='Checking for ctdb ipv4 support')
1622 if not conf.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
1623 have_cluster_support = False
1624 ctdb_broken = "missing struct ctdb_control_tcp"
1626 if have_cluster_support:
1627 conf.CHECK_CODE('''
1628 #define NO_CONFIG_H
1629 #include "replace.h"
1630 #include "system/wait.h"
1631 #include "system/network.h"
1632 #include <talloc.h>
1633 #include <tdb.h>
1634 #include <ctdb.h>
1635 #include <ctdb_private.h>
1637 int main(void)
1639 struct ctdb_control_tcp_addr _x;
1640 return 0;
1642 ''',
1643 'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
1644 addmain=False,
1645 includes=includes,
1646 msg='Checking for ctdb ipv6 support')
1648 if have_cluster_support:
1649 Logs.info("building with cluster support")
1650 conf.DEFINE('CLUSTER_SUPPORT', 1);
1651 else:
1652 if not Options.options.with_cluster_support:
1653 Logs.info("building without cluster support")
1654 else:
1655 Logs.warn("building without cluster support: " + ctdb_broken)
1656 conf.undefine('CLUSTER_SUPPORT')
1660 conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1661 'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1662 addmain=False,
1663 link=False,
1664 msg='Checking whether we can compile with __attribute__((destructor))')
1666 conf.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1667 'SEEKDIR_RETURNS_VOID',
1668 headers='sys/types.h dirent.h',
1669 msg='Checking whether seekdir returns void')
1671 if Options.options.with_profiling_data:
1672 conf.DEFINE('WITH_PROFILE', 1);
1674 PTHREAD_CFLAGS='error'
1675 PTHREAD_LDFLAGS='error'
1677 if PTHREAD_LDFLAGS == 'error':
1678 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
1679 PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
1680 PTHREAD_LDFLAGS='-lpthread'
1681 if PTHREAD_LDFLAGS == 'error':
1682 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
1683 PTHREAD_CFLAGS='-D_THREAD_SAFE'
1684 PTHREAD_LDFLAGS='-lpthreads'
1685 if PTHREAD_LDFLAGS == 'error':
1686 if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
1687 PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread'
1688 PTHREAD_LDFLAGS='-pthread'
1689 if PTHREAD_LDFLAGS == 'error':
1690 if conf.CHECK_FUNC('pthread_attr_init'):
1691 PTHREAD_CFLAGS='-D_REENTRANT'
1692 PTHREAD_LDFLAGS='-lpthread'
1693 # especially for HP-UX, where the CHECK_FUNC macro fails to test for
1694 # pthread_attr_init. On pthread_mutex_lock it works there...
1695 if PTHREAD_LDFLAGS == 'error':
1696 if conf.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
1697 PTHREAD_CFLAGS='-D_REENTRANT'
1698 PTHREAD_LDFLAGS='-lpthread'
1700 if PTHREAD_CFLAGS != 'error' and PTHREAD_LDFLAGS != 'error':
1701 conf.ADD_CFLAGS(PTHREAD_CFLAGS)
1702 conf.ADD_LDFLAGS(PTHREAD_LDFLAGS)
1703 conf.CHECK_HEADERS('pthread.h')
1704 conf.DEFINE('HAVE_PTHREAD', '1')
1706 if Options.options.with_pthreadpool:
1707 if conf.CONFIG_SET('HAVE_PTHREAD'):
1708 conf.DEFINE('WITH_PTHREADPOOL', '1')
1709 else:
1710 Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
1711 conf.undefine('WITH_PTHREADPOOL')
1713 if conf.CHECK_HEADERS('gpfs_gpl.h'):
1714 conf.DEFINE('HAVE_GPFS', '1')
1716 default_static_modules=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1717 auth_sam auth_unix auth_winbind auth_wbc auth_server
1718 auth_domain auth_builtin vfs_default
1719 nss_info_template idmap_tdb idmap_passdb
1720 idmap_nss''')
1722 default_shared_modules=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1723 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1724 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850
1725 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb
1726 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1727 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1728 vfs_crossrename vfs_linux_xfs_sgid
1729 vfs_time_audit idmap_autorid''')
1731 if Options.options.developer:
1732 default_static_modules.extend(TO_LIST('pdb_ads auth_netlogond'))
1733 default_shared_modules.extend(TO_LIST('charset_weird perfcount_test'))
1735 if conf.env.toplevel_build:
1736 default_static_modules.extend(TO_LIST('pdb_samba4 auth_samba4'))
1738 if Options.options.with_acl_support and conf.CONFIG_SET('HAVE_POSIX_ACLS'):
1739 default_static_modules.extend(TO_LIST('vfs_posixacl'))
1741 if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1742 default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
1744 if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
1745 default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1747 if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
1748 default_shared_modules.extend(TO_LIST('vfs_fileid'))
1750 if conf.CONFIG_SET('HAVE_AIO') and (conf.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
1751 default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
1753 if conf.CONFIG_SET('HAVE_LDAP'):
1754 default_static_modules.extend(TO_LIST('pdb_ldap idmap_ldap'))
1756 if conf.CONFIG_SET('DARWINOS'):
1757 default_shared_modules.extend(TO_LIST('charset_macosxfs'))
1759 if conf.CONFIG_SET('HAVE_GPFS'):
1760 default_shared_modules.extend(TO_LIST('vfs_gpfs vfs_gpfs_hsm_notify'))
1762 explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
1763 explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
1765 final_static_modules = default_static_modules
1766 final_shared_modules = default_shared_modules
1768 for m in explicit_static_modules:
1769 if m in final_shared_modules:
1770 final_shared_modules.remove(m)
1771 final_static_modules.append(m)
1772 for m in explicit_shared_modules:
1773 if m in final_static_modules:
1774 final_static_modules.remove(m)
1775 final_shared_modules.append(m)
1777 conf.env['static_modules'] = final_static_modules
1778 conf.env['shared_modules'] = final_shared_modules
1780 conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
1782 static_list = {}
1783 shared_list = {}
1785 prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1786 conf.env['MODULE_PREFIXES'] = prefixes
1787 for p in prefixes:
1788 for m in final_static_modules:
1789 if m.find(p) == 0:
1790 if not p in static_list:
1791 static_list[p] = []
1792 static_list[p].append(m)
1793 for m in final_shared_modules:
1794 if m.find(p) == 0:
1795 if not p in shared_list:
1796 shared_list[p] = []
1797 shared_list[p].append(m)
1799 for p in prefixes:
1800 static_env = "%s_STATIC" % p.upper()
1801 shared_env = "%s_SHARED" % p.upper()
1802 conf.env[static_env] = []
1803 conf.env[shared_env] = []
1804 if p in static_list:
1805 decl_list=""
1806 for entry in static_list[p]:
1807 decl_list += "extern NTSTATUS %s_init(void); " % entry
1808 conf.env[static_env].append('%s' % entry)
1809 decl_list = decl_list.rstrip()
1810 conf.DEFINE('static_decl_%s' % p, decl_list)
1811 conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
1812 else:
1813 conf.DEFINE('static_decl_%s' % p, '')
1814 conf.DEFINE('static_init_%s' % p, '{}')
1815 if p in shared_list:
1816 for entry in shared_list[p]:
1817 conf.DEFINE('%s_init' % entry, 'init_samba_module')
1818 conf.env[shared_env].append('%s' % entry)
1820 if not os.getenv('TOPLEVEL_BUILD'):
1821 # we don't want PYTHONDIR in config.h, as otherwise changing
1822 # --prefix causes a complete rebuild
1823 del(conf.env.defines['PYTHONDIR'])
1824 del(conf.env.defines['PYTHONARCHDIR'])
1826 conf.SAMBA_CONFIG_H('include/config.h')
1828 def ctags(ctx):
1829 "build 'tags' file using ctags"
1830 import Utils
1831 source_root = os.path.dirname(Utils.g_module.root_path)
1832 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1833 print("Running: %s" % cmd)
1834 os.system(cmd)
1836 if not os.getenv('TOPLEVEL_BUILD'):
1837 def wildcard_cmd(cmd):
1838 '''called on a unknown command'''
1839 from samba_wildcard import run_named_build_task
1840 run_named_build_task(cmd)
1841 def main():
1842 from samba_wildcard import wildcard_main
1843 wildcard_main(wildcard_cmd)
1844 Scripting.main = main