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