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