pyldb: add tests for getting control results
[Samba.git] / source3 / wscript
blob9e5a8dec41134debe64c40d5de7cd62c0d1d04df
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 import wafsamba, Options
13 import build.charset
14 import samba_utils, samba_version
15 import samba3
17 def set_options(opt):
18 opt.BUILTIN_DEFAULT('NONE')
19 opt.PRIVATE_EXTENSION_DEFAULT('s3')
20 opt.RECURSE('../lib/replace')
21 opt.RECURSE('build')
22 opt.RECURSE('selftest')
23 opt.RECURSE('../lib/nss_wrapper')
24 opt.RECURSE('../lib/socket_wrapper')
25 opt.RECURSE('../lib/tevent')
26 opt.RECURSE('../lib/tdb')
28 opt.add_option('--with-static-modules',
29 help=("Comma-separated list of names of modules to statically link in"),
30 action="store", dest='static_modules', default=None)
31 opt.add_option('--with-shared-modules',
32 help=("Comma-separated list of names of modules to build shared"),
33 action="store", dest='shared_modules', default=None)
34 opt.add_option('--enable-selftest',
35 help=("enable options necessary for selftest"),
36 action="store_true", dest='enable_selftest', default=False)
38 opt.SAMBA3_ADD_OPTION('winbind')
39 opt.SAMBA3_ADD_OPTION('swat')
40 opt.SAMBA3_ADD_OPTION('ads')
41 opt.SAMBA3_ADD_OPTION('krb5')
42 opt.SAMBA3_ADD_OPTION('ldap')
43 opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
44 opt.SAMBA3_ADD_OPTION('iprint', with_name="enable", without_name="disable")
45 opt.SAMBA3_ADD_OPTION('merged-build', with_name="enable", without_name="disable")
46 opt.SAMBA3_ADD_OPTION('pam')
47 opt.SAMBA3_ADD_OPTION('quotas')
48 opt.SAMBA3_ADD_OPTION('sys-quotas')
49 opt.SAMBA3_ADD_OPTION('sendfile-support')
50 opt.SAMBA3_ADD_OPTION('utmp')
51 opt.SAMBA3_ADD_OPTION('pthreadpool', with_name="enable", without_name="disable")
52 opt.SAMBA3_ADD_OPTION('avahi', with_name="enable", without_name="disable")
53 opt.SAMBA3_ADD_OPTION('iconv')
54 opt.SAMBA3_ADD_OPTION('acl-support')
55 opt.SAMBA3_ADD_OPTION('dnsupdate')
56 opt.SAMBA3_ADD_OPTION('syslog')
57 opt.SAMBA3_ADD_OPTION('automount')
58 opt.SAMBA3_ADD_OPTION('aio-support')
61 def configure(conf):
62 from samba_utils import TO_LIST
64 version = samba_version.load_version(env=conf.env)
66 conf.DEFINE('CONFIG_H_IS_FROM_SAMBA', 1)
67 conf.DEFINE('_SAMBA_BUILD_', version.MAJOR, add_to_cflags=True)
68 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
70 if Options.options.developer:
71 conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
72 conf.env['developer'] = True
74 if Options.options.with_swat:
75 conf.env['build_swat'] = True
77 conf.RECURSE('../lib/replace')
78 conf.RECURSE('build')
79 conf.RECURSE('../lib/tdb')
80 conf.RECURSE('../lib/talloc')
81 conf.RECURSE('../lib/tevent')
82 conf.RECURSE('../lib/popt')
83 conf.RECURSE('../lib/nss_wrapper')
84 conf.RECURSE('../lib/socket_wrapper')
85 conf.RECURSE('../lib/zlib')
86 conf.RECURSE('../libcli/smbreadline')
87 conf.RECURSE('../lib/util')
89 conf.ADD_EXTRA_INCLUDES('''#source3 #source3/include #lib/replace''')
90 if not conf.env.USING_SYSTEM_TDB:
91 conf.ADD_EXTRA_INCLUDES('#lib/tdb/include')
92 if not conf.env.USING_SYSTEM_TEVENT:
93 conf.ADD_EXTRA_INCLUDES('#lib/tevent')
94 if not conf.env.USING_SYSTEM_TALLOC:
95 conf.ADD_EXTRA_INCLUDES('#lib/talloc')
96 if not conf.env.USING_SYSTEM_POPT:
97 conf.ADD_EXTRA_INCLUDES('#lib/popt')
99 conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
101 conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
102 conf.CHECK_HEADERS('linux/falloc.h')
104 conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
105 conf.CHECK_FUNCS('strtol strchr strupr chflags')
106 conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
107 conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
108 conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
109 conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
110 conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf stat64 fstat64')
111 conf.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 fallocate fallocate64 posix_fallocate posix_fallocate64')
112 conf.CHECK_FUNCS('fseek64 fseeko64 ftell64 ftello64 setluid')
113 conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
114 conf.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
115 conf.CHECK_FUNCS('fdopendir fdopendir64')
116 conf.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
117 conf.CHECK_FUNCS('syslog vsyslog timegm setlocale nl_langinfo')
118 conf.CHECK_FUNCS_IN('nanosleep', 'rt')
119 conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
120 conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
121 conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
122 conf.CHECK_FUNCS('shmget')
123 conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
124 conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain')
125 #FIXME: for some reason this one still fails
126 conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
127 conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
128 conf.CHECK_DECLS('fdatasync', reverse=True)
129 conf.CHECK_DECLS('readahead', reverse=True, headers='fcntl.h')
131 if conf.CONFIG_SET('HAVE_LONG_LONG'):
132 conf.DEFINE('HAVE_LONGLONG', 1)
134 if conf.CHECK_CODE('''
135 #if defined(HAVE_UNISTD_H)
136 #include <unistd.h>
137 #endif
138 long ret = splice(0,0,1,0,400,0);
139 ''',
140 'HAVE_LINUX_SPLICE',
141 headers='fcntl.h'):
142 conf.CHECK_DECLS('splice', reverse=True, headers='fcntl.h')
144 # Check for inotify support
145 conf.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
146 conf.CHECK_FUNCS('inotify_init')
147 if "HAVE_LINUX_INOTIFY_H" in conf.env and "HAVE_INOTIFY_INIT" in conf.env:
148 conf.DEFINE('HAVE_INOTIFY', 1)
150 # Check for kernel change notify support
151 conf.CHECK_CODE('''
152 #ifndef F_NOTIFY
153 #define F_NOTIFY 1026
154 #endif
155 main() {
156 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
157 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
158 headers='fcntl.h signal.h',
159 msg="Checking for kernel change notify support")
161 # Check for Linux kernel oplocks
162 conf.CHECK_CODE('''
163 #include <sys/types.h>
164 #include <fcntl.h>
165 #include <signal.h>
166 #ifndef F_NOTIFY
167 #define F_NOTIFY 1026
168 #endif
169 main() {
170 exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ? 1 : 0);
171 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
172 msg="Checking for Linux kernel oplocks")
174 # Check for IRIX kernel oplock types
175 conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
176 'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
177 msg="Checking for IRIX kernel oplock types")
179 # Check for krenel share modes
180 conf.CHECK_CODE('''
181 #include <sys/types.h>
182 #include <fcntl.h>
183 #include <signal.h>
184 #include <sys/file.h>
185 #ifndef LOCK_MAND
186 #define LOCK_MAND 32
187 #define LOCK_READ 64
188 #endif
189 main() {
190 exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
191 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
192 msg="Checking for krenel share modes")
194 # Check for various members of the stat structure
195 conf.CHECK_TYPES('blksize_t blkcnt_t')
196 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
197 headers='sys/stat.h')
198 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
199 headers='sys/stat.h')
200 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define='HAVE_STAT_ST_FLAGS',
201 headers='sys/types.h sys/stat.h unistd.h')
203 # Check for POSIX capability support
204 conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
206 if "HAVE_SYS_CAPABILITY_H" in conf.env:
207 conf.CHECK_CODE('''
208 cap_t cap;
209 cap_value_t vals[1];
210 if (!(cap = cap_get_proc())) exit(1);
211 vals[0] = CAP_CHOWN;
212 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
213 cap_set_proc(cap);''',
214 'HAVE_POSIX_CAPABILITIES', execute=True, lib="cap",
215 headers='sys/capability.h',
216 msg="Checking whether POSIX capabilities are available")
218 # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
219 # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
220 # -- JRA.
221 if conf.CONFIG_SET("HAVE_RPC_RPC_H"):
222 conf.CHECK_TYPE('int16', headers='rpc/rpc.h',
223 define='HAVE_INT16_FROM_RPC_RPC_H',
224 msg="Checking for int16 typedef included by rpc/rpc.h")
225 conf.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
226 headers='sys/types.h rpc/rpc.h',
227 msg="Checking for uint16 typedef included by rpc/rpc.h")
228 conf.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
229 headers='sys/types.h rpc/rpc.h',
230 msg="Checking for int32 typedef included by rpc/rpc.h")
231 conf.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
232 headers='sys/types.h rpc/rpc.h',
233 msg="Checking for uint32 typedef included by rpc/rpc.h")
234 conf.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
235 headers='sys/types.h sys/acl.h rpcsvc/nis.h',
236 msg="Checking for broken nisplus include files")
238 # Check if the compiler will optimize out functions
239 conf.CHECK_CODE('''
240 if (0) {
241 this_function_does_not_exist();
242 } else {
243 return 1;
244 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
245 msg="Checking if the compiler will optimize out functions")
247 # Check if the compiler supports the LL suffix on long long integers
248 # AIX needs this
249 conf.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
250 headers='stdio.h',
251 msg="Checking for LL suffix on long long integers")
253 conf.CHECK_FUNCS('''
254 _acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
255 attropen attr_remove attr_removef attr_set attr_setf backtrace_symbols
256 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
257 __closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
258 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
259 extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
260 extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
261 extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
262 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
263 fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
264 _fork __fork fremoveea fremovexattr fseek64 fseeko64 fsetea
265 fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
266 ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
267 getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
268 getgrent getgrnam getgrouplist getmntent getpagesize
269 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
270 glob grantpt hstrerror initgroups innetgr
271 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
272 llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
273 lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
274 __lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
275 nl_langinfo _open __open open64 _open64 __open64 _opendir __opendir
276 opendir64 pathconf poll posix_fallocate posix_fallocate64
277 posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
278 pwrite _pwrite __pwrite pwrite64 _pwrite64
279 __pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
280 __readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
281 seekdir64 select setea setenv setgidx setgroups setlocale setluid
282 setmntent setpgid setpriv setproplist setsid setuidx
283 setxattr shmget shm_open sigaction sigblock sigprocmask sigset
284 sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
285 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
286 __sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
287 utimensat vsyslog _write __write __xstat
288 ''')
290 conf.CHECK_TYPE('struct timespec', headers='sys/time.h time.h')
292 conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
294 # FIXME: these should be tests for features, but the old build system just
295 # checks for OSes.
296 import sys
297 host_os = sys.platform
298 print "building on %s" % host_os
300 # Python doesn't have case switches... :/
301 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
302 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
304 conf.SET_TARGET_TYPE('sunacl', 'EMPTY')
305 if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('qnx') > -1):
306 if host_os.rfind('linux') > -1:
307 conf.DEFINE('LINUX', '1')
308 elif host_os.rfind('qnx') > -1:
309 conf.DEFINE('QNX', '1')
310 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
311 elif (host_os.rfind('darwin') > -1):
312 conf.DEFINE('DARWINOS', 1)
313 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
314 conf.ADD_CFLAGS('-fno-common')
315 elif (host_os.rfind('freebsd') > -1):
316 if conf.CHECK_HEADERS('sunacl.h'):
317 conf.define('HAVE_FREEBSD_SUNACL_H', '1')
318 conf.CHECK_FUNCS_IN('acl', 'sunacl')
319 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
320 elif (host_os.rfind('netbsd') > -1):
321 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
322 elif (host_os.rfind('openbsd') > -1):
323 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
324 # FIXME: Add more checks here.
325 else:
326 print "Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os
328 #FIXME: add more checks
329 if Options.options.with_acl_support:
330 if host_os.rfind('linux') > -1:
331 conf.CHECK_FUNCS_IN('acl_get_file', 'acl')
332 conf.CHECK_FUNCS_IN('getxattr', 'attr')
333 if conf.CHECK_CODE('''
334 acl_t acl;
335 int entry_id;
336 acl_entry_t *entry_p;
337 return acl_get_entry(acl, entry_id, entry_p);
338 ''',
339 'HAVE_POSIX_ACLS',
340 headers='sys/types.h sys/acl.h', link=False,
341 msg="Checking for POSIX ACL support") :
342 conf.CHECK_CODE('''
343 acl_permset_t permset_d;
344 acl_perm_t perm;
345 return acl_get_perm_np(permset_d, perm);
346 ''',
347 'HAVE_ACL_GET_PERM_NP',
348 headers='sys/types.h sys/acl.h', link=True,
349 msg="Checking whether acl_get_perm_np() is available")
350 else:
351 conf.DEFINE('HAVE_NO_ACLS', 1)
352 conf.SET_TARGET_TYPE('acl', 'EMPTY')
353 else:
354 conf.DEFINE('HAVE_NO_ACLS', 1)
355 conf.SET_TARGET_TYPE('acl', 'EMPTY')
357 if conf.CHECK_FUNCS('dirfd'):
358 conf.DEFINE('HAVE_DIRFD_DECL', 1)
360 conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
361 'HAVE_STATFS_F_FSID',
362 msg="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
363 headers='sys/types.h sys/statfs.h',
364 execute=True)
366 if conf.CONFIG_SET('HAVE_FALLOCATE'):
367 conf.CHECK_CODE('''
368 #if defined(HAVE_UNISTD_H)
369 #include <unistd.h>
370 #endif
371 #include <sys/types.h>
372 #define _GNU_SOURCE
373 #include <fcntl.h>
374 #if defined(HAVE_LINUX_FALLOC_H)
375 #include <linux/falloc.h>
376 #endif
377 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
378 'HAVE_LINUX_FALLOCATE',
379 msg="Checking whether the Linux 'fallocate' function is available")
380 if conf.CONFIG_SET('HAVE_FALLOCATE64'):
381 conf.CHECK_CODE('''
382 #if defined(HAVE_UNISTD_H)
383 #include <unistd.h>
384 #endif
385 #include <sys/types.h>
386 #define _GNU_SOURCE
387 #include <fcntl.h>
388 #if defined(HAVE_LINUX_FALLOC_H)
389 #include <linux/falloc.h>
390 #endif
391 int ret = fallocate64(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
392 'HAVE_LINUX_FALLOCATE64',
393 msg="Checking whether the Linux 'fallocate64' function is available")
394 conf.CHECK_CODE('''
395 #if defined(HAVE_UNISTD_H)
396 #include <unistd.h>
397 #endif
398 #include <fcntl.h>
399 ssize_t err = readahead(0,0,0x80000);''',
400 'HAVE_LINUX_READAHEAD',
401 msg="Checking whether Linux readahead is available")
402 conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
404 conf.CHECK_CODE('''
405 #include <sys/types.h>
406 #include <sys/socket.h>],
407 struct ucred cred;
408 socklen_t cred_len;
409 int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);''',
410 'HAVE_PEERCRED',
411 msg="Checking whether we can use SO_PEERCRED to get socket credentials")
413 conf.CHECK_CODE('''
414 #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
415 #include <sys/types.h>
416 #else
417 __COMPILE_ERROR_
418 #endif
419 int i;''',
420 'HAVE_EXPLICIT_LARGEFILE_SUPPORT',
421 msg="Checking whether large file support can be enabled")
423 if Options.options.with_aio_support:
424 conf.CHECK_FUNCS_IN('aio_read', 'aio')
425 conf.CHECK_FUNCS_IN('aio_read', 'rt')
426 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);',
427 'HAVE_AIO',
428 msg='Checking for asynchronous io support',
429 headers='sys/types.h aio.h',
430 lib='aio rt')
431 conf.CHECK_CODE('struct aiocb64 a; return aio_read64(&a);',
432 'HAVE_AIO64',
433 msg='Checking for 64-bit asynchronous io support',
434 headers='sys/types.h aio.h',
435 lib='aio rt')
436 if conf.CONFIG_SET('HAVE_AIO64'):
437 conf.DEFINE('HAVE_AIOCB64', '1')
438 conf.DEFINE('WITH_AIO', '1')
439 elif conf.CONFIG_SET('HAVE_AIO'):
440 conf.DEFINE('WITH_AIO', '1')
441 if conf.CONFIG_SET('HAVE_AIO'):
442 conf.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg='Checking for aio_read', headers='aio.h', lib='aio rt')
443 conf.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg='Checking for aio_write', headers='aio.h', lib='aio rt')
444 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')
445 conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
446 conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
447 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')
448 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')
449 if conf.CONFIG_SET('HAVE_AIO64'):
450 conf.CHECK_CODE('struct aiocb a; return aio_read64(&a);', 'HAVE_AIO_READ64', msg='Checking for aio_read64', headers='aio.h', lib='aio rt')
451 conf.CHECK_CODE('struct aiocb a; return aio_write64(&a);', 'HAVE_AIO_WRITE64', msg='Checking for aio_write64', headers='aio.h', lib='aio rt')
452 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')
453 conf.CHECK_CODE('struct aiocb a; return aio_return64(&a);', 'HAVE_AIO_RETURN64', msg='Checking for aio_return64', headers='aio.h', lib='aio rt')
454 conf.CHECK_CODE('struct aiocb a; return aio_error64(&a);', 'HAVE_AIO_ERROR64', msg='Checking for aio_error64', headers='aio.h', lib='aio rt')
455 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')
456 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')
457 if not conf.CONFIG_SET('HAVE_AIO'):
458 conf.DEFINE('HAVE_NO_AIO', '1')
459 else:
460 conf.DEFINE('HAVE_NO_AIO', '1')
462 conf.CHECK_CODE('''
463 struct msghdr msg;
464 union {
465 struct cmsghdr cm;
466 char control[CMSG_SPACE(sizeof(int))];
467 } control_un;
468 msg.msg_control = control_un.control;
469 msg.msg_controllen = sizeof(control_un.control);
470 ''',
471 'HAVE_MSGHDR_MSG_CONTROL',
472 msg='Checking if we can use msg_control for passing file descriptors',
473 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
474 conf.CHECK_CODE('''
475 struct msghdr msg;
476 int fd;
477 msg.msg_acctrights = (caddr_t) &fd;
478 msg.msg_acctrightslen = sizeof(fd);
479 ''',
480 'HAVE_MSGHDR_MSG_ACCTRIGHTS',
481 msg='Checking if we can use msg_acctrights for passing file descriptors',
482 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
484 if Options.options.with_winbind:
485 conf.env.build_winbind = True
486 conf.DEFINE('WITH_WINBIND', '1')
488 conf.find_program('awk', var='AWK')
489 conf.find_program('perl', var='PERL')
491 # Darwin has extra options to xattr-family functions
492 conf.CHECK_CODE('getxattr(0, 0, 0, 0, 0, 0);',
493 'XATTR_ADD_OPT',
494 msg="Checking whether xattr interface takes additional options",
495 headers='sys/types.h attr/xattr.h sys/xattr.h')
497 conf.CHECK_HEADERS('asm/types.h')
499 conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
500 headers='unistd.h sys/types.h',
501 msg="Checking for major macro")
503 conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
504 headers='unistd.h sys/types.h',
505 msg="Checking for minor macro")
507 conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
508 headers='unistd.h sys/types.h dirent.h',
509 define='HAVE_DIRENT_D_OFF')
511 conf.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
512 conf.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
513 msg="Checking for setnetgrent prototype",
514 headers='netdb.h netgroup.h',
515 cflags="-Werror-implicit-function-declaration")
516 conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
517 msg="Checking for getnetgrent prototype",
518 headers='netdb.h netgroup.h',
519 cflags="-Werror-implicit-function-declaration")
520 conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
521 msg="Checking for endnetgrent prototype",
522 headers='netdb.h netgroup.h',
523 cflags="-Werror-implicit-function-declaration")
526 # Look for CUPS
527 if Options.options.with_cups:
528 conf.find_program('cups-config', var='CUPS_CONFIG')
529 if conf.env.CUPS_CONFIG:
530 conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags --libs",
531 package="", uselib_store="cups")
532 conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
533 conf.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', conf.env.LIB_cups)
534 if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
535 conf.DEFINE('HAVE_CUPS', '1')
536 else:
537 conf.undefine('HAVE_CUPS')
538 conf.SET_TARGET_TYPE('cups', 'EMPTY')
539 else:
540 # define an empty subsystem for cups, to allow it to be used as an empty dependency
541 conf.SET_TARGET_TYPE('cups', 'EMPTY')
543 if Options.options.with_iprint:
544 if conf.CONFIG_SET('HAVE_CUPS'):
545 conf.DEFINE('HAVE_IPRINT', '1')
546 else:
547 print "--enable-iprint=yes but cups support not sufficient"
548 if Options.options.with_syslog:
549 conf.DEFINE('WITH_SYSLOG', '1')
550 if Options.options.with_automount:
551 conf.DEFINE('WITH_AUTOMOUNT', '1')
553 # Check for LDAP
554 if Options.options.with_ldap:
555 conf.CHECK_HEADERS('ldap.h lber.h')
556 conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
557 conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
558 conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
559 # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
560 # SASL wrapping hooks
561 if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
562 conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
563 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
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 else:
588 conf.SET_TARGET_TYPE('ldap', 'EMPTY')
589 conf.SET_TARGET_TYPE('lber', 'EMPTY')
591 # Check for kerberos
592 have_gssapi=False
593 if Options.options.with_krb5:
594 conf.find_program('krb5-config', var='KRB5_CONFIG')
595 if conf.env.KRB5_CONFIG:
596 conf.check_cfg(path="krb5-config", args="--cflags --libs",
597 package="gssapi", uselib_store="krb5")
598 conf.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib='krb5')
599 conf.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h', lib='krb5')
601 if conf.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
602 conf.env['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
604 conf.CHECK_FUNCS_IN('_et_list', 'com_err')
605 conf.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
606 conf.CHECK_FUNCS_IN('crypto', 'des_set_key')
607 conf.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
608 conf.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
609 if conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi') or \
610 conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi_krb5'):
611 have_gssapi=True
612 conf.CHECK_FUNCS_IN('gss_wrap_iov', 'gssapi gssapi_krb5 krb5')
613 conf.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
614 conf.CHECK_FUNCS('''
615 krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
616 krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
617 krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
618 krb5_auth_con_setuseruserkey krb5_locate_kdc krb5_get_permitted_enctypes
619 krb5_get_default_in_tkt_etypes krb5_free_data_contents
620 krb5_principal_get_comp_string krb5_free_unparsed_name
621 krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
622 krb5_krbhst_get_addrinfo krb5_c_enctype_compare krb5_enctypes_compatible_keys
623 krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
624 krb5_verify_checksum krb5_c_verify_checksum krb5_principal_compare_any_realm
625 krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
626 krb5_get_renewed_creds krb5_get_kdc_cred krb5_free_error_contents
627 initialize_krb5_error_table krb5_get_init_creds_opt_alloc
628 krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
629 krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
630 krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
631 krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
632 lib='krb5 k5crypto')
633 conf.CHECK_DECLS('''krb5_get_credentials_for_user
634 krb5_auth_con_set_req_cksumtype''',
635 headers='krb5.h', always=True)
636 conf.CHECK_VARIABLE('AP_OPTS_USE_SUBKEY', headers='krb5.h')
637 conf.CHECK_VARIABLE('KV5M_KEYTAB', headers='krb5.h')
638 conf.CHECK_VARIABLE('KRB5_KU_OTHER_CKSUM', headers='krb5.h')
639 conf.CHECK_VARIABLE('KRB5_KEYUSAGE_APP_DATA_CKSUM', headers='krb5.h')
640 conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'key', headers='krb5.h',
641 define='HAVE_KRB5_KEYTAB_ENTRY_KEY')
642 conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'keyblock', headers='krb5.h',
643 define='HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK')
644 conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'magic', headers='krb5.h',
645 define='HAVE_MAGIC_IN_KRB5_ADDRESS')
646 conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'addrtype', headers='krb5.h',
647 define='HAVE_ADDRTYPE_IN_KRB5_ADDRESS')
648 conf.CHECK_STRUCTURE_MEMBER('krb5_ticket', 'enc_part2', headers='krb5.h',
649 define='HAVE_KRB5_TKT_ENC_PART2')
650 conf.CHECK_STRUCTURE_MEMBER('krb5_creds', 'keyblock', headers='krb5.h',
651 define='HAVE_KRB5_KEYBLOCK_IN_CREDS')
652 conf.CHECK_STRUCTURE_MEMBER('krb5_creds', 'session', headers='krb5.h',
653 define='HAVE_KRB5_SESSION_IN_CREDS')
654 conf.CHECK_STRUCTURE_MEMBER('krb5_ap_req', 'ticket', headers='krb5.h',
655 define='HAVE_TICKET_POINTER_IN_KRB5_AP_REQ')
657 conf.CHECK_TYPE('krb5_encrypt_block', headers='krb5.h')
659 conf.CHECK_CODE('''
660 krb5_ticket ticket;
661 krb5_kvno kvno;
662 krb5_enctype enctype;
663 enctype = ticket.enc_part.enctype;
664 kvno = ticket.enc_part.kvno;
665 ''',
666 'KRB5_TICKET_HAS_KEYINFO',
667 headers='krb5.h', link=False,
668 msg="Checking whether the krb5_ticket structure contains the kvno and enctype")
669 conf.CHECK_CODE('''
670 krb5_context ctx;
671 krb5_get_init_creds_opt *opt = NULL;
672 krb5_get_init_creds_opt_free(ctx, opt);
673 ''',
674 'KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT',
675 headers='krb5.h', link=False,
676 msg="Checking whether krb5_get_init_creds_opt_free takes a context argument")
677 conf.CHECK_CODE('krb5_mk_error(0,0,0)',
678 'HAVE_SHORT_KRB5_MK_ERROR_INTERFACE',
679 headers='krb5.h', link=False,
680 msg="Checking whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal")
681 conf.CHECK_CODE('''
682 const krb5_data *pkdata;
683 krb5_context context;
684 krb5_principal principal;
685 pkdata = krb5_princ_component(context, principal, 0);
686 ''',
687 'HAVE_KRB5_PRINC_COMPONENT',
688 headers='krb5.h', lib='krb5',
689 msg="Checking whether krb5_princ_component is available")
691 conf.CHECK_CODE('''
692 int main(void) {
693 char buf[256];
694 krb5_enctype_to_string(1, buf, 256);
695 return 0;
696 }''',
697 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG',
698 headers='krb5.h', lib='krb5 k5crypto',
699 addmain=False, cflags='-Werror',
700 msg="Checking whether krb5_enctype_to_string takes size_t argument")
702 conf.CHECK_CODE('''
703 int main(void) {
704 krb5_context context = NULL;
705 char *str = NULL;
706 krb5_enctype_to_string(context, 1, &str);
707 if (str) free (str);
708 return 0;
709 }''',
710 'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG',
711 headers='krb5.h stdlib.h', lib='krb5',
712 addmain=False, cflags='-Werror',
713 msg="Checking whether krb5_enctype_to_string takes krb5_context argument")
714 conf.CHECK_CODE('''
715 int main(void) {
716 krb5_context ctx = NULL;
717 krb5_principal princ = NULL;
718 const char *str = krb5_princ_realm(ctx, princ)->data;
719 return 0;
720 }''',
721 'HAVE_KRB5_PRINC_REALM',
722 headers='krb5.h', lib='krb5',
723 addmain=False,
724 msg="Checking whether the macro krb5_princ_realm is defined")
725 conf.CHECK_CODE('''
726 int main(void) {
727 krb5_context context;
728 krb5_principal principal;
729 const char *realm; realm = krb5_principal_get_realm(context, principal);
730 return 0;
731 }''',
732 'HAVE_KRB5_PRINCIPAL_GET_REALM',
733 headers='krb5.h', lib='krb5',
734 addmain=False,
735 msg="Checking whether krb5_principal_get_realm is defined")
736 if conf.CHECK_CODE('''krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);''',
737 'KRB5_VERIFY_CHECKSUM_ARGS',
738 headers='krb5.h', lib='krb5',
739 msg="Checking whether krb5_verify_checksum takes 7 arguments"):
740 conf.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '7')
741 else:
742 conf.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '6')
744 conf.CHECK_CODE('''
745 krb5_enctype enctype;
746 enctype = ENCTYPE_ARCFOUR_HMAC_MD5;
747 ''',
748 '_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5',
749 headers='krb5.h', lib='krb5',
750 msg="Checking whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available");
751 conf.CHECK_CODE('''
752 krb5_keytype keytype;
753 keytype = KEYTYPE_ARCFOUR_56;
754 ''',
755 '_HAVE_KEYTYPE_ARCFOUR_56',
756 headers='krb5.h', lib='krb5',
757 msg="Checking whether the HAVE_KEYTYPE_ARCFOUR_56 key type definition is available");
758 if conf.CONFIG_SET('_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and conf.CONFIG_SET('_HAVE_KEYTYPE_ARCFOUR_56'):
759 conf.DEFINE('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', '1')
761 conf.CHECK_CODE('''
762 krb5_enctype enctype;
763 enctype = ENCTYPE_ARCFOUR_HMAC;
764 ''',
765 'HAVE_ENCTYPE_ARCFOUR_HMAC',
766 headers='krb5.h', lib='krb5',
767 msg="Checking whether the ENCTYPE_ARCFOUR_HMAC key type definition is available");
769 conf.CHECK_CODE('''
770 krb5_context context;
771 krb5_keytab keytab;
772 krb5_init_context(&context);
773 return krb5_kt_resolve(context, "WRFILE:api", &keytab);
774 ''',
775 'HAVE_WRFILE_KEYTAB',
776 headers='krb5.h', lib='krb5', execute=True,
777 msg="Checking whether the WRFILE:-keytab is supported");
779 # Check for KRB5_DEPRECATED handling
780 conf.CHECK_CODE('''#define KRB5_DEPRECATED 1
781 #include <krb5.h>''',
782 'HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER', addmain=False,
783 link=False,
784 msg="Checking for KRB5_DEPRECATED define taking an identifier")
785 else:
786 conf.SET_TARGET_TYPE('krb5', 'EMPTY')
787 conf.SET_TARGET_TYPE('gssapi', 'EMPTY')
788 conf.SET_TARGET_TYPE('gssapi_krb5', 'EMPTY')
789 conf.SET_TARGET_TYPE('com_err', 'EMPTY')
790 conf.SET_TARGET_TYPE('k5crypto', 'EMPTY')
792 if Options.options.with_ads:
793 use_ads=True
794 if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
795 not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
796 print "arcfour-hmac-md5 encryption type not found in -lkrb5"
797 use_ads=False
798 if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
799 print "krb5_mk_req_extended not found in -lkrb5"
800 use_ads=False
801 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
802 not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
803 print "no CREATE_KEY_FUNCTIONS detected"
804 use_ads=False
805 if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
806 not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
807 print "no GET_ENCTYPES_FUNCTIONS detected"
808 use_ads=False
809 if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
810 not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
811 print "no KT_FREE_FUNCTION detected"
812 use_ads=False
813 if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM') and \
814 not conf.CONFIG_SET('HAVE_KRB5_VERIFY_CHECKSUM'):
815 print "no KRB5_VERIFY_CHECKSUM_FUNCTION detected"
816 use_ads=False
817 if not conf.CONFIG_SET('KRB5_TICKET_HAS_KEYINFO'):
818 # We only need the following functions if we can't get the enctype
819 # and kvno out of the ticket directly (ie. on Heimdal).
820 if not conf.CONFIG_SET('free_AP_REQ'):
821 print "no KRB5_AP_REQ_FREE_FUNCTION detected"
822 use_ads=False
823 if not conf.CONFIG_SET('HAVE_KRB5_DECODE_AP_REQ'):
824 print "no KRB5_AP_REQ_DECODING_FUNCTION detected"
825 use_ads=False
826 if use_ads:
827 conf.DEFINE('WITH_ADS', '1')
828 conf.DEFINE('HAVE_KRB5', '1')
829 if have_gssapi:
830 conf.DEFINE('HAVE_GSSAPI', '1')
831 else:
832 print "krb5 libs don't have all features required for Active Directory support"
833 conf.undefine('HAVE_KRB5_H')
834 conf.undefine('HAVE_GSSAPI_H')
835 conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
836 conf.undefine('HAVE_GSSAPI_GSSAPI_H')
838 if Options.options.with_utmp:
839 conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
840 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
841 define='HAVE_UT_UT_NAME')
842 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers='utmp.h',
843 define='HAVE_UT_UT_USER')
844 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers='utmp.h',
845 define='HAVE_UT_UT_ID')
846 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers='utmp.h',
847 define='HAVE_UT_UT_HOST')
848 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers='utmp.h',
849 define='HAVE_UT_UT_TIME')
850 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers='utmp.h',
851 define='HAVE_UT_UT_TV')
852 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers='utmp.h',
853 define='HAVE_UT_UT_TYPE')
854 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers='utmp.h',
855 define='HAVE_UT_UT_PID')
856 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers='utmp.h',
857 define='HAVE_UT_UT_EXIT')
858 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers='utmp.h',
859 define='HAVE_UT_UT_ADDR_V6')
860 conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers='utmp.h',
861 define='HAVE_UT_UT_ADDR')
862 conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers='utmpx.h',
863 define='HAVE_UX_UT_SYSLEN')
864 conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
865 'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
866 msg="Checking whether pututline returns pointer")
867 conf.DEFINE('WITH_UTMP', 1)
869 if Options.options.with_avahi:
870 conf.env.with_avahi = True
871 if not conf.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf.env.with_avahi = False
872 if not conf.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf.env.with_avahi = False
873 if not conf.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf.env.with_avahi = False
874 if conf.env.with_avahi:
875 conf.DEFINE('WITH_AVAHI_SUPPORT', 1)
876 else:
877 conf.SET_TARGET_TYPE('avahi-common', 'EMPTY')
878 conf.SET_TARGET_TYPE('avahi-client', 'EMPTY')
880 if Options.options.with_iconv:
881 conf.env.with_iconv = True
882 if not conf.CHECK_FUNCS_IN('iconv_open', 'iconv', headers='iconv.h'):
883 conf.env.with_iconv = False
884 if conf.env.with_iconv:
885 conf.DEFINE('HAVE_ICONV', 1)
887 if Options.options.with_pam:
888 use_pam=True
889 conf.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
890 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
891 print "--with-pam=yes but pam_appl.h not found"
892 use_pam=False
893 conf.CHECK_FUNCS_IN('pam_get_data', 'pam')
894 conf.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
895 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
896 print "--with-pam=yes but pam_modules.h not found"
897 use_pam=False
898 conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
899 conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
900 conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
901 conf.CHECK_CODE('''
902 #if defined(HAVE_SECURITY_PAM_APPL_H)
903 #include <security/pam_appl.h>
904 #elif defined(HAVE_PAM_PAM_APPL_H)
905 #include <pam/pam_appl.h>
906 #endif
907 pam_set_item(0, PAM_RHOST, 0);
908 ''',
909 'HAVE_PAM_RHOST',
910 lib='pam',
911 msg="Checking whether PAM_RHOST is available");
912 conf.CHECK_CODE('''
913 #if defined(HAVE_SECURITY_PAM_APPL_H)
914 #include <security/pam_appl.h>
915 #elif defined(HAVE_PAM_PAM_APPL_H)
916 #include <pam/pam_appl.h>
917 #endif
918 pam_set_item(0, PAM_TTY, 0);
919 ''',
920 'HAVE_PAM_TTY',
921 lib='pam',
922 msg="Checking whether PAM_TTY is available");
923 conf.CHECK_CODE('''
924 #if (!defined(LINUX))
926 #define PAM_EXTERN extern
927 #if defined(HAVE_SECURITY_PAM_APPL_H)
928 #include <security/pam_appl.h>
929 #elif defined(HAVE_PAM_PAM_APPL_H)
930 #include <pam/pam_appl.h>
931 #endif
933 #endif
935 #if defined(HAVE_SECURITY_PAM_MODULES_H)
936 #include <security/pam_modules.h>
937 #elif defined(HAVE_PAM_PAM_MODULES_H)
938 #include <pam/pam_modules.h>
939 #endif
941 #if defined(HAVE_SECURITY__PAM_MACROS_H)
942 #include <security/_pam_macros.h>
943 #elif defined(HAVE_PAM__PAM_MACROS_H)
944 #include <pam/_pam_macros.h>
945 #endif
947 #ifdef HAVE_SECURITY_PAM_EXT_H
948 #include <security/pam_ext.h>
949 #endif
951 int i; i = PAM_RADIO_TYPE;
952 ''',
953 'HAVE_PAM_RADIO_TYPE',
954 lib='pam',
955 msg="Checking whether PAM_RADIO_TYPE is available");
956 if use_pam:
957 conf.DEFINE('WITH_PAM', 1)
958 conf.DEFINE('WITH_PAM_MODULES', 1)
960 seteuid = False
961 if not seteuid:
962 seteuid = conf.CHECK_CODE('''
963 #define AUTOCONF_TEST 1
964 #define USE_SETREUID 1
965 #include "./lib/util_sec.c"
966 ''',
967 'USE_SETREUID',
968 addmain=False,
969 execute=True,
970 msg="Checking whether setreuid is available")
971 if not seteuid:
972 seteuid = conf.CHECK_CODE('''
973 #define AUTOCONF_TEST 1
974 #define USE_SETRESUID 1
975 #include "./lib/util_sec.c"
976 ''',
977 'USE_SETRESUID',
978 addmain=False,
979 execute=True,
980 msg="Checking whether setresuid is available")
981 if not seteuid:
982 seteuid = conf.CHECK_CODE('''
983 #define AUTOCONF_TEST 1
984 #define USE_SETEUID 1
985 #include "./lib/util_sec.c"
986 ''',
987 'USE_SETEUID',
988 addmain=False,
989 execute=True,
990 msg="Checking whether seteuid is available")
991 if not seteuid:
992 seteuid = conf.CHECK_CODE('''
993 #define AUTOCONF_TEST 1
994 #define USE_SETUIDX 1
995 #include "./lib/util_sec.c"
996 ''',
997 'USE_SETUIDX',
998 addmain=False,
999 execute=True,
1000 mandatory=True,
1001 msg="Checking whether setuidx is available")
1002 if Options.options.with_dnsupdate:
1003 conf.CHECK_HEADERS('uuid/uuid.h')
1004 conf.CHECK_FUNCS_IN('uuid_generate', 'uuid')
1005 if not conf.CONFIG_SET('HAVE_UUID_UUID_H') and not conf.CONFIG_SET('HAVE_UUID_GENERATE'):
1006 print "--with-dnsupdate=yes but uuid support not sufficient"
1007 elif not conf.CONFIG_SET('HAVE_GSSAPI'):
1008 print "--with-dnsupdate=yes but gssapi support not sufficient"
1009 else:
1010 conf.DEFINE('WITH_DNS_UPDATES', 1)
1011 else:
1012 conf.SET_TARGET_TYPE('uuid', 'EMPTY')
1013 conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
1014 if Options.options.developer:
1015 if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
1016 conf.DEFINE('VALGRIND', '1')
1018 if conf.CHECK_CODE('''
1019 #include <bits/sockaddr.h>
1020 #include <linux/netlink.h>
1021 ''',
1022 'HAVE_LINUX_NETLINK_H',
1023 msg="Checking whether Linux netlink is available"):
1024 conf.CHECK_CODE('''
1025 #include <bits/sockaddr.h>
1026 #include <linux/netlink.h>
1027 #include <linux/rtnetlink.h>
1028 ''',
1029 'HAVE_LINUX_RTNETLINK_H',
1030 msg='Checking whether Linux rtnetlink is available')
1031 if conf.CHECK_TYPE('struct dirent64', headers='sys/types.h dirent.h') and conf.CONFIG_SET('HAVE_READDIR64'):
1032 conf.DEFINE('HAVE_STRUCT_DIRENT64', '1')
1033 else:
1034 conf.undefine('HAVE_STRUCT_DIRENT64')
1036 conf.CHECK_CODE('''
1037 #include "../tests/fcntl_lock.c"
1038 ''',
1039 'HAVE_FCNTL_LOCK',
1040 addmain=False,
1041 execute=True,
1042 msg='Checking whether fcntl locking is available')
1044 conf.CHECK_CODE('''
1045 #include "../tests/fcntl_lock64.c"
1046 ''',
1047 'HAVE_BROKEN_FCNTL64_LOCKS',
1048 addmain=False,
1049 execute=True,
1050 msg='Checking whether fcntl64 locks are broken')
1052 if not conf.CONFIG_SET('HAVE_BROKEN_FCNTL64_LOCKS'):
1053 conf.CHECK_CODE('''
1054 #if defined(HAVE_UNISTD_H)
1055 #include <unistd.h>
1056 #endif
1057 #include <stdio.h>
1058 #include <stdlib.h>
1060 #ifdef HAVE_FCNTL_H
1061 #include <fcntl.h>
1062 #endif
1064 #ifdef HAVE_SYS_FCNTL_H
1065 #include <sys/fcntl.h>
1066 #endif
1067 main() { struct flock64 fl64;
1068 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
1069 exit(0);
1070 #else
1071 exit(1);
1072 #endif
1074 ''',
1075 'HAVE_STRUCT_FLOCK64',
1076 addmain=False,
1077 execute=True,
1078 msg="Checking whether the flock64 struct is available")
1080 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1081 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1082 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1083 define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1084 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1085 define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1086 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1087 define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1088 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1089 define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1090 if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1091 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1092 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1093 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1094 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1095 conf.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1097 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1098 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1099 define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1100 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1101 define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1102 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1103 define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1105 conf.CHECK_CODE('''
1106 #if defined(HAVE_UNISTD_H)
1107 #include <unistd.h>
1108 #endif
1109 #include <fcntl.h>],
1110 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1111 ''',
1112 'HAVE_POSIX_FADVISE',
1113 msg='Checking whether posix_fadvise is available')
1115 for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1116 conf.CHECK_CODE('''
1117 #include <unistd.h>
1118 return sysconf(%s) == -1 ? 1 : 0;
1119 ''' % v,
1120 'SYSCONF%s' % v,
1121 msg='Checking whether sysconf(%s) is available' % v)
1123 conf.CHECK_DECLS('__NR_inotify_init', reverse=True, headers='asm/unistd.h')
1125 conf.CHECK_CODE('''
1126 #include <sys/syscall.h>
1127 #include <unistd.h>
1128 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1129 ''',
1130 'HAVE_DARWIN_INITGROUPS',
1131 msg='Checking hether to use the Darwin-specific initgroups system call')
1133 conf.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1134 'HAVE_UTIMBUF',
1135 headers='sys/types.h utime.h',
1136 msg='Checking whether struct utimbuf is available')
1138 if conf.CHECK_CODE('''struct sigevent s;''',
1139 'HAVE_STRUCT_SIGEVENT',
1140 headers='sys/types.h stdlib.h stddef.h signal.h',
1141 msg='Checking whether we have the struct sigevent'):
1142 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1143 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1144 headers='signal.h');
1145 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1146 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1147 headers='signal.h');
1149 default_static_modules=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1150 auth_sam auth_unix auth_winbind auth_wbc auth_server
1151 auth_domain auth_builtin vfs_default
1152 nss_info_template idmap_tdb idmap_passdb
1153 idmap_nss''')
1155 default_shared_modules=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1156 vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1157 vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850
1158 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb
1159 vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1160 vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1161 vfs_crossrename vfs_linux_xfs_sgid
1162 vfs_time_audit idmap_autorid''')
1164 if Options.options.developer:
1165 default_static_modules.extend(TO_LIST('pdb_ads auth_netlogond'))
1166 default_shared_modules.extend(TO_LIST('charset_weird perfcount_test'))
1168 if Options.options.with_acl_support and conf.CONFIG_SET('HAVE_POSIX_ACLS'):
1169 default_static_modules.extend(TO_LIST('vfs_posixacl'))
1171 if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1172 default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
1174 if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
1175 default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1177 if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
1178 default_shared_modules.extend(TO_LIST('vfs_fileid'))
1180 if conf.CONFIG_SET('HAVE_AIO') and (conf.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
1181 default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
1183 if conf.CONFIG_SET('HAVE_LDAP'):
1184 default_static_modules.extend(TO_LIST('pdb_ldap idmap_ldap'))
1186 if conf.CONFIG_SET('DARWINOS'):
1187 default_shared_modules.extend(TO_LIST('charset_macosxfs'))
1189 explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
1190 explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
1192 final_static_modules = default_static_modules
1193 final_shared_modules = default_shared_modules
1195 for m in explicit_static_modules:
1196 if m in final_shared_modules:
1197 final_shared_modules.remove(m)
1198 final_static_modules.append(m)
1199 for m in explicit_shared_modules:
1200 if m in final_static_modules:
1201 final_static_modules.remove(m)
1202 final_shared_modules.append(m)
1204 conf.env['static_modules'] = final_static_modules
1205 conf.env['shared_modules'] = final_shared_modules
1207 conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
1209 static_list = {}
1210 shared_list = {}
1212 prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1213 conf.env['MODULE_PREFIXES'] = prefixes
1214 for p in prefixes:
1215 for m in final_static_modules:
1216 if m.find(p) == 0:
1217 if not p in static_list:
1218 static_list[p] = []
1219 static_list[p].append(m)
1220 for m in final_shared_modules:
1221 if m.find(p) == 0:
1222 if not p in shared_list:
1223 shared_list[p] = []
1224 shared_list[p].append(m)
1226 for p in prefixes:
1227 static_env = "%s_STATIC" % p.upper()
1228 shared_env = "%s_SHARED" % p.upper()
1229 conf.env[static_env] = []
1230 conf.env[shared_env] = []
1231 if p in static_list:
1232 decl_list=""
1233 for entry in static_list[p]:
1234 decl_list += "extern NTSTATUS %s_init(void); " % entry
1235 conf.env[static_env].append('%s' % entry)
1236 decl_list = decl_list.rstrip()
1237 conf.DEFINE('static_decl_%s' % p, decl_list)
1238 conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init(); '.join(static_list[p]))
1239 else:
1240 conf.DEFINE('static_decl_%s' % p, '')
1241 conf.DEFINE('static_init_%s' % p, '{}')
1242 if p in shared_list:
1243 for entry in shared_list[p]:
1244 conf.DEFINE('%s_init' % entry, 'init_samba_module')
1245 conf.env[shared_env].append('%s' % entry)
1247 conf.SAMBA_CONFIG_H('include/config.h')
1249 def ctags(ctx):
1250 "build 'tags' file using ctags"
1251 import Utils
1252 source_root = os.path.dirname(Utils.g_module.root_path)
1253 cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1254 print("Running: %s" % cmd)
1255 os.system(cmd)