Debian Codegraph @

source3/wscript

raw
1 #!/usr/bin/env python
2
3 srcdir = ".."
4
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
10 from waflib import Options, Logs, Errors
11 import wafsamba
12 import build.charset
13 from wafsamba import samba_utils
14 from samba_utils import TO_LIST
15 import samba3
16
17 default_prefix = Options.default_prefix = '/usr/local/samba'
18
19 def options(opt):
20
21 opt.add_option('--with-static-modules',
22 help=("Comma-separated list of names of modules to statically link in. "+
23 "May include !module to disable 'module'. "+
24 "Can be '!FORCED' to disable all non-required static only modules. "+
25 "Can be '!DEFAULT' to disable all modules defaulting to a static build. "+
26 "Can be 'ALL' to build all default shared modules static. "+
27 "The most specific one wins, while the order is ignored "+
28 "and --with-static-modules is evaluated before "+
29 "--with-shared-modules"),
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 "May include !module to disable 'module'. "+
34 "Can be '!FORCED' to disable all non-required shared only modules. "+
35 "Can be '!DEFAULT' to disable all modules defaulting to a shared build. "+
36 "Can be 'ALL' to build all default static modules shared. "+
37 "The most specific one wins, while the order is ignored "+
38 "and --with-static-modules is evaluated before "+
39 "--with-shared-modules"),
40 action="store", dest='shared_modules', default=None)
41
42 # Optional Libraries
43 # ------------------
44 #
45 # Most of the calls to opt.samba_add_onoff_option() implicitly
46 # or explicitly use default=True
47 #
48 # To assist users and distributors to build Samba with the full feature
49 # set, the build system will abort if our dependent libraries and their
50 # header files are not found on the target system. This will mean for
51 # example, that xattr, acl and ldap headers must be installed for the
52 # default build to complete. The configure system will check for these
53 # headers, and the error message will indicate the option (such as
54 # --without-acl-support) that can be specified to skip this requirement.
55 #
56 # This will assist users and in particular distributors in building fully
57 # functional packages, while allowing those on systems truly without these
58 # facilities to continue to build Samba after careful consideration.
59 #
60 # It also ensures our container image generation in bootstrap/ is correct
61 # as otherwise a missing package there would just silently work
62
63 opt.samba_add_onoff_option('winbind')
64 opt.samba_add_onoff_option('ads')
65 opt.samba_add_onoff_option('cups', with_name="enable", without_name="disable")
66 opt.samba_add_onoff_option('iprint', with_name="enable", without_name="disable")
67 opt.samba_add_onoff_option('pam')
68 opt.samba_add_onoff_option('quotas', default=None)
69 opt.samba_add_onoff_option('sendfile-support', default=None)
70 opt.samba_add_onoff_option('utmp')
71 opt.samba_add_onoff_option('avahi', with_name="enable", without_name="disable")
72 opt.samba_add_onoff_option('iconv')
73 opt.samba_add_onoff_option('acl-support')
74 opt.samba_add_onoff_option('syslog')
75 opt.samba_add_onoff_option('automount')
76 opt.samba_add_onoff_option('dmapi', default=None) # None means autodetection
77 opt.samba_add_onoff_option('fam', default=None) # None means autodetection
78 opt.samba_add_onoff_option('profiling-data', default=False)
79 opt.samba_add_onoff_option('libarchive', default=True)
80 opt.samba_add_onoff_option('prometheus-exporter', default=False)
81
82 opt.samba_add_onoff_option('cluster-support', default=False)
83
84 opt.samba_add_onoff_option('regedit', default=None)
85 opt.samba_add_onoff_option('winexe', default=None)
86
87 opt.samba_add_onoff_option('fake-kaserver',
88 help=("Include AFS fake-kaserver support"), default=False)
89
90 opt.samba_add_onoff_option('glusterfs', with_name="enable", without_name="disable", default=True)
91 opt.samba_add_onoff_option('cephfs', with_name="enable", without_name="disable", default=None)
92
93 opt.add_option('--enable-vxfs',
94 help=("enable support for VxFS (default=no)"),
95 action="store_true", dest='enable_vxfs', default=False)
96
97 # default = None means autodetection
98 opt.samba_add_onoff_option('spotlight', with_name="enable", without_name="disable", default=None)
99 opt.samba_add_onoff_option('wsp', with_name="enable", without_name="disable", default=True)
100
101 def configure(conf):
102 default_static_modules = []
103 default_shared_modules = []
104 required_static_modules = []
105 forced_static_modules = []
106 forced_shared_modules = []
107
108 if sys.platform != 'openbsd5':
109 conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
110
111 # We crash without vfs_default
112 # and vfs_not_implemented provides helper function
113 # for other modules
114 required_static_modules.extend(['vfs_default', 'vfs_not_implemented'])
115
116 conf.CHECK_HEADERS('netdb.h')
117 conf.CHECK_HEADERS('linux/falloc.h linux/ioctl.h')
118 conf.CHECK_HEADERS('linux/magic.h')
119
120 conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknodat')
121 conf.CHECK_FUNCS('strtol strchr strupr chflags fchflags')
122 conf.CHECK_FUNCS('getrlimit fsync setpgid')
123 conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
124 conf.CHECK_FUNCS('innetgr')
125 conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
126 conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
127 conf.CHECK_FUNCS('atexit grantpt posix_openpt fallocate')
128 conf.CHECK_FUNCS('fseeko setluid')
129 conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
130 conf.CHECK_FUNCS('fdopendir')
131 conf.CHECK_FUNCS('getpwent_r setenv clearenv strcasecmp')
132 conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
133 conf.CHECK_FUNCS('lutimes utimensat futimens')
134 conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
135 conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
136 conf.CHECK_FUNCS('getdomainname')
137 conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
138 conf.CHECK_FUNCS_IN('dn_expand', 'inet')
139 conf.CHECK_DECLS('readahead', reverse=True, headers='fcntl.h')
140
141 if conf.CHECK_CODE('''
142 #if defined(HAVE_UNISTD_H)
143 #include <unistd.h>
144 #endif
145 long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
146 ''',
147 'HAVE_LINUX_SPLICE',
148 headers='fcntl.h'):
149 conf.CHECK_DECLS('splice', reverse=True, headers='fcntl.h')
150
151 # Check for inotify support (Skip if we are SunOS)
152 #NOTE: illumos provides sys/inotify.h but is not an exact match for linux
153 host_os = sys.platform
154 if host_os.rfind('sunos') == -1:
155 conf.CHECK_HEADERS('sys/inotify.h')
156 if conf.env.HAVE_SYS_INOTIFY_H:
157 conf.DEFINE('HAVE_INOTIFY', 1)
158
159 # Check for Linux kernel oplocks
160 if conf.CHECK_DECLS('F_SETLEASE', headers='linux/fcntl.h', reverse=True):
161 conf.DEFINE('HAVE_KERNEL_OPLOCKS_LINUX', 1)
162
163 # check for fam libs
164 samba_fam_libs=None
165 check_for_fam=False
166 if Options.options.with_fam is None:
167 check_for_fam=True
168 elif Options.options.with_fam == True:
169 check_for_fam=True
170
171 if check_for_fam and conf.CHECK_HEADERS('fam.h'):
172 if conf.CHECK_FUNCS_IN('FAMOpen2', 'fam'):
173 samba_fam_libs='fam'
174 elif conf.CHECK_FUNCS_IN('FAMOpen2', 'fam C'):
175 samba_fam_libs='fam C'
176 conf.CHECK_TYPE('enum FAMCodes', headers='fam.h',
177 define='HAVE_FAM_H_FAMCODES_TYPEDEF',
178 msg='Checking whether enum FAMCodes is available')
179 conf.CHECK_FUNCS_IN('FAMNoExists', 'fam')
180
181 if samba_fam_libs is not None:
182 conf.DEFINE('SAMBA_FAM_LIBS', samba_fam_libs)
183 conf.DEFINE('HAVE_FAM', 1)
184 else:
185 if Options.options.with_fam == True:
186 conf.fatal('FAM support requested, but no suitable FAM library found')
187 elif check_for_fam:
188 Logs.warn('no suitable FAM library found')
189
190 # check for libarchive (tar command in smbclient)
191 # None means autodetect, True/False means enable/disable
192 conf.SET_TARGET_TYPE('archive', 'EMPTY')
193 if Options.options.with_libarchive is not False:
194 Logs.info("Checking for libarchive existence")
195 if conf.CHECK_HEADERS('archive.h') and conf.CHECK_LIB('archive', shlib=True):
196 conf.CHECK_FUNCS_IN('archive_read_support_filter_all archive_read_free', 'archive')
197 else:
198 conf.fatal("libarchive support not found. "
199 "Try installing libarchive-dev or libarchive-devel. "
200 "Otherwise, use --without-libarchive to "
201 "build without libarchive support. "
202 "libarchive support is required for the smbclient "
203 "tar-file mode")
204 elif conf.CONFIG_GET('ENABLE_SELFTEST'):
205 raise Errors.WafError('libarchive library required for '
206 '--enable-selftest')
207
208 # check for libevent, needed for prometheus http endpoint
209 conf.SET_TARGET_TYPE('event', 'EMPTY')
210 if Options.options.with_prometheus_exporter is True:
211 if not Options.options.with_profiling_data:
212 conf.fatal("Building --with-prometheus-exporter also require "
213 "building --with-profiling-data.")
214 Logs.info("Checking for libevent existence")
215 if conf.CHECK_HEADERS('event2/http.h') and conf.CHECK_LIB('event', shlib=True):
216 conf.CHECK_FUNCS_IN('evhttp_new', 'event')
217 if not conf.CONFIG_SET('HAVE_EVHTTP_NEW'):
218 conf.fatal("libevent support not found. "
219 "Try installing libevent-dev or libevent-devel. "
220 "libevent support is required for the prometheus "
221 "endpoint")
222
223 # check for DMAPI libs
224 if Options.options.with_dmapi == False:
225 have_dmapi = False
226 else:
227 have_dmapi = True
228 Logs.info("Checking for DMAPI library existence")
229 samba_dmapi_lib = ''
230 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dm'):
231 samba_dmapi_lib = 'dm'
232 else:
233 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'jfsdm'):
234 samba_dmapi_lib = 'jfsdm'
235 else:
236 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dmapi'):
237 samba_dmapi_lib = 'dmapi'
238 else:
239 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'xdsm'):
240 samba_dmapi_lib = 'xdsm'
241 # only bother to test headers and compilation when a candidate
242 # library has been found
243 if samba_dmapi_lib == '':
244 have_dmapi = False
245 broken_dmapi = "no suitable DMAPI library found"
246
247 if have_dmapi:
248 conf.CHECK_HEADERS('sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h dmapi.h')
249 conf.CHECK_CODE('''
250 #include <time.h> /* needed by Tru64 */
251 #include <sys/types.h> /* needed by AIX */
252 #ifdef HAVE_XFS_DMAPI_H
253 #include <xfs/dmapi.h>
254 #elif defined(HAVE_SYS_DMI_H)
255 #include <sys/dmi.h>
256 #elif defined(HAVE_SYS_JFSDMAPI_H)
257 #include <sys/jfsdmapi.h>
258 #elif defined(HAVE_SYS_DMAPI_H)
259 #include <sys/dmapi.h>
260 #elif defined(HAVE_DMAPI_H)
261 #include <dmapi.h>
262 #endif
263
264 /* This link test is designed to fail on IRI 6.4, but should
265 * succeed on Linux, IRIX 6.5 and AIX.
266 */
267 int main(int argc, char **argv)
268 {
269 char * version;
270 dm_eventset_t events;
271 /* This doesn't take an argument on IRIX 6.4. */
272 dm_init_service(&version);
273 /* IRIX 6.4 expects events to be a pointer. */
274 DMEV_ISSET(DM_EVENT_READ, events);
275
276 return 0;
277 }
278 ''',
279 'USEABLE_DMAPI_LIBRARY',
280 addmain=False,
281 execute=False,
282 lib=samba_dmapi_lib,
283 msg='Checking whether DMAPI lib '+samba_dmapi_lib+' can be used')
284 if not conf.CONFIG_SET('USEABLE_DMAPI_LIBRARY'):
285 have_dmapi = False
286 broken_dmapi = "no usable DMAPI library found"
287
288 if have_dmapi:
289 Logs.info("Building with DMAPI support.")
290 conf.env['dmapi_lib'] = samba_dmapi_lib
291 conf.DEFINE('USE_DMAPI', 1)
292 else:
293 if Options.options.with_dmapi == False:
294 Logs.info("Building without DMAPI support (--without-dmapi).")
295 elif Options.options.with_dmapi == True:
296 Logs.error("DMAPI support not available: " + broken_dmapi)
297 conf.fatal('DMAPI support requested but not found.');
298 else:
299 Logs.warn("Building without DMAPI support: " + broken_dmapi)
300 conf.env['dmapi_lib'] = ''
301
302 # Check for various members of the stat structure
303 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
304 headers='sys/stat.h')
305 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
306 headers='sys/stat.h')
307 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define='HAVE_STAT_ST_FLAGS',
308 headers='sys/types.h sys/stat.h unistd.h')
309
310 if conf.env.HAVE_BLKCNT_T:
311 conf.CHECK_CODE('''
312 static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 4)];''',
313 'SIZEOF_BLKCNT_T_4',
314 headers='replace.h sys/types.h sys/stat.h unistd.h',
315 msg="Checking whether blkcnt_t is 32 bit")
316
317 # If sizeof is 4 it can't be 8
318 if conf.env.HAVE_BLKCNT_T:
319 if not conf.CONFIG_SET('SIZEOF_BLKCNT_T_4'):
320 conf.CHECK_CODE('''
321 static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 8)];''',
322 'SIZEOF_BLKCNT_T_8',
323 headers='replace.h sys/types.h sys/stat.h unistd.h',
324 msg="Checking whether blkcnt_t is 64 bit")
325
326 # Check for POSIX capability support
327 conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
328
329 if conf.env.HAVE_SYS_CAPABILITY_H:
330 conf.CHECK_CODE('''
331 cap_t cap;
332 cap_value_t vals[1];
333 if (!(cap = cap_get_proc())) exit(1);
334 vals[0] = CAP_CHOWN;
335 cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
336 cap_set_proc(cap);''',
337 'HAVE_POSIX_CAPABILITIES', execute=True, lib="cap",
338 headers='sys/capability.h',
339 msg="Checking whether POSIX capabilities are available")
340
341 conf.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
342 headers='sys/types.h sys/acl.h rpcsvc/nis.h',
343 msg="Checking for broken nisplus include files")
344
345 # Check if the compiler will optimize out functions
346 conf.CHECK_CODE('''
347 #include <sys/types.h>
348 size_t __unsafe_string_function_usage_here_size_t__(void);
349 #define CHECK_STRING_SIZE(d, len) (sizeof(d) != (len) && sizeof(d) != sizeof(char *))
350 static size_t push_string_check_fn(void *dest, const char *src, size_t dest_len) {
351 return 0;
352 }
353
354 #define push_string_check(dest, src, dest_len) \
355 (CHECK_STRING_SIZE(dest, dest_len) \
356 ? __unsafe_string_function_usage_here_size_t__() \
357 : push_string_check_fn(dest, src, dest_len))
358
359 int main(int argc, char **argv) {
360 char outbuf[1024];
361 char *p = outbuf;
362 const char *foo = "bar";
363 p += 31 + push_string_check(p + 31, foo, sizeof(outbuf) - (p + 31 - outbuf));
364 return 0;
365 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
366 addmain=False,
367 add_headers=False,
368 msg="Checking if the compiler will optimize out functions")
369
370 # Check if the compiler supports the LL suffix on long long integers
371 # AIX needs this
372 conf.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
373 headers='stdio.h',
374 msg="Checking for LL suffix on long long integers")
375
376 conf.CHECK_FUNCS('''
377 DNSServiceRegister
378 atexit
379 chflags
380 fchflags
381 chmod
382 crypt16
383 devnm
384 endmntent
385 execl
386 fchmod
387 fchown
388 fseeko
389 fsync
390 futimens
391 getauthuid
392 getcwd
393 getgrent
394 getgrnam
395 getgrouplist
396 getgrset
397 getmntent
398 getpagesize
399 getpwanam
400 getpwent_r
401 getrlimit
402 glob
403 grantpt
404 hstrerror
405 initgroups
406 innetgr
407 llseek
408 lutimes
409 memalign
410 mknod
411 mlock
412 mlockall
413 munlock
414 munlockall
415 pathconf poll
416 posix_memalign
417 pread
418 pwrite
419 rdchk
420 select
421 setenv
422 setgidx
423 setgroups
424 setlocale
425 setluid
426 setmntent
427 setpgid
428 setpriv
429 setsid
430 setuidx
431 statvfs
432 strcasecmp
433 strchr
434 strpbrk
435 strsignal
436 strtol
437 strupr
438 sysconf
439 sysctl
440 sysctlbyname
441 syslog
442 timegm
443 utimensat
444 vsyslog
445 ''')
446
447 conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
448
449 # FIXME: these should be tests for features, but the old build system just
450 # checks for OSes.
451 host_os = sys.platform
452 Logs.info("building on %s" % host_os)
453
454 # Python doesn't have case switches... :/
455 # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
456 # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
457
458 conf.SET_TARGET_TYPE('sunacl', 'EMPTY')
459 if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('qnx') > -1):
460 if host_os.rfind('linux') > -1:
461 conf.DEFINE('LINUX', '1')
462 elif host_os.rfind('qnx') > -1:
463 conf.DEFINE('QNX', '1')
464 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
465 elif (host_os.rfind('darwin') > -1):
466 conf.DEFINE('DARWINOS', 1)
467 conf.ADD_CFLAGS('-fno-common')
468 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
469 elif (host_os.rfind('freebsd') > -1):
470 conf.DEFINE('FREEBSD', 1)
471 if conf.CHECK_HEADERS('sunacl.h'):
472 conf.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
473 conf.CHECK_FUNCS_IN(['acl'], 'sunacl')
474 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
475 elif (host_os.rfind('openbsd') > -1):
476 conf.DEFINE('OPENBSD', 1)
477 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
478 elif (host_os.rfind('irix') > -1):
479 conf.DEFINE('IRIX', 1)
480 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
481 elif (host_os.rfind('aix') > -1):
482 conf.DEFINE('AIX', 1)
483 conf.DEFINE('STAT_ST_BLOCKSIZE', 'DEV_BSIZE')
484 elif (host_os.rfind('hpux') > -1):
485 conf.DEFINE('HPUX', 1)
486 conf.DEFINE('STAT_ST_BLOCKSIZE', '8192')
487 elif (host_os.rfind('osf') > -1):
488 conf.DEFINE('OSF1', 1)
489 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
490
491 # FIXME: Add more checks here.
492 else:
493 conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
494
495 if Options.options.with_acl_support:
496 if (host_os.rfind('hpux') > -1):
497 Logs.info('Using HPUX ACLs')
498 conf.DEFINE('HAVE_HPUX_ACLS',1)
499 conf.DEFINE('POSIX_ACL_NEEDS_MASK',1)
500 required_static_modules.extend(['vfs_hpuxacl'])
501 elif (host_os.rfind('aix') > -1):
502 Logs.info('Using AIX ACLs')
503 conf.DEFINE('HAVE_AIX_ACLS',1)
504 required_static_modules.extend(['vfs_aixacl', 'vfs_aixacl2'])
505 elif (host_os.rfind('darwin') > -1):
506 Logs.warn('ACLs on Darwin currently not supported')
507 conf.fatal("ACL support not available on Darwin/MacOS. "
508 "Use --without-acl-support for building without "
509 "ACL support. "
510 "ACL support is required to change permissions "
511 "from Windows clients.")
512 else:
513 conf.CHECK_FUNCS_IN(['acl_get_file'], 'acl')
514 if conf.CHECK_CODE('''
515 acl_t acl;
516 int entry_id;
517 acl_entry_t *entry_p;
518 return acl_get_entry(acl, entry_id, entry_p);
519 ''',
520 'HAVE_POSIX_ACLS',
521 headers='sys/types.h sys/acl.h', link=False,
522 msg="Checking for POSIX ACL support") :
523 conf.CHECK_CODE('''
524 acl_permset_t permset_d;
525 acl_perm_t perm;
526 return acl_get_perm_np(permset_d, perm);
527 ''',
528 'HAVE_ACL_GET_PERM_NP',
529 headers='sys/types.h sys/acl.h', link=True,
530 msg="Checking whether acl_get_perm_np() is available")
531 # source3/lib/sysacls.c calls posixacl_sys_acl_get_file()
532 required_static_modules.extend(['vfs_posixacl'])
533 conf.CHECK_VARIABLE('ACL_EVERYONE', headers='sys/acl.h')
534 elif conf.CHECK_FUNCS_IN(['facl'], 'sec'):
535 Logs.info('Using solaris or UnixWare ACLs')
536 conf.DEFINE('HAVE_SOLARIS_UNIXWARE_ACLS',1)
537 required_static_modules.extend(['vfs_solarisacl'])
538 else:
539 conf.fatal("ACL support not found. Try installing libacl1-dev "
540 "or libacl-devel. "
541 "Otherwise, use --without-acl-support to build "
542 "without ACL support. "
543 "ACL support is required to change permissions from "
544 "Windows clients.")
545
546 if conf.CHECK_FUNCS('dirfd'):
547 conf.DEFINE('HAVE_DIRFD_DECL', 1)
548
549 conf.CHECK_CODE('struct statfs fsd; int r = fstatfs(AT_FDCWD, &fsd);',
550 'HAVE_FSTATFS',
551 msg='Checking for fstatfs',
552 headers='sys/statfs.h fcntl.h')
553 conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
554 'HAVE_STATFS_F_FSID',
555 msg="vfs_fileid checking for statfs() and struct statfs.f_fsid",
556 headers='sys/types.h sys/statfs.h',
557 execute=True)
558
559 if conf.CONFIG_SET('HAVE_FALLOCATE'):
560 conf.CHECK_CODE('''
561 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
562 'HAVE_LINUX_FALLOCATE',
563 msg="Checking whether the Linux 'fallocate' function is available",
564 headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
565 conf.CHECK_CODE('''
566 int ret = fallocate(0, FALLOC_FL_PUNCH_HOLE, 0, 10);''',
567 'HAVE_FALLOC_FL_PUNCH_HOLE',
568 msg="Checking whether Linux 'fallocate' supports hole-punching",
569 headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
570
571 conf.CHECK_CODE('''
572 int ret = lseek(0, 0, SEEK_HOLE);
573 ret = lseek(0, 0, SEEK_DATA);''',
574 'HAVE_LSEEK_HOLE_DATA',
575 msg="Checking whether lseek supports hole/data seeking",
576 headers='unistd.h sys/types.h')
577
578 conf.CHECK_CODE('''
579 ssize_t err = readahead(0,0,0x80000);''',
580 'HAVE_LINUX_READAHEAD',
581 msg="Checking whether Linux readahead is available",
582 headers='unistd.h fcntl.h')
583 conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
584
585 conf.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
586 'HAVE_OPENAT',
587 msg='Checking for openat',
588 headers='fcntl.h')
589
590 conf.CHECK_CODE('''
591 struct msghdr msg;
592 union {
593 struct cmsghdr cm;
594 char control[CMSG_SPACE(sizeof(int))];
595 } control_un;
596 msg.msg_control = control_un.control;
597 msg.msg_controllen = sizeof(control_un.control);
598 ''',
599 'HAVE_STRUCT_MSGHDR_MSG_CONTROL',
600 msg='Checking if we can use msg_control for passing file descriptors',
601 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
602 conf.CHECK_CODE('''
603 struct msghdr msg;
604 int fd;
605 msg.msg_accrights = (caddr_t) &fd;
606 msg.msg_accrightslen = sizeof(fd);
607 ''',
608 'HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS',
609 msg='Checking if we can use msg_accrights for passing file descriptors',
610 headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
611
612 if Options.options.with_winbind:
613 conf.env.build_winbind = True
614 conf.DEFINE('WITH_WINBIND', '1')
615
616 if Options.options.with_varlink or Options.options.with_systemd_userdb:
617 conf.CHECK_CFG(package='libvarlink', args='"libvarlink >= 24" --cflags --libs',
618 msg='Checking for libvarlink >= 24', mandatory=True)
619 if (conf.CHECK_HEADERS('varlink.h', lib='varlink') and
620 conf.CHECK_LIB('varlink', shlib=True) and
621 conf.CHECK_FUNCS_IN('varlink_service_new', 'varlink', headers='varlink.h')):
622 conf.env.with_varlink = True
623 else:
624 conf.fatal("libvarlink not found.")
625 if Options.options.with_systemd_userdb:
626 conf.env.with_systemd_userdb = True
627 conf.DEFINE('WITH_SYSTEMD_USERDB', '1')
628
629
630 conf.find_program('awk', var='AWK')
631
632 conf.CHECK_HEADERS('asm/types.h')
633
634 conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
635 headers='sys/sysmacros.h unistd.h sys/types.h',
636 msg="Checking for major macro")
637
638 conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
639 headers='sys/sysmacros.h unistd.h sys/types.h',
640 msg="Checking for minor macro")
641
642 conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
643 headers='unistd.h sys/types.h dirent.h',
644 define='HAVE_DIRENT_D_OFF')
645
646 if (conf.CONFIG_SET('HAVE_GETDOMAINNAME')):
647 conf.DEFINE('HAVE_NETGROUP', '1')
648
649 # Look for CUPS
650 if Options.options.with_cups:
651 conf.find_program('cups-config', var='CUPS_CONFIG')
652 if conf.env.CUPS_CONFIG:
653 # we would normally use --libs here, but cups-config incorrectly adds
654 # gssapi_krb5 and other libraries to its --libs output. That breaks the use
655 # of an in-tree heimdal kerberos
656 conf.CHECK_CFG(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
657 package="", uselib_store="CUPS")
658 conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
659 conf.CHECK_FUNCS_IN('httpConnect httpConnect2 httpConnectEncrypt', 'cups')
660 if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
661 conf.DEFINE('HAVE_CUPS', '1')
662 else:
663 conf.undefine('HAVE_CUPS')
664 conf.SET_TARGET_TYPE('cups', 'EMPTY')
665 else:
666 # define an empty subsystem for cups, to allow it to be used as an empty dependency
667 conf.SET_TARGET_TYPE('cups', 'EMPTY')
668
669 if Options.options.with_iprint:
670 if conf.CONFIG_SET('HAVE_CUPS'):
671 conf.DEFINE('HAVE_IPRINT', '1')
672 else:
673 Logs.warn("--enable-iprint=yes but cups support not sufficient")
674 if Options.options.with_syslog:
675 conf.DEFINE('WITH_SYSLOG', '1')
676 if Options.options.with_automount:
677 conf.DEFINE('WITH_AUTOMOUNT', '1')
678
679 if Options.options.with_ads == False:
680 use_ads = False
681 use_ads_krb5 = False
682 use_ads_ldap = False
683 else:
684 use_ads = True
685 use_ads_krb5 = True
686 use_ads_ldap = True
687 if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
688 not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
689 Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
690 use_ads_krb5 = False
691 if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
692 Logs.warn("krb5_mk_req_extended not found in -lkrb5")
693 use_ads_krb5 = False
694 if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
695 Logs.warn("krb5_get_host_realm not found in -lkrb5")
696 use_ads_krb5 = False
697 if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
698 Logs.warn("krb5_free_host_realm not found in -lkrb5")
699 use_ads_krb5 = False
700 if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
701 Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
702 use_ads_krb5 = False
703 if not conf.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
704 Logs.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
705 use_ads_krb5 = False
706 if not conf.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
707 Logs.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
708 use_ads_krb5 = False
709 if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
710 Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
711 use_ads_krb5 = False
712 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
713 Logs.warn("krb5_principal_compare_any_realm not found in -lkrb5")
714 use_ads_krb5 = False
715 if not conf.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
716 not conf.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
717 Logs.warn("krb5_c_string_to_key not found in -lkrb5")
718 use_ads_krb5 = False
719 if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
720 not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
721 Logs.warn("no CREATE_KEY_FUNCTIONS detected")
722 use_ads_krb5 = False
723 if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
724 not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
725 Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
726 use_ads_krb5 = False
727 if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
728 not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
729 Logs.warn("no KT_FREE_FUNCTION detected")
730 use_ads_krb5 = False
731 if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
732 Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
733 use_ads_krb5 = False
734
735 # We don't actually use
736 # gsskrb5_extract_authz_data_from_sec_context, but it is a
737 # clue that this Heimdal, which does the PAC processing we
738 # need on the standard gss_inquire_sec_context_by_oid
739 if not conf.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
740 not (conf.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
741 conf.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
742 Logs.warn("need either gss_get_name_attribute or gsskrb5_extract_authz_data_from_sec_context and gss_inquire_sec_context_by_oid in -lgssapi for PAC support")
743 use_ads_krb5 = False
744
745 if not conf.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
746 Logs.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
747 use_ads_krb5 = False
748
749 if use_ads_krb5:
750 conf.DEFINE('HAVE_KRB5', '1')
751 conf.env['HAVE_KRB5'] = '1'
752 else:
753 conf.undefine('HAVE_KRB5_H')
754 conf.undefine('HAVE_GSSAPI_H')
755 conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
756 conf.undefine('HAVE_GSSAPI_GSSAPI_H')
757 use_ads = False
758
759 if not conf.CONFIG_SET('HAVE_LDAP_TRANSPORT_WRAPPING'):
760 Logs.warn("need ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF for SASL and TLS support")
761 use_ads = False
762 use_ads_ldap = False
763
764 if use_ads:
765 conf.DEFINE('HAVE_ADS', '1')
766 Logs.info("Building with Active Directory support.")
767 # these have broken dependencies
768 forced_shared_modules.extend(['idmap_ad', 'idmap_rfc2307'])
769 elif Options.options.with_ads == False:
770 Logs.info("Building without Active Directory support (--without-ads).")
771 if not Options.options.without_ad_dc:
772 conf.fatal("Building --without-ads requires also "
773 "building --without-ad-dc.")
774 else:
775 if not use_ads_krb5:
776 Logs.warn("Active Directory support not available: krb5 libs don't have all required features")
777 if not use_ads_ldap:
778 Logs.warn("Active Directory support not available: LDAP support is not available.")
779 if Options.options.with_ads:
780 conf.fatal("Active Directory support not found. Use --without-ads "
781 "for building without Active Directory support. "
782 "ADS support improves communication with "
783 "Active Directory domain controllers.")
784 else:
785 # this is the auto-mode case
786 Logs.warn("Building without Active Directory support.")
787
788
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')
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 utmpx', 'ut_syslen', headers='utmpx.h',
812 define='HAVE_UX_UT_SYSLEN')
813 conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_host', headers='utmpx.h',
814 define='HAVE_UX_UT_HOST')
815 conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
816 'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
817 msg="Checking whether pututline returns pointer")
818 conf.CHECK_SIZEOF(['((struct utmp *)NULL)->ut_line'], headers='utmp.h',
819 define='SIZEOF_UTMP_UT_LINE', critical=False)
820 if not conf.CONFIG_SET('SIZEOF_UTMP_UT_LINE'):
821 conf.env.with_utmp = False
822 elif int(conf.env.SIZEOF_UTMP_UT_LINE) < 15:
823 conf.env.with_utmp = False
824 if conf.env.with_utmp:
825 conf.DEFINE('WITH_UTMP', 1)
826 else:
827 Logs.warn("--with-utmp but utmp support not sufficient")
828
829 if Options.options.with_avahi:
830 conf.env.with_avahi = True
831 if not conf.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf.env.with_avahi = False
832 if not conf.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf.env.with_avahi = False
833 if not conf.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf.env.with_avahi = False
834 if conf.env.with_avahi:
835 conf.DEFINE('WITH_AVAHI_SUPPORT', 1)
836 else:
837 conf.SET_TARGET_TYPE('avahi-common', 'EMPTY')
838 conf.SET_TARGET_TYPE('avahi-client', 'EMPTY')
839
840 if Options.options.with_iconv:
841 conf.env.with_iconv = True
842 if not conf.CHECK_FUNCS_IN('iconv_open', 'iconv', headers='iconv.h'):
843 conf.env.with_iconv = False
844 if conf.env.with_iconv:
845 conf.DEFINE('HAVE_ICONV', 1)
846
847 if Options.options.with_pam:
848 use_pam=True
849 conf.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
850 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
851 Logs.warn("--with-pam=yes but pam_appl.h not found")
852 use_pam=False
853 conf.CHECK_FUNCS_IN('pam_get_data', 'pam')
854 conf.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
855 if not conf.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
856 Logs.warn("--with-pam=yes but pam_modules.h not found")
857 use_pam=False
858 conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
859 conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
860 conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
861 conf.CHECK_CODE('''
862 #if defined(HAVE_SECURITY_PAM_APPL_H)
863 #include <security/pam_appl.h>
864 #elif defined(HAVE_PAM_PAM_APPL_H)
865 #include <pam/pam_appl.h>
866 #endif
867 pam_set_item(0, PAM_RHOST, 0);
868 ''',
869 'HAVE_PAM_RHOST',
870 lib='pam',
871 msg="Checking whether PAM_RHOST is available");
872 conf.CHECK_CODE('''
873 #if defined(HAVE_SECURITY_PAM_APPL_H)
874 #include <security/pam_appl.h>
875 #elif defined(HAVE_PAM_PAM_APPL_H)
876 #include <pam/pam_appl.h>
877 #endif
878 pam_set_item(0, PAM_TTY, 0);
879 ''',
880 'HAVE_PAM_TTY',
881 lib='pam',
882 msg="Checking whether PAM_TTY is available");
883 conf.CHECK_CODE('''
884 #if (!defined(LINUX))
885
886 #define PAM_EXTERN extern
887 #if defined(HAVE_SECURITY_PAM_APPL_H)
888 #include <security/pam_appl.h>
889 #elif defined(HAVE_PAM_PAM_APPL_H)
890 #include <pam/pam_appl.h>
891 #endif
892
893 #endif
894
895 #if defined(HAVE_SECURITY_PAM_MODULES_H)
896 #include <security/pam_modules.h>
897 #elif defined(HAVE_PAM_PAM_MODULES_H)
898 #include <pam/pam_modules.h>
899 #endif
900
901 #if defined(HAVE_SECURITY__PAM_MACROS_H)
902 #include <security/_pam_macros.h>
903 #elif defined(HAVE_PAM__PAM_MACROS_H)
904 #include <pam/_pam_macros.h>
905 #endif
906
907 #ifdef HAVE_SECURITY_PAM_EXT_H
908 #include <security/pam_ext.h>
909 #endif
910
911 int i; i = PAM_RADIO_TYPE;
912 ''',
913 'HAVE_PAM_RADIO_TYPE',
914 lib='pam',
915 msg="Checking whether PAM_RADIO_TYPE is available");
916 if use_pam:
917 conf.DEFINE('WITH_PAM', 1)
918 conf.DEFINE('WITH_PAM_MODULES', 1)
919 else:
920 conf.fatal("PAM support is enabled but prerequisite libraries "
921 "or headers not found. Use --without-pam to disable "
922 "PAM support.");
923
924 seteuid = False
925
926 #
927 # Ensure we select the correct set of system calls on Linux.
928 #
929 if (host_os.rfind('linux') > -1):
930 conf.CHECK_CODE('''
931 #if defined(HAVE_UNISTD_H)
932 #include <unistd.h>
933 #endif
934 #include <stdlib.h>
935 #include <stdio.h>
936 #include <sys/types.h>
937 #include <errno.h>
938
939 #ifdef HAVE_SYS_PRIV_H
940 #include <sys/priv.h>
941 #endif
942 #ifdef HAVE_SYS_ID_H
943 #include <sys/id.h>
944 #endif
945
946 #if defined(HAVE_SYSCALL_H)
947 #include <syscall.h>
948 #endif
949
950 #if defined(HAVE_SYS_SYSCALL_H)
951 #include <sys/syscall.h>
952 #endif
953
954 syscall(SYS_setresuid32, -1, -1, -1);
955 syscall(SYS_setresgid32, -1, -1, -1);
956 syscall(SYS_setreuid32, -1, -1);
957 syscall(SYS_setregid32, -1, -1);
958 syscall(SYS_setuid32, -1);
959 syscall(SYS_setgid32, -1);
960 syscall(SYS_setgroups32, 0, NULL);
961 ''',
962 'USE_LINUX_32BIT_SYSCALLS',
963 msg="Checking whether Linux should use 32-bit credential calls");
964
965 if (conf.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
966 seteuid = conf.CHECK_CODE('''
967 #define AUTOCONF_TEST 1
968 #define HAVE_LINUX_THREAD_CREDENTIALS 1
969 #define USE_LINUX_32BIT_SYSCALLS 1
970 #include "../lib/util/setid.c"
971 #include "./lib/util_sec.c"
972 ''',
973 'HAVE_LINUX_THREAD_CREDENTIALS',
974 addmain=False,
975 execute=True,
976 msg="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
977 else:
978 seteuid = conf.CHECK_CODE('''
979 #define AUTOCONF_TEST 1
980 #define HAVE_LINUX_THREAD_CREDENTIALS 1
981 #include "../lib/util/setid.c"
982 #include "./lib/util_sec.c"
983 ''',
984 'HAVE_LINUX_THREAD_CREDENTIALS',
985 addmain=False,
986 execute=True,
987 msg="Checking whether we can use Linux thread-specific credentials")
988 if not seteuid:
989 seteuid = conf.CHECK_CODE('''
990 #define AUTOCONF_TEST 1
991 #define USE_SETREUID 1
992 #include "../lib/util/setid.c"
993 #include "./lib/util_sec.c"
994 ''',
995 'USE_SETREUID',
996 addmain=False,
997 execute=True,
998 msg="Checking whether setreuid is available")
999 if not seteuid:
1000 seteuid = conf.CHECK_CODE('''
1001 #define AUTOCONF_TEST 1
1002 #define USE_SETRESUID 1
1003 #include "../lib/util/setid.c"
1004 #include "./lib/util_sec.c"
1005 ''',
1006 'USE_SETRESUID',
1007 addmain=False,
1008 execute=True,
1009 msg="Checking whether setresuid is available")
1010 if not seteuid:
1011 seteuid = conf.CHECK_CODE('''
1012 #define AUTOCONF_TEST 1
1013 #define USE_SETEUID 1
1014 #include "../lib/util/setid.c"
1015 #include "./lib/util_sec.c"
1016 ''',
1017 'USE_SETEUID',
1018 addmain=False,
1019 execute=True,
1020 msg="Checking whether seteuid is available")
1021 if not seteuid:
1022 seteuid = conf.CHECK_CODE('''
1023 #define AUTOCONF_TEST 1
1024 #define USE_SETUIDX 1
1025 #include "../lib/util/setid.c"
1026 #include "./lib/util_sec.c"
1027 ''',
1028 'USE_SETUIDX',
1029 addmain=False,
1030 execute=True,
1031 mandatory=True,
1032 msg="Checking whether setuidx is available")
1033 # valgrind.h or valgrind/valgrind.h is checked in lib/replace/wscript
1034 if Options.options.developer:
1035 if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
1036 conf.DEFINE('VALGRIND', '1')
1037
1038 if conf.CHECK_CODE('''
1039 #include <bits/sockaddr.h>
1040 #include <linux/netlink.h>
1041 ''',
1042 'HAVE_LINUX_NETLINK_H',
1043 msg="Checking whether Linux netlink is available"):
1044
1045 conf.CHECK_CODE('''
1046 #include <bits/sockaddr.h>
1047 #include <linux/netlink.h>
1048 #include <linux/rtnetlink.h>
1049 ''',
1050 'HAVE_LINUX_RTNETLINK_H',
1051 msg='Checking whether Linux rtnetlink is available')
1052
1053 conf.CHECK_CODE('''
1054 #include "../tests/fcntl_lock.c"
1055 ''',
1056 'HAVE_FCNTL_LOCK',
1057 addmain=False,
1058 execute=True,
1059 msg='Checking whether fcntl locking is available')
1060
1061 conf.CHECK_CODE('''
1062 #include <unistd.h>
1063 #include <sys/types.h>
1064 #include <sys/stat.h>
1065 #include <fcntl.h>
1066 #include <errno.h>
1067
1068 #define DATA "ofdtest.fcntl"
1069
1070 int main(void) {
1071 struct flock lck = {
1072 .l_whence = SEEK_SET,
1073 .l_type = F_WRLCK,
1074 .l_start = 0,
1075 .l_len = 1,
1076 .l_pid = 0,
1077 };
1078 int ret;
1079 int fd1;
1080 int fd2;
1081 char *testdir = getenv("TESTDIR");
1082
1083 if (testdir) {
1084 if (chdir(testdir) != 0) {
1085 goto err;
1086 }
1087 }
1088
1089 unlink(DATA);
1090 fd1 = open(DATA, O_RDWR|O_CREAT|O_EXCL, 0600);
1091 fd2 = open(DATA, O_RDWR);
1092 if (fd1 == -1 || fd2 == -1) {
1093 goto err;
1094 }
1095 ret = fcntl(fd1,F_OFD_SETLKW,&lck);
1096 if (ret == -1) {
1097 goto err;
1098 }
1099 ret = fcntl(fd2,F_OFD_SETLK,&lck);
1100 if (ret != -1) {
1101 goto err;
1102 }
1103 if (errno != EAGAIN) {
1104 goto err;
1105 }
1106 ret = fcntl(fd2,F_OFD_GETLK,&lck);
1107 if (ret == -1) {
1108 goto err;
1109 }
1110 unlink(DATA);
1111 exit(0);
1112 err:
1113 unlink(DATA);
1114 exit(1);
1115 }''',
1116 'HAVE_OFD_LOCKS',
1117 addmain=False,
1118 execute=True,
1119 msg="Checking whether fcntl lock supports open file description locks")
1120
1121 conf.CHECK_CODE('''
1122 #include <fcntl.h>
1123 #include <unistd.h>
1124 #include <stdlib.h>
1125 #include <sys/socket.h>
1126
1127 int main(void)
1128 {
1129 int sockfd, ret;
1130 struct f_owner_ex owner, get_owner;
1131
1132 sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
1133 if (sockfd == -1) {
1134 goto err;
1135 }
1136
1137 owner.type = F_OWNER_PID;
1138 owner.pid = getpid();
1139
1140 ret = fcntl(sockfd, F_SETOWN_EX, &owner);
1141 if (ret == -1) {
1142 goto err;
1143 }
1144
1145 ret = fcntl(sockfd, F_GETOWN_EX, &get_owner);
1146 if (ret == -1) {
1147 goto err;
1148 }
1149
1150 if (get_owner.type != F_OWNER_PID) {
1151 goto err;
1152 }
1153
1154 if (get_owner.pid != getpid()) {
1155 goto err;
1156 }
1157
1158 close(sockfd);
1159 exit(0);
1160 err:
1161 close(sockfd);
1162 exit(1);
1163 }''',
1164 'HAVE_F_OWNER_EX',
1165 addmain=False,
1166 execute=True,
1167 msg="Checking whether fcntl supports flags to send direct I/O availability signals")
1168
1169 conf.CHECK_CODE('''
1170 #include <fcntl.h>
1171 #include <unistd.h>
1172 #include <stdlib.h>
1173 #include <stdint.h>
1174
1175 #define DATA "hinttest.fcntl"
1176
1177 int main(void)
1178 {
1179 uint64_t hint, get_hint;
1180 int fd;
1181
1182 fd = open(DATA, O_RDONLY | O_CREAT | O_EXCL);
1183 if (fd == -1) {
1184 goto err;
1185 }
1186
1187 hint = RWH_WRITE_LIFE_SHORT;
1188 int ret = fcntl(fd, F_SET_RW_HINT, &hint);
1189 if (ret == -1) {
1190 goto err;
1191 }
1192
1193 ret = fcntl(fd, F_GET_RW_HINT, &get_hint);
1194 if (ret == -1) {
1195 goto err;
1196 }
1197
1198 if (get_hint != RWH_WRITE_LIFE_SHORT) {
1199 goto err;
1200 }
1201
1202 hint = RWH_WRITE_LIFE_EXTREME;
1203 ret = fcntl(fd, F_SET_FILE_RW_HINT, &hint);
1204 if (ret == -1) {
1205 goto err;
1206 }
1207
1208 ret = fcntl(fd, F_GET_FILE_RW_HINT, &get_hint);
1209 if (ret == -1) {
1210 goto err;
1211 }
1212
1213 if (get_hint != RWH_WRITE_LIFE_EXTREME) {
1214 goto err;
1215 }
1216
1217 close(fd);
1218 unlink(DATA);
1219 exit(0);
1220 err:
1221 close(fd);
1222 unlink(DATA);
1223 exit(1);
1224 }''',
1225 'HAVE_RW_HINTS',
1226 addmain=False,
1227 execute=True,
1228 msg="Checking whether fcntl supports setting/getting hints")
1229
1230 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1231 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1232 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1233 define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1234 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1235 define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1236 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1237 define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1238 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1239 define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1240 if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1241 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1242 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1243 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1244 conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1245 conf.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1246
1247 # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1248 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1249 define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1250 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1251 define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1252 conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1253 define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1254
1255 conf.CHECK_CODE('''
1256 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1257 ''',
1258 'HAVE_POSIX_FADVISE',
1259 msg='Checking whether posix_fadvise is available',
1260 headers='unistd.h fcntl.h')
1261
1262 for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1263 conf.CHECK_CODE('''
1264 #include <unistd.h>
1265 return sysconf(%s) == -1 ? 1 : 0;
1266 ''' % v,
1267 'SYSCONF%s' % v,
1268 msg='Checking whether sysconf(%s) is available' % v)
1269
1270 conf.CHECK_CODE('''
1271 #include <sys/syscall.h>
1272 #include <unistd.h>
1273 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1274 ''',
1275 'HAVE_DARWIN_INITGROUPS',
1276 msg='Checking whether to use the Darwin-specific initgroups system call')
1277
1278 conf.CHECK_CODE('''struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1279 'HAVE_UTIMBUF',
1280 headers='sys/types.h utime.h',
1281 msg='Checking whether struct utimbuf is available')
1282
1283 if conf.CHECK_CODE('''struct sigevent s;''',
1284 'HAVE_STRUCT_SIGEVENT',
1285 headers='sys/types.h stdlib.h stddef.h signal.h',
1286 msg='Checking whether we have the struct sigevent'):
1287 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1288 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1289 headers='signal.h');
1290 conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1291 define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1292 headers='signal.h');
1293
1294 if os.path.exists('/proc/sys/kernel/core_pattern'):
1295 conf.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
1296
1297 if conf.CHECK_CODE('''
1298 #include <time.h>
1299 int main(void) {
1300 struct tm *tm;
1301 if (sizeof(time_t) == 8) {
1302 time_t max_time = 0x7fffffffffffffffll;
1303 tm = gmtime(&max_time);
1304 /* This should fail with 32-bit tm_year. */
1305 if (tm == NULL) {
1306 /* Max time_t that works with 32-bit int tm_year in struct tm. */
1307 max_time = 67768036191676799ll;
1308 tm = gmtime(&max_time);
1309 if (tm) {
1310 exit(0);
1311 }
1312 }
1313 }
1314 exit(1);
1315 }''',
1316 '__TIME_T_MAX',
1317 addmain=False,
1318 execute=True,
1319 msg="Checking for the maximum value of the 'time_t' type"):
1320 conf.DEFINE('TIME_T_MAX', '67768036191676799ll')
1321
1322 conf.CHECK_CODE('''
1323 #if defined(HAVE_UNISTD_H)
1324 #include <unistd.h>
1325 #endif
1326 #include <sys/types.h>
1327 #if defined(HAVE_SYS_SYSMACROS_H)
1328 #include <sys/sysmacros.h>
1329 #endif
1330 int main(void) { dev_t dev = makedev(1,2); return 0; }
1331 ''',
1332 'HAVE_MAKEDEV',
1333 addmain=False,
1334 msg='Checking whether the macro for makedev is available')
1335
1336 conf.CHECK_CODE('''
1337 #include <stdio.h>
1338 #include <limits.h>
1339 #include <signal.h>
1340 #include <stdlib.h>
1341
1342 void exit_on_core(int ignored) {
1343 exit(1);
1344 }
1345
1346 int main(void) {
1347 char *newpath;
1348 signal(SIGSEGV, exit_on_core);
1349 newpath = realpath("/tmp", NULL);
1350 exit((newpath != NULL) ? 0 : 1);
1351 }
1352 ''',
1353 'REALPATH_TAKES_NULL',
1354 addmain=False,
1355 execute=True,
1356 msg='Checking whether the realpath function allows a NULL argument')
1357
1358 conf.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1359 'HAVE_FTRUNCATE_EXTEND',
1360 msg='Checking for ftruncate extend',
1361 addmain=False,
1362 execute=True)
1363
1364 conf.CHECK_CODE('''#include "../tests/readlink.c"''',
1365 'HAVE_BROKEN_READLINK',
1366 msg='Checking for readlink breakage',
1367 addmain=False,
1368 execute=True)
1369
1370 conf.SET_TARGET_TYPE('sendfile', 'EMPTY')
1371 conf.CHECK_LIB('sendfile')
1372 if not Options.options.with_sendfile_support == False:
1373 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):
1374 conf.CHECK_CODE('''
1375 int tofd, fromfd;
1376 off_t offset;
1377 size_t total;
1378 ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1379 ''',
1380 '_HAVE_SENDFILE',
1381 headers='sys/sendfile.h',
1382 msg='Checking for linux sendfile support')
1383
1384 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1385 conf.DEFINE('HAVE_SENDFILE', '1')
1386 conf.DEFINE('LINUX_SENDFILE_API', '1')
1387 elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
1388 conf.CHECK_CODE('''
1389 #include <sys/types.h>
1390 #include <unistd.h>
1391 #include <sys/socket.h>
1392 #include <sys/uio.h>
1393 int fromfd, tofd, ret, total=0;
1394 off_t offset, nwritten;
1395 struct sf_hdtr hdr;
1396 struct iovec hdtrl;
1397 hdr.headers = &hdtrl;
1398 hdr.hdr_cnt = 1;
1399 hdr.trailers = NULL;
1400 hdr.trl_cnt = 0;
1401 hdtrl.iov_base = NULL;
1402 hdtrl.iov_len = 0;
1403 ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1404 ''',
1405 '_HAVE_SENDFILE',
1406 msg='Checking for freebsd sendfile support')
1407 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1408 conf.DEFINE('HAVE_SENDFILE', '1')
1409 conf.DEFINE('FREEBSD_SENDFILE_API', '1')
1410 elif (host_os.rfind('darwin') > -1):
1411 conf.CHECK_CODE('''
1412 #include <sys/types.h>
1413 #include <sys/socket.h>
1414 #include <sys/uio.h>
1415 int fromfd, tofd, ret;
1416 off_t offset, nwritten;
1417 struct sf_hdtr hdr;
1418 struct iovec hdtrl;
1419 hdr.headers = &hdtrl;
1420 hdr.hdr_cnt = 1;
1421 hdr.trailers = (void *)0;
1422 hdr.trl_cnt = 0;
1423 hdtrl.iov_base = (void *)0;
1424 hdtrl.iov_len = 0;
1425 ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1426 ''',
1427 '_HAVE_SENDFILE',
1428 msg='Checking for darwin sendfile support')
1429 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1430 conf.DEFINE('HAVE_SENDFILE', '1')
1431 conf.DEFINE('DARWIN_SENDFILE_API', '1')
1432 elif (host_os.rfind('hpux') > -1) or (host_os.rfind('osf') > -1):
1433 conf.CHECK_CODE('''
1434 #include <sys/socket.h>
1435 #include <sys/uio.h>
1436 int fromfd, tofd;
1437 size_t total=0;
1438 struct iovec hdtrl[2];
1439 ssize_t nwritten;
1440 off_t offset;
1441 hdtrl[0].iov_base = 0;
1442 hdtrl[0].iov_len = 0;
1443 nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1444 ''',
1445 '_HAVE_SENDFILE',
1446 msg='Checking for osf/hpux sendfile support')
1447 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1448 conf.DEFINE('HAVE_SENDFILE', '1')
1449 conf.DEFINE('HPUX_SENDFILE_API', '1')
1450 elif (host_os.rfind('sunos') > -1):
1451 conf.CHECK_FUNCS_IN('sendfilev', 'sendfile')
1452 conf.CHECK_CODE('''
1453 #include <sys/sendfile.h>,
1454 int sfvcnt;
1455 size_t xferred;
1456 struct sendfilevec vec[2];
1457 ssize_t nwritten;
1458 int tofd;
1459 sfvcnt = 2;
1460 vec[0].sfv_fd = SFV_FD_SELF;
1461 vec[0].sfv_flag = 0;
1462 vec[0].sfv_off = 0;
1463 vec[0].sfv_len = 0;
1464 vec[1].sfv_fd = 0;
1465 vec[1].sfv_flag = 0;
1466 vec[1].sfv_off = 0;
1467 vec[1].sfv_len = 0;
1468 nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1469 ''',
1470 '_HAVE_SENDFILEV',
1471 msg='Checking for solaris sendfilev support',
1472 lib='sendfile')
1473 if conf.CONFIG_SET('_HAVE_SENDFILEV'):
1474 conf.DEFINE('HAVE_SENDFILEV', '1')
1475 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1476 elif (host_os.rfind('aix') > -1):
1477 conf.CHECK_CODE('''
1478 #include <sys/socket.h>
1479 int fromfd, tofd;
1480 size_t total=0;
1481 struct sf_parms hdtrl;
1482 ssize_t nwritten;
1483 hdtrl.header_data = 0;
1484 hdtrl.header_length = 0;
1485 hdtrl.file_descriptor = fromfd;
1486 hdtrl.file_offset = 0;
1487 hdtrl.file_bytes = 0;
1488 hdtrl.trailer_data = 0;
1489 hdtrl.trailer_length = 0;
1490 nwritten = send_file(&tofd, &hdtrl, 0);
1491 ''',
1492 '_HAVE_SENDFILE',
1493 msg='Checking for AIX send_file support')
1494 if conf.CONFIG_SET('_HAVE_SENDFILE'):
1495 conf.DEFINE('HAVE_SENDFILE', '1')
1496 conf.DEFINE('AIX_SENDFILE_API', '1')
1497
1498 if Options.options.with_sendfile_support == True and not conf.CONFIG_SET('HAVE_SENDFILE'):
1499 conf.fatal('sendfile support not found but it was requested !')
1500 # Check for getcwd allowing a NULL arg.
1501 conf.CHECK_CODE('''
1502 #include <unistd.h>
1503 int main(void) {
1504 char *s = getcwd(NULL,0);
1505 return s != NULL ? 0 : 1;
1506 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
1507 msg="getcwd takes a NULL argument")
1508
1509
1510 # UnixWare 7.x has its getspnam in -lgen
1511 conf.CHECK_FUNCS_IN('getspnam', 'gen')
1512 conf.CHECK_FUNCS_IN('getspnam', 'security')
1513 conf.CHECK_FUNCS_IN('getspnam', 'sec')
1514
1515 legacy_quota_libs = ''
1516 if not Options.options.with_quotas == False:
1517 # For quotas on Veritas VxFS filesystems
1518 conf.CHECK_HEADERS('sys/fs/vx_quota.h')
1519 # For sys/quota.h and linux/quota.h
1520 conf.CHECK_HEADERS('sys/quota.h')
1521 # For quotas on BSD systems
1522 conf.CHECK_HEADERS('ufs/ufs/quota.h')
1523 # For quotas on AIX systems
1524 conf.CHECK_HEADERS('jfs/quota.h')
1525 # For quotas on Linux XFS filesystems
1526 if conf.CHECK_HEADERS('xfs/xqm.h'):
1527 conf.DEFINE('HAVE_XFS_QUOTAS', '1')
1528 else:
1529 # For Irix XFS
1530 conf.CHECK_CODE('''
1531 #include "confdefs.h"
1532 #ifdef HAVE_SYS_TYPES_H
1533 #include <sys/types.h>
1534 #endif
1535 #ifdef HAVE_ASM_TYPES_H
1536 #include <asm/types.h>
1537 #endif
1538 #include <sys/quota.h>
1539 int i = Q_XGETQUOTA;''',
1540 define='HAVE_XFS_QUOTAS',
1541 msg='for XFS QUOTA in <sys/quota.h>',
1542 execute=False,
1543 local_include=False)
1544
1545 # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struct dqblk
1546 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define='HAVE_DQB_FSOFTLIMIT',
1547 headers='sys/quota.h')
1548 #darwin style quota bytecount
1549 conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_curbytes', define='HAVE_STRUCT_DQBLK_DQB_CURBYTES',
1550 headers='sys/quota.h')
1551 conf.CHECK_HEADERS('rpc/types.h rpc/xdr.h', together=True)
1552 if conf.CHECK_HEADERS('rpcsvc/rquota.h', lib='tirpc'):
1553 # Optional structure member
1554 conf.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1555 define='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1556 headers='rpcsvc/rquota.h',
1557 lib='tirpc')
1558
1559 # Required function for NFS quota support
1560 conf.CHECK_CODE('''
1561 clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
1562 ''',
1563 headers="rpc/rpc.h rpc/types.h rpcsvc/rquota.h rpc/nettype.h rpc/xdr.h",
1564 define='HAVE_NFS_QUOTAS',
1565 msg='checking for clnt_create()',
1566 execute=True,
1567 local_include=False,
1568 lib='tirpc')
1569
1570 if (host_os.rfind('linux') > -1):
1571 conf.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1572 elif not conf.CONFIG_SET("HAVE_XFS_QUOTAS"):
1573 if not conf.CHECK_CODE('''
1574 #define HAVE_QUOTACTL_4A 1
1575 #define AUTOCONF_TEST 1
1576 #include "../tests/sysquotas.c"
1577 ''',
1578 cflags=conf.env['WERROR_CFLAGS'],
1579 define='HAVE_QUOTACTL_4A',
1580 msg='for QUOTACTL_4A: long quotactl(int cmd, char *special, qid_t id, caddr_t addr)',
1581 execute=True,
1582 addmain=False):
1583
1584 conf.CHECK_CODE('''
1585 #define HAVE_QUOTACTL_4B 1
1586 #define AUTOCONF_TEST 1
1587 #include "../tests/sysquotas.c"
1588 ''',
1589 cflags=conf.env['WERROR_CFLAGS'],
1590 define='HAVE_QUOTACTL_4B',
1591 msg='for QUOTACTL_4B: int quotactl(const char *path, int cmd, int id, char *addr)',
1592 execute=True,
1593 addmain=False)
1594
1595 if conf.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1596 conf.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1597 conf.CONFIG_SET('HAVE_QUOTACTL_4B') or \
1598 conf.CONFIG_SET('HAVE_XFS_QUOTAS'):
1599 conf.DEFINE('HAVE_SYS_QUOTAS', '1')
1600 conf.DEFINE('WITH_QUOTAS', '1')
1601
1602 #
1603 # check if Legacy quota code can be brought in
1604 # if standard interfaces are not supported
1605 #
1606 if not conf.CONFIG_SET('WITH_QUOTAS'):
1607 if host_os.rfind('sunos5') > -1:
1608 conf.DEFINE('SUNOS5', '1')
1609 legacy_quota_libs = 'nsl'
1610 conf.CHECK_CODE('''
1611 #define WITH_QUOTAS 1
1612 #define AUTOCONF_TEST 1
1613 #include "../tests/oldquotas.c"
1614 ''',
1615 cflags=conf.env['WERROR_CFLAGS'],
1616 define='WITH_QUOTAS',
1617 lib=legacy_quota_libs,
1618 msg='Checking whether legacy quota code can be used',
1619 execute=False,
1620 addmain=False)
1621 if not conf.CONFIG_SET('WITH_QUOTAS'):
1622 legacy_quota_libs = ''
1623 conf.env['legacy_quota_libs'] = legacy_quota_libs
1624
1625 if Options.options.with_quotas == True and not conf.CONFIG_SET('WITH_QUOTAS'):
1626 conf.fatal('quota support not found but it was requested !')
1627
1628 conf.CHECK_CODE('(void)unshare(CLONE_FS);',
1629 headers='sched.h',
1630 define='HAVE_UNSHARE_CLONE_FS',
1631 msg='for Linux unshare(CLONE_FS)')
1632
1633 #
1634 # cluster support (CTDB)
1635 #
1636 if not Options.options.with_cluster_support:
1637 Logs.info("building without cluster support (--without-cluster-support)")
1638 conf.env.with_ctdb = False
1639 else:
1640 Logs.info("building with cluster support")
1641 conf.env.with_ctdb = True
1642 conf.DEFINE('CLUSTER_SUPPORT', 1)
1643
1644 if Options.options.with_profiling_data:
1645 conf.DEFINE('WITH_PROFILE', 1);
1646 conf.CHECK_FUNCS('getrusage', headers="sys/time.h sys/resource.h")
1647
1648 if (conf.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
1649 conf.CHECK_DECLS('FS_IOC_GETFLAGS FS_COMPR_FL', headers='linux/fs.h')):
1650 conf.DEFINE('HAVE_LINUX_IOCTL', '1')
1651
1652 conf.env['CFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64"
1653
1654 if (Options.options.with_cephfs is not False and
1655 conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and
1656 conf.CHECK_LIB('cephfs', shlib=True)):
1657 if (Options.options.with_acl_support and
1658 conf.CHECK_FUNCS_IN('ceph_statx ceph_openat', 'cephfs',
1659 headers='cephfs/libcephfs.h')):
1660 conf.DEFINE('HAVE_CEPH', '1')
1661
1662 if (conf.CHECK_FUNCS_IN('ceph_ll_nonblocking_readv_writev', 'cephfs',
1663 headers='cephfs/libcephfs.h')):
1664 conf.DEFINE('HAVE_CEPH_ASYNCIO', '1')
1665
1666 ceph_fscrypt = conf.CHECK_FUNCS_IN(
1667 'ceph_ll_set_fscrypt_policy_v2',
1668 'cephfs',
1669 headers='cephfs/libcephfs.h',
1670 )
1671 fscrypt = conf.CHECK_HEADERS('linux/fscrypt.h')
1672 if conf.env.with_varlink and ceph_fscrypt and fscrypt:
1673 conf.DEFINE('HAVE_CEPH_FSCRYPT', '1')
1674
1675 if conf.CONFIG_SET('HAVE_CEPH'):
1676 Logs.info("building ceph vfs modules")
1677 else:
1678 if Options.options.with_cephfs == False:
1679 Logs.info("not building ceph vfs modules(--disable-cephfs)")
1680 elif Options.options.with_cephfs == True:
1681 Logs.error("acl support disabled or ceph_statx/ceph_openat not "
1682 "available, cannot build ceph vfs modules")
1683 conf.fatal("acl support disabled or ceph_statx/ceph_openat not "
1684 "available, but --enable-cephfs was specified")
1685 else:
1686 Logs.warn("acl support disabled or ceph_statx/ceph_openat not "
1687 "available, not building ceph vfs modules")
1688
1689 if Options.options.with_glusterfs:
1690 conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs',
1691 msg='Checking for glusterfs-api >= 4', uselib_store="GFAPI")
1692 conf.CHECK_HEADERS('glusterfs/api/glfs.h', lib='gfapi')
1693 conf.CHECK_LIB('gfapi', shlib=True)
1694
1695 if conf.CONFIG_SET('HAVE_GLUSTERFS_API_GLFS_H'):
1696 if Options.options.with_acl_support:
1697 conf.DEFINE('HAVE_GLUSTERFS', '1')
1698 else:
1699 Logs.warn("GlusterFS support disabled due to --without-acl-support")
1700 conf.undefine('HAVE_GLUSTERFS')
1701 else:
1702 conf.undefine('HAVE_GLUSTERFS')
1703
1704 conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 6" --cflags --libs',
1705 msg='Checking for glusterfs-api >= 6',
1706 uselib_store="GFAPI_VER_6")
1707 conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 7.6" --cflags --libs',
1708 msg='Checking for glusterfs-api >= 7.6',
1709 uselib_store="GFAPI_VER_7_6")
1710 conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 7.9" --cflags --libs',
1711 msg='Checking for glusterfs-api >= 7.9',
1712 uselib_store="GFAPI_VER_7_9")
1713 conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 7.11" --cflags --libs',
1714 msg='Checking for glusterfs-api >= 7.11',
1715 uselib_store="GFAPI_VER_7_11")
1716
1717 else:
1718 conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
1719 conf.undefine('HAVE_GLUSTERFS')
1720
1721 if Options.options.enable_vxfs:
1722 conf.DEFINE('HAVE_VXFS', '1')
1723
1724 if conf.CHECK_CFG(package='liburing', args='--cflags --libs',
1725 msg='Checking for liburing package', uselib_store="URING"):
1726 if (conf.CHECK_HEADERS('liburing.h', lib='uring')
1727 and conf.CHECK_LIB('uring', shlib=True)):
1728 conf.CHECK_FUNCS_IN('io_uring_ring_dontfork io_uring_prep_writev2', 'uring',
1729 headers='liburing.h')
1730 # There are a few distributions, which
1731 # don't seem to have linux/openat2.h available
1732 # during the liburing build, which means liburing/compat.h
1733 # defines struct open_how directly instead of including
1734 # linux/openat2.h, while linux/openat2.h is
1735 # available on the installed system, which cause problems
1736 # when we try to include both files.
1737 #
1738 # check if struct open_how is defined in liburing/compat.h
1739 # itself and not via including linux/openat2.h
1740 conf.CHECK_TYPE_IN('struct open_how', 'liburing/compat.h',
1741 cflags='-D_LINUX_OPENAT2_H',
1742 define='HAVE_STRUCT_OPEN_HOW_LIBURING_COMPAT_H')
1743 conf.DEFINE('HAVE_LIBURING', '1')
1744
1745 conf.env.build_regedit = False
1746 if not Options.options.with_regedit == False:
1747 conf.PROCESS_SEPARATE_RULE('system_ncurses')
1748 if conf.CONFIG_SET('HAVE_NCURSES'):
1749 conf.env.build_regedit = True
1750
1751 if conf.env.build_regedit:
1752 Logs.info("building regedit")
1753 else:
1754 if Options.options.with_regedit == False:
1755 Logs.info("not building regedit (--without-regedit)")
1756 elif Options.options.with_regedit == True:
1757 Logs.error("ncurses not available, cannot build regedit")
1758 conf.fatal("ncurses not available, but --with-regedit was specified")
1759 else:
1760 Logs.info("ncurses not available, not building regedit")
1761
1762 if conf.CHECK_HEADERS('ftw.h') and conf.CHECK_FUNCS('nftw'):
1763 conf.env.build_mvxattr = True
1764
1765 conf.env.build_winexe = False
1766 if not Options.options.with_winexe == False:
1767 if conf.CONFIG_SET('HAVE_WINEXE_CC_WIN32') or conf.CONFIG_SET('HAVE_WINEXE_CC_WIN64'):
1768 conf.env.build_winexe = True
1769
1770 if conf.env.build_winexe:
1771 Logs.info("building winexe")
1772 else:
1773 if Options.options.with_winexe == False:
1774 Logs.info("not building winexe (--without-winexe)")
1775 elif Options.options.with_winexe == True:
1776 Logs.error("mingw not available, cannot build winexe")
1777 conf.fatal("mingw not available, but --with-winexe was specified")
1778 else:
1779 Logs.info("mingw not available, not building winexe")
1780
1781 conf.CHECK_FUNCS_IN('DES_pcbc_encrypt', 'crypto')
1782 if Options.options.with_fake_kaserver == True:
1783 conf.CHECK_HEADERS('afs/param.h afs/stds.h', together=True)
1784 conf.CHECK_HEADERS('afs/param.h afs/stds.h', together=True)
1785 if (conf.CONFIG_SET('HAVE_AFS_PARAM_H') and conf.CONFIG_SET('HAVE_AFS_STDS_H') and conf.CONFIG_SET('HAVE_DES_PCBC_ENCRYPT')):
1786 conf.DEFINE('WITH_FAKE_KASERVER', '1')
1787 else:
1788 conf.fatal('AFS headers not available, but --with-fake-kaserver was specified')
1789
1790 with_spotlight_es_backend = (
1791 conf.CONFIG_SET('HAVE_JSON_OBJECT')
1792 and conf.env['BISON']
1793 and conf.env['FLEX']
1794 and conf.CONFIG_GET('HAVE_UTF8_NORMALISATION')
1795 )
1796
1797 conf.env.with_wsp = False
1798 if conf.CONFIG_GET('ENABLE_SELFTEST'):
1799 Options.options.with_wsp = True
1800 if Options.options.with_wsp:
1801 Logs.info("building with WSP support")
1802 conf.DEFINE('WITH_WSP', '1')
1803 conf.env.with_wsp = True
1804
1805 conf.env.with_spotlight = False
1806 if Options.options.with_spotlight is not False:
1807 backends = ['noindex']
1808
1809 if not conf.env['BISON']:
1810 Logs.warn("Spotlight support requested but bison missing")
1811 if not conf.env['FLEX']:
1812 Logs.warn("Spotlight support requested but flex missing")
1813 if not conf.CONFIG_GET('HAVE_UTF8_NORMALISATION'):
1814 Logs.warn("Missing support for Unicode normalisation. "
1815 "Try installing icu-dev or libicu-devel.")
1816 if not conf.CONFIG_GET('HAVE_JSON_OBJECT'):
1817 Logs.warn('Missing libjansson development files for Spotlight backend "elasticsearch"')
1818
1819 if with_spotlight_es_backend:
1820 conf.env.spotlight_backend_es = True
1821 backends.append('elasticsearch')
1822 conf.DEFINE('HAVE_SPOTLIGHT_BACKEND_ES', '1')
1823
1824 if (Options.options.with_spotlight is True
1825 and not conf.env.spotlight_backend_es):
1826 conf.fatal("Unmet dependencies for Spotlight backends")
1827
1828 Logs.info("Building with Spotlight support, available backends: %s" % ', '.join(backends))
1829 conf.DEFINE('WITH_SPOTLIGHT', '1')
1830 conf.env.with_spotlight = True
1831
1832 if not conf.CONFIG_SET('HAVE_RPC_XDR_H'):
1833 conf.CHECK_HEADERS('rpc/types.h rpc/xdr.h', together=True, lib='tirpc')
1834
1835 if conf.CHECK_FUNCS_IN('nscd_flush_cache', 'nscd', headers='libnscd.h'):
1836 conf.DEFINE('HAVE_NSCD_FLUSH_CACHE', '1')
1837
1838 forced_static_modules.extend(['auth_builtin', 'auth_sam', 'auth_winbind'])
1839 default_static_modules.extend(['pdb_smbpasswd', 'pdb_tdbsam',
1840 'auth_unix',
1841 'nss_info_template', 'idmap_tdb', 'idmap_passdb',
1842 'idmap_nss'])
1843
1844 default_shared_modules.extend(['vfs_recycle', 'vfs_audit', 'vfs_extd_audit', 'vfs_full_audit',
1845 'vfs_fake_perms', 'vfs_default_quota', 'vfs_readonly', 'vfs_cap',
1846 'vfs_expand_msdfs', 'vfs_shadow_copy', 'vfs_shadow_copy2',
1847 'vfs_readahead', 'vfs_xattr_tdb',
1848 'vfs_streams_xattr', 'vfs_streams_depot', 'vfs_acl_xattr', 'vfs_acl_tdb',
1849 'vfs_preopen', 'vfs_catia',
1850 'vfs_media_harmony', 'vfs_unityed_media', 'vfs_fruit', 'vfs_shell_snap',
1851 'vfs_commit', 'vfs_worm', 'vfs_crossrename', 'vfs_linux_xfs_sgid',
1852 'vfs_time_audit', 'vfs_offline', 'vfs_virusfilter', 'vfs_widelinks',
1853 'vfs_aio_ratelimit'])
1854 if host_os.rfind('linux') > -1:
1855 default_shared_modules.extend(['vfs_snapper'])
1856
1857 default_shared_modules.extend(['idmap_tdb2', 'idmap_script'])
1858 # these have broken dependencies
1859 forced_shared_modules.extend(['idmap_autorid', 'idmap_rid', 'idmap_hash'])
1860
1861 if Options.options.developer:
1862 default_static_modules.extend(['charset_weird'])
1863 default_shared_modules.extend(['vfs_skel_opaque',
1864 'vfs_skel_transparent',
1865 'vfs_shadow_copy_test',
1866 'pdb_test',
1867 'vfs_fake_dfq',
1868 'gpext_security', 'gpext_registry', 'gpext_scripts'])
1869
1870 if Options.options.enable_selftest or Options.options.developer:
1871 default_shared_modules.extend(['vfs_fake_acls', 'vfs_nfs4acl_xattr',
1872 'vfs_error_inject',
1873 'vfs_delay_inject'])
1874
1875 if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1876 default_static_modules.extend(['pdb_samba_dsdb', 'auth_samba4', 'vfs_dfs_samba4'])
1877 default_shared_modules.extend(['vfs_posix_eadb'])
1878
1879 if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1880 default_shared_modules.extend(['vfs_zfsacl'])
1881
1882 if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
1883 default_shared_modules.extend(['vfs_syncops', 'vfs_dirsort'])
1884
1885 if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
1886 default_shared_modules.extend(['vfs_fileid'])
1887
1888 if (conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS')):
1889 default_shared_modules.extend(['vfs_aio_fork'])
1890
1891 if conf.CONFIG_SET('HAVE_LIBURING'):
1892 default_shared_modules.extend(['vfs_io_uring'])
1893
1894 if Options.options.with_pthreadpool:
1895 default_shared_modules.extend(['vfs_aio_pthread'])
1896
1897 if conf.CONFIG_SET('HAVE_LDAP'):
1898 default_static_modules.extend(['pdb_ldapsam', 'idmap_ldap'])
1899
1900 if conf.CONFIG_SET('DARWINOS'):
1901 default_static_modules.extend(['charset_macosxfs'])
1902
1903 if conf.CONFIG_SET('HAVE_GPFS') and conf.CONFIG_SET('HAVE_KERNEL_OPLOCKS_LINUX'):
1904 default_shared_modules.extend(['vfs_gpfs'])
1905
1906 if (conf.CONFIG_SET('HAVE_LINUX_IOCTL')
1907 and conf.CONFIG_SET('HAVE_BASENAME') and conf.CONFIG_SET('HAVE_DIRNAME')):
1908 default_shared_modules.extend(['vfs_btrfs'])
1909
1910 if conf.CONFIG_SET("HAVE_CEPH"):
1911 default_shared_modules.extend(['vfs_ceph'])
1912 # Unlike vfs_ceph, vfs_ceph_snapshots doesn't depend on libcephfs, so
1913 # can be enabled atop a kernel CephFS share (with vfs_default) in
1914 # addition to vfs_ceph. Still, only enable vfs_ceph_snapshots builds
1915 # if we're building with libcephfs for now.
1916 default_shared_modules.extend(['vfs_ceph_snapshots'])
1917 default_shared_modules.extend(['vfs_ceph_new'])
1918
1919 if conf.CONFIG_SET('HAVE_GLUSTERFS'):
1920 default_shared_modules.extend(['vfs_glusterfs'])
1921
1922 if conf.CONFIG_SET('HAVE_SETMNTENT'):
1923 default_shared_modules.extend(['vfs_glusterfs_fuse'])
1924
1925 if conf.CONFIG_SET('HAVE_VXFS'):
1926 default_shared_modules.extend(['vfs_vxfs'])
1927
1928 explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
1929 explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
1930
1931 def replace_list_item(lst, item, value):
1932 try:
1933 idx = lst.index(item)
1934 lst[idx] = value
1935 except:
1936 pass
1937 # PDB module file name should have the same name as module registers itself
1938 # In Autoconf build we export LDAP passdb module as ldapsam but WAF build
1939 # was always exporting pdb_ldap. In order to support existing packages
1940 # allow referring to pdb_ldapsam as pdb_ldap but use proper name internally.
1941 replace_list_item(explicit_shared_modules, 'pdb_ldap', 'pdb_ldapsam')
1942 replace_list_item(explicit_static_modules, 'pdb_ldap', 'pdb_ldapsam')
1943
1944 final_static_modules = []
1945 final_static_modules.extend(TO_LIST(required_static_modules))
1946 final_shared_modules = []
1947
1948 if '!FORCED' not in explicit_static_modules:
1949 final_static_modules.extend(TO_LIST(forced_static_modules))
1950 if '!FORCED' not in explicit_shared_modules:
1951 final_shared_modules.extend(TO_LIST(forced_shared_modules))
1952 if '!DEFAULT' not in explicit_static_modules:
1953 final_static_modules.extend(TO_LIST(default_static_modules))
1954 if '!DEFAULT' not in explicit_shared_modules:
1955 final_shared_modules.extend(TO_LIST(default_shared_modules))
1956
1957 if 'ALL' in explicit_static_modules:
1958 for m in default_shared_modules:
1959 if m in final_shared_modules:
1960 final_shared_modules.remove(m)
1961 final_static_modules.append(m)
1962 if 'ALL' in explicit_shared_modules:
1963 for m in default_static_modules:
1964 if m in final_static_modules:
1965 final_static_modules.remove(m)
1966 final_shared_modules.append(m)
1967
1968 for m in explicit_static_modules:
1969 if m in ['ALL','!DEFAULT','!FORCED']:
1970 continue
1971 if m.startswith('!'):
1972 m = m[1:]
1973 if m in required_static_modules:
1974 raise Errors.WafError('These modules are REQUIRED as static modules: %s' %
1975 ' '.join(required_static_modules))
1976 if m in final_static_modules:
1977 final_static_modules.remove(m)
1978 continue
1979 if m in forced_shared_modules:
1980 raise Errors.WafError('These modules MUST be configured as shared modules: %s' %
1981 ' '.join(forced_shared_modules))
1982 if m in final_shared_modules:
1983 final_shared_modules.remove(m)
1984 if m not in final_static_modules:
1985 final_static_modules.append(m)
1986 for m in explicit_shared_modules:
1987 if m in ['ALL','!DEFAULT','!FORCED']:
1988 continue
1989 if m.startswith('!'):
1990 m = m[1:]
1991 if m in final_shared_modules:
1992 final_shared_modules.remove(m)
1993 continue
1994 if m in required_static_modules:
1995 raise Errors.WafError('These modules are REQUIRED as static modules: %s' %
1996 ' '.join(required_static_modules))
1997 if m in forced_static_modules:
1998 raise Errors.WafError('These module MUST be configured as static modules: %s' %
1999 ' '.join(forced_static_modules))
2000 if m in final_static_modules:
2001 final_static_modules.remove(m)
2002 if m not in final_shared_modules:
2003 final_shared_modules.append(m)
2004
2005 conf.env['static_modules'] = final_static_modules
2006 conf.env['shared_modules'] = final_shared_modules
2007
2008 conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
2009 conf.DEFINE('STRING_SHARED_MODULES', ' '.join(final_shared_modules), quote=True)
2010
2011 static_list = {}
2012 shared_list = {}
2013
2014 prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext']
2015 conf.env['MODULE_PREFIXES'] = prefixes
2016 for p in prefixes:
2017 for m in final_static_modules:
2018 if m.find(p) == 0:
2019 if not p in static_list:
2020 static_list[p] = []
2021 static_list[p].append(m)
2022 for m in final_shared_modules:
2023 if m.find(p) == 0:
2024 if not p in shared_list:
2025 shared_list[p] = []
2026 shared_list[p].append(m)
2027
2028 for p in prefixes:
2029 static_env = "%s_STATIC" % p.upper()
2030 shared_env = "%s_SHARED" % p.upper()
2031 conf.env[static_env] = []
2032 conf.env[shared_env] = []
2033 if p in static_list:
2034 decl_list = " ".join("extern NTSTATUS %s_init(TALLOC_CTX *mem_ctx); " % entry for entry in static_list[p])
2035 for entry in static_list[p]:
2036 conf.env[static_env].append('%s' % entry)
2037 conf.DEFINE('static_decl_%s' % p, decl_list)
2038 conf.DEFINE('static_init_%s(mem_ctx)' % p, '{ %s_init((mem_ctx)); }' % '_init((mem_ctx)); '.join(static_list[p]))
2039 else:
2040 conf.DEFINE('static_decl_%s' % p, '')
2041 conf.DEFINE('static_init_%s(mem_ctx)' % p, '{}')
2042 if p in shared_list:
2043 for entry in shared_list[p]:
2044 conf.DEFINE('%s_init' % entry, 'samba_init_module')
2045 conf.env[shared_env].append('%s' % entry)
2046 Logs.info("%s: %s" % (static_env, ','.join(conf.env[static_env])))
2047 Logs.info("%s: %s" % (shared_env, ','.join(conf.env[shared_env])))
2048
2049 if (('vfs_snapper' in shared_list.get('vfs', []) or 'vfs_snapper' in static_list.get('vfs', []))
2050 and not (conf.CHECK_CFG(package='dbus-1', args='--cflags --libs',
2051 msg='Checking for dbus', uselib_store="DBUS-1")
2052 and conf.CHECK_HEADERS('dbus/dbus.h', lib='dbus-1')
2053 and conf.CHECK_LIB('dbus-1', shlib=True))):
2054 conf.fatal("vfs_snapper is enabled but prerequisite dbus-1 package not "
2055 "found. Use --with-shared-modules='!vfs_snapper' to disable "
2056 "vfs_snapper support.")
2057
2058 if not Options.options.disable_gettext:
2059 conf.load('gnu_dirs intltool')
2060
2061 conf.SAMBA_CONFIG_H('include/config.h')