build: rename HAVE_MSGHDR_MSG_ACCTRIGHTS to HAVE_STRUCT_MSGHDR_MSG_ACCTRIGHTS
[samba.git] / source3 / wscript
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 import wafsamba, Options, Logs, Utils, Scripting
10 import build.charset
11 import samba_utils, samba_version
12 import samba3
13
14 Options.default_prefix = '/usr/local/samba'
15
16 def set_options(opt):
17
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
25     opt.SAMBA3_ADD_OPTION('winbind')
26     opt.SAMBA3_ADD_OPTION('ads')
27     opt.SAMBA3_ADD_OPTION('ldap')
28     opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
29     opt.SAMBA3_ADD_OPTION('iprint', with_name="enable", without_name="disable")
30     opt.SAMBA3_ADD_OPTION('pam')
31     opt.SAMBA3_ADD_OPTION('pam_smbpass')
32     opt.SAMBA3_ADD_OPTION('quotas')
33     opt.SAMBA3_ADD_OPTION('sendfile-support')
34     opt.SAMBA3_ADD_OPTION('utmp')
35     opt.SAMBA3_ADD_OPTION('pthreadpool', with_name="enable", without_name="disable", default=True)
36     opt.SAMBA3_ADD_OPTION('avahi', with_name="enable", without_name="disable")
37     opt.SAMBA3_ADD_OPTION('iconv')
38     opt.SAMBA3_ADD_OPTION('acl-support')
39     opt.SAMBA3_ADD_OPTION('dnsupdate')
40     opt.SAMBA3_ADD_OPTION('syslog')
41     opt.SAMBA3_ADD_OPTION('automount')
42     opt.SAMBA3_ADD_OPTION('aio-support')
43     opt.SAMBA3_ADD_OPTION('dmapi', default=None) # None means autodetection
44     opt.SAMBA3_ADD_OPTION('fam', default=None) # None means autodetection
45     opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
46     opt.SAMBA3_ADD_OPTION('libarchive', default=None)
47
48     opt.SAMBA3_ADD_OPTION('cluster-support', default=None)
49
50     opt.SAMBA3_ADD_OPTION('regedit', default=None)
51
52     opt.add_option('--with-ctdb-dir',
53                    help=("Directory under which ctdb is installed"),
54                    action="store", dest='ctdb_dir', default=None)
55     opt.add_option('--enable-old-ctdb',
56                   help=("enable building against (too) old version of ctdb (default=false)"),
57                   action="store_true", dest='enable_old_ctdb', default=False)
58
59     opt.add_option('--with-libcephfs',
60                    help=("Directory under which libcephfs is installed"),
61                    action="store", dest='libcephfs_dir', default=None)
62
63     opt.SAMBA3_ADD_OPTION('glusterfs', with_name="enable", without_name="disable", default=True)
64
65
66 def configure(conf):
67     from samba_utils import TO_LIST
68
69     default_static_modules = []
70     default_shared_modules = []
71
72     if Options.options.developer:
73         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
74         conf.env.developer = True
75
76     if sys.platform != 'openbsd5':
77         conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
78
79     conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
80     conf.CHECK_HEADERS('linux/falloc.h')
81
82     conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
83     conf.CHECK_FUNCS('strtol strchr strupr chflags')
84     conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
85     conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
86     conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
87     conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
88     conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
89     conf.CHECK_FUNCS('atexit grantpt posix_openpt fallocate posix_fallocate')
90     conf.CHECK_FUNCS('fseeko setluid')
91     conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
92     conf.CHECK_FUNCS('fdopendir')
93     conf.CHECK_FUNCS('fstatat')
94     conf.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
95     conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
96     conf.CHECK_FUNCS_IN('nanosleep', 'rt')
97     conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
98     conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
99     conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
100     conf.CHECK_FUNCS('shmget')
101     conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
102     #FIXME: for some reason this one still fails
103     conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
104     conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
105     conf.CHECK_FUNCS_IN('dn_expand', 'inet')
106     conf.CHECK_DECLS('fdatasync', reverse=True)
107     conf.CHECK_DECLS('readahead', reverse=True, headers='fcntl.h')
108
109     if conf.CONFIG_SET('HAVE_LONG_LONG'):
110         conf.DEFINE('HAVE_LONGLONG', 1)
111
112     if conf.CHECK_CODE('''
113 #if defined(HAVE_UNISTD_H)
114 #include <unistd.h>
115 #endif
116 long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
117 ''',
118         'HAVE_LINUX_SPLICE',
119         headers='fcntl.h'):
120         conf.CHECK_DECLS('splice', reverse=True, headers='fcntl.h')
121
122     # Check for inotify support
123     conf.CHECK_HEADERS('sys/inotify.h')
124     if "HAVE_SYS_INOTIFY_H" in conf.env:
125         conf.DEFINE('HAVE_INOTIFY', 1)
126
127     # Check for kernel change notify support
128     conf.CHECK_CODE('''
129 #ifndef F_NOTIFY
130 #define F_NOTIFY 1026
131 #endif
132 main() {
133         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
134 }''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
135         headers='fcntl.h signal.h',
136         msg="Checking for kernel change notify support")
137
138     # Check for Linux kernel oplocks
139     conf.CHECK_CODE('''
140 #include <sys/types.h>
141 #include <fcntl.h>
142 #include <signal.h>
143 #ifndef F_NOTIFY
144 #define F_NOTIFY 1026
145 #endif
146 main() {
147         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
148 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
149         msg="Checking for Linux kernel oplocks")
150
151     # Check for IRIX kernel oplock types
152     conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
153                     'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
154                     msg="Checking for IRIX kernel oplock types")
155
156     # Check for kernel share modes
157     conf.CHECK_CODE('''
158 #include <sys/types.h>
159 #include <fcntl.h>
160 #include <signal.h>
161 #include <sys/file.h>
162 #ifndef LOCK_MAND
163 #define LOCK_MAND        32
164 #define LOCK_READ        64
165 #endif
166 main() {
167         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
168 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
169         msg="Checking for kernel share modes")
170
171     # check for fam libs
172     samba_fam_libs=None
173     check_for_fam=False
174     if Options.options.with_fam is None:
175         check_for_fam=True
176     elif Options.options.with_fam == True:
177         check_for_fam=True
178
179     if check_for_fam and conf.CHECK_HEADERS('fam.h'):
180         if conf.CHECK_FUNCS_IN('FAMOpen2', 'fam'):
181             samba_fam_libs='fam'
182         elif conf.CHECK_FUNCS_IN('FAMOpen2', 'fam C'):
183             samba_fam_libs='fam C'
184         conf.CHECK_TYPE('enum FAMCodes', headers='fam.h',
185             define='HAVE_FAM_H_FAMCODES_TYPEDEF',
186             msg='Checking whether enum FAMCodes is available')
187         conf.CHECK_FUNCS_IN('FAMNoExists', 'fam')
188
189     if samba_fam_libs is not None:
190         conf.DEFINE('SAMBA_FAM_LIBS', samba_fam_libs)
191     else:
192         if Options.options.with_fam == True:
193             conf.fatal('FAM support requested, but no suitable FAM library found')
194         elif check_for_fam:
195             Logs.warn('no suitable FAM library found')
196
197     # check for libarchive (tar command in smbclient)
198     # None means autodetect, True/False means enable/disable
199     conf.env['archive_lib'] = ''
200     if Options.options.with_libarchive is not False:
201         libarchive_mandatory = Options.options.with_libarchive == True
202         Logs.info("Checking for libarchive existence")
203         if conf.CHECK_BUNDLED_SYSTEM('libarchive', minversion='3.1.2'):
204             conf.env['archive_lib'] = 'libarchive'
205         elif libarchive_mandatory:
206             conf.fatal('libarchive support requested, but no suitable pkgconfig found')
207
208     # check for DMAPI libs
209     Logs.info("Checking for DMAPI library existence")
210     conf.env['dmapi_lib'] = ''
211     samba_dmapi_lib = ''
212     if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dm'):
213         samba_dmapi_lib = 'dm'
214     else:
215         if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'jfsdm'):
216             samba_dmapi_lib = 'jfsdm'
217         else:
218             if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dmapi'):
219                 samba_dmapi_lib = 'dmapi'
220             else:
221                 if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'xdsm'):
222                     samba_dmapi_lib = 'xdsm'
223     # only bother to test headers and compilation when a candidate
224     # library has been found
225     if Options.options.with_dmapi == True and samba_dmapi_lib == '':
226         conf.fatal('DMAPI support requested, but no suitable DMAPI library found')
227     else:
228         conf.CHECK_HEADERS('sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h dmapi.h')
229         conf.CHECK_CODE('''
230 #include <time.h>      /* needed by Tru64 */
231 #include <sys/types.h> /* needed by AIX */
232 #ifdef HAVE_XFS_DMAPI_H
233 #include <xfs/dmapi.h>
234 #elif defined(HAVE_SYS_DMI_H)
235 #include <sys/dmi.h>
236 #elif defined(HAVE_SYS_JFSDMAPI_H)
237 #include <sys/jfsdmapi.h>
238 #elif defined(HAVE_SYS_DMAPI_H)
239 #include <sys/dmapi.h>
240 #elif defined(HAVE_DMAPI_H)
241 #include <dmapi.h>
242 #endif
243
244 /* This link test is designed to fail on IRI 6.4, but should
245  * succeed on Linux, IRIX 6.5 and AIX.
246  */
247 int main(int argc, char **argv)
248 {
249         char * version;
250         dm_eventset_t events;
251         /* This doesn't take an argument on IRIX 6.4. */
252         dm_init_service(&version);
253         /* IRIX 6.4 expects events to be a pointer. */
254         DMEV_ISSET(DM_EVENT_READ, events);
255
256         return 0;
257 }
258 ''',
259         'USE_DMAPI',
260         addmain=False,
261         execute=False,
262         lib=samba_dmapi_lib,
263         msg='Checking whether DMAPI lib '+samba_dmapi_lib+' can be used')
264
265         if conf.CONFIG_SET('USE_DMAPI'):
266             conf.env['dmapi_lib'] = samba_dmapi_lib
267         else:
268             if Options.options.with_dmapi == True:
269                 conf.fatal('DMAPI support requested but not found');
270
271     # Check for various members of the stat structure
272     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
273                                 headers='sys/stat.h')
274     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
275                                 headers='sys/stat.h')
276     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define='HAVE_STAT_ST_FLAGS',
277                                 headers='sys/types.h sys/stat.h unistd.h')
278
279     if "HAVE_BLKCNT_T" in conf.env:
280         conf.CHECK_CODE('''
281         static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 4)];''',
282                 'SIZEOF_BLKCNT_T_4',
283                 headers='replace.h sys/types.h sys/stat.h unistd.h',
284                 msg="Checking whether blkcnt_t is 32 bit")
285
286     # If sizeof is 4 it can't be 8
287     if "HAVE_BLKCNT_T" in conf.env:
288         if not conf.CONFIG_SET('SIZEOF_BLKCNT_T_4'):
289             conf.CHECK_CODE('''
290             static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 8)];''',
291                     'SIZEOF_BLKCNT_T_8',
292                     headers='replace.h sys/types.h sys/stat.h unistd.h',
293                     msg="Checking whether blkcnt_t is 64 bit")
294
295     # Check for POSIX capability support
296     conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
297
298     if "HAVE_SYS_CAPABILITY_H" in conf.env:
299         conf.CHECK_CODE('''
300         cap_t cap;
301         cap_value_t vals[1];
302         if (!(cap = cap_get_proc())) exit(1);
303         vals[0] = CAP_CHOWN;
304         cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
305         cap_set_proc(cap);''',
306                         'HAVE_POSIX_CAPABILITIES', execute=True, lib="cap",
307                         headers='sys/capability.h',
308                         msg="Checking whether POSIX capabilities are available")
309
310     # Check for int16, uint16, int32 and uint32 in rpc/types.h included from
311     # rpc/rpc.h. This is *really* broken but some systems (DEC OSF1) do this.
312     # -- JRA.
313     if conf.CONFIG_SET("HAVE_RPC_RPC_H"):
314         conf.CHECK_TYPE('int16', headers='rpc/rpc.h',
315                         define='HAVE_INT16_FROM_RPC_RPC_H',
316                         msg="Checking for int16 typedef included by rpc/rpc.h")
317         conf.CHECK_CODE('uint16 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
318                         headers='sys/types.h rpc/rpc.h',
319                         msg="Checking for uint16 typedef included by rpc/rpc.h")
320         conf.CHECK_CODE('int32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
321                         headers='sys/types.h rpc/rpc.h',
322                         msg="Checking for int32 typedef included by rpc/rpc.h")
323         conf.CHECK_CODE('uint32 testvar;', 'HAVE_INT16_FROM_RPC_RPC_H',
324                         headers='sys/types.h rpc/rpc.h',
325                         msg="Checking for uint32 typedef included by rpc/rpc.h")
326     conf.CHECK_CODE('int i;', 'BROKEN_NISPLUS_INCLUDE_FILES',
327                     headers='sys/types.h sys/acl.h rpcsvc/nis.h',
328                     msg="Checking for broken nisplus include files")
329
330     # Check if the compiler will optimize out functions
331     conf.CHECK_CODE('''
332 if (0) {
333     this_function_does_not_exist();
334 } else {
335     return 1;
336 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
337         msg="Checking if the compiler will optimize out functions")
338
339     # Check if the compiler supports the LL suffix on long long integers
340     # AIX needs this
341     conf.CHECK_CODE('long long i = 0x8000000000LL', 'COMPILER_SUPPORTS_LL',
342                     headers='stdio.h',
343                     msg="Checking for LL suffix on long long integers")
344
345     conf.CHECK_FUNCS('''
346 _acl __acl atexit 
347  _chdir __chdir chflags chmod _close __close _closedir
348 __closedir crypt16 devnm dirfd
349 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
350 _facl __facl _fchdir
351 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
352 _fork __fork fseeko
353 fsetxattr _fstat __fstat fsync
354 futimens futimes __fxstat getauthuid
355 getcwd _getcwd __getcwd getdents __getdents getdirentries
356 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
357 getpwanam getpwent_r getrlimit
358 glob grantpt hstrerror initgroups innetgr
359 llseek _llseek __llseek _lseek __lseek
360 _lstat __lstat lutimes
361 __lxstat memalign mknod mlock mlockall munlock munlockall
362 _open __open _opendir __opendir
363 pathconf poll posix_fallocate
364 posix_memalign pread _pread __pread
365 pwrite _pwrite __pwrite
366 rdchk _read __read _readdir __readdir
367 _seekdir __seekdir
368 select setenv setgidx setgroups setlocale setluid
369 setmntent setpgid setpriv setsid setuidx
370 shmget shm_open sigaction sigblock sigprocmask sigset
371 _stat __stat statvfs
372 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
373 __sys_llseek syslog _telldir __telldir timegm
374 utimensat vsyslog _write __write __xstat
375 ''')
376
377     conf.CHECK_SAMBA3_CHARSET() # see build/charset.py
378
379     # FIXME: these should be tests for features, but the old build system just
380     # checks for OSes.
381     host_os = sys.platform
382     Logs.info("building on %s" % host_os)
383
384     # Python doesn't have case switches... :/
385     # FIXME: original was *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
386     # the search for .rfind('gnu') covers gnu* and *-gnu is that too broad?
387
388     conf.SET_TARGET_TYPE('sunacl', 'EMPTY')
389     if (host_os.rfind('linux') > -1) or (host_os.rfind('gnu') > -1) or (host_os.rfind('qnx') > -1):
390         if host_os.rfind('linux') > -1:
391             conf.DEFINE('LINUX', '1')
392         elif host_os.rfind('qnx') > -1:
393             conf.DEFINE('QNX', '1')
394         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
395     elif (host_os.rfind('darwin') > -1):
396         conf.DEFINE('DARWINOS', 1)
397         conf.ADD_CFLAGS('-fno-common')
398         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
399     elif (host_os.rfind('freebsd') > -1):
400         conf.DEFINE('FREEBSD', 1)
401         if conf.CHECK_HEADERS('sunacl.h'):
402             conf.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
403             conf.CHECK_FUNCS_IN(['acl'], 'sunacl')
404         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
405     elif (host_os.rfind('irix') > -1):
406         conf.DEFINE('IRIX', 1)
407         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
408     elif (host_os.rfind('aix') > -1):
409         conf.DEFINE('AIX', 1)
410         conf.DEFINE('STAT_ST_BLOCKSIZE', 'DEV_BSIZE')
411     elif (host_os.rfind('hpux') > -1):
412         conf.DEFINE('HPUX', 1)
413         conf.DEFINE('STAT_ST_BLOCKSIZE', '8192')
414     elif (host_os.rfind('osf') > -1):
415         conf.DEFINE('OSF1', 1)
416         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
417
418     # FIXME: Add more checks here.
419     else:
420         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
421
422     if Options.options.with_acl_support:
423         if (host_os.rfind('hpux') > -1):
424                 Logs.info('Using HPUX ACLs')
425                 conf.DEFINE('HAVE_HPUX_ACLS',1)
426                 conf.DEFINE('POSIX_ACL_NEEDS_MASK',1)
427                 default_static_modules.extend(TO_LIST('vfs_hpuxacl'))
428         elif (host_os.rfind('aix') > -1):
429                 Logs.info('Using AIX ACLs')
430                 conf.DEFINE('HAVE_AIX_ACLS',1)
431                 default_static_modules.extend(TO_LIST('vfs_aixacl vfs_aixacl2'))
432         elif (host_os.rfind('darwin') > -1):
433             Logs.warn('ACLs on Darwin currently not supported')
434             conf.fatal("ACL support not available on Darwin/MacOS. "
435                        "Use --without-acl-support for building without "
436                        "ACL support. "
437                        "ACL support is required to change permissions "
438                        "from Windows clients.")
439         else:
440             conf.CHECK_FUNCS_IN(['acl_get_file'], 'acl')
441             if conf.CHECK_CODE('''
442 acl_t acl;
443 int entry_id;
444 acl_entry_t *entry_p;
445 return acl_get_entry(acl, entry_id, entry_p);
446 ''',
447                         'HAVE_POSIX_ACLS',
448                         headers='sys/types.h sys/acl.h', link=False,
449                         msg="Checking for POSIX ACL support") :
450                 conf.CHECK_CODE('''
451 acl_permset_t permset_d;
452 acl_perm_t perm;
453 return acl_get_perm_np(permset_d, perm);
454 ''',
455                         'HAVE_ACL_GET_PERM_NP',
456                         headers='sys/types.h sys/acl.h', link=True,
457                         msg="Checking whether acl_get_perm_np() is available")
458                 default_static_modules.extend(TO_LIST('vfs_posixacl'))
459             elif conf.CHECK_FUNCS_IN(['facl'], 'sec'):
460                 Logs.info('Using solaris or UnixWare ACLs')
461                 conf.DEFINE('HAVE_SOLARIS_UNIXWARE_ACLS',1)
462                 default_static_modules.extend(TO_LIST('vfs_solarisacl'))
463             elif conf.CHECK_FUNCS_IN(['acl_get_fd'], 'pacl'):
464                 Logs.info('Using Tru64 ACLs')
465                 conf.DEFINE('HAVE_TRU64_ACLS',1)
466                 default_static_modules.extend(TO_LIST('vfs_tru64acl'))
467             else:
468                 conf.fatal("ACL support not found. Try installing libacl1-dev "
469                            "or libacl-devel.  "
470                            "Otherwise, use --without-acl-support to build "
471                            "without ACL support. "
472                            "ACL support is required to change permissions from "
473                            "Windows clients.")
474
475     if conf.CHECK_FUNCS('dirfd'):
476         conf.DEFINE('HAVE_DIRFD_DECL', 1)
477
478     conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
479                     'HAVE_STATFS_F_FSID',
480                     msg="vfs_fileid checking for statfs() and struct statfs.f_fsid",
481                     headers='sys/types.h sys/statfs.h',
482                     execute=True)
483
484     if conf.CONFIG_SET('HAVE_FALLOCATE'):
485         conf.CHECK_CODE('''
486                 int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
487                 'HAVE_LINUX_FALLOCATE',
488                 msg="Checking whether the Linux 'fallocate' function is available",
489                 headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
490     conf.CHECK_CODE('''
491                 ssize_t err = readahead(0,0,0x80000);''',
492                 'HAVE_LINUX_READAHEAD',
493                 msg="Checking whether Linux readahead is available",
494                 headers='unistd.h fcntl.h')
495     conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
496
497     conf.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
498                 'HAVE_OPENAT',
499                 msg='Checking for openat',
500                 headers='fcntl.h')
501
502     if Options.options.with_aio_support:
503         conf.CHECK_FUNCS_IN('aio_read', 'aio')
504         conf.CHECK_FUNCS_IN('aio_read', 'rt')
505         conf.CHECK_CODE('struct aiocb a; return aio_read(&a);',
506                         'HAVE_AIO',
507                         msg='Checking for asynchronous io support',
508                         headers='sys/types.h aio.h',
509                         lib='aio rt')
510         if conf.CONFIG_SET('HAVE_AIO'):
511             conf.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg='Checking for aio_read', headers='aio.h', lib='aio rt')
512             conf.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg='Checking for aio_write', headers='aio.h', lib='aio rt')
513             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')
514             conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
515             conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
516             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')
517             conf.CHECK_CODE('const struct aiocb * const a[1]; struct timespec t; return aio_suspend(&a, 1, &t);', 'HAVE_AIO_SUSPEND', msg='Checking for aio_suspend', headers='aio.h', lib='aio rt')
518         if not conf.CONFIG_SET('HAVE_AIO'):
519             conf.DEFINE('HAVE_NO_AIO', '1')
520     else:
521         conf.DEFINE('HAVE_NO_AIO', '1')
522
523     if host_os.rfind('linux') > -1:
524         conf.CHECK_FUNCS_IN('io_submit', 'aio')
525         conf.CHECK_CODE('''
526 struct io_event ioev;
527 struct iocb *ioc;
528 io_context_t ctx;
529 struct timespec ts;
530 int fd;
531 char *buf;
532 fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
533 io_queue_init(128,&ctx);
534 io_prep_pwrite(ioc, 1, buf, 1, 0);
535 io_prep_pread(ioc, 1, buf, 1, 0);
536 io_set_eventfd(ioc, fd);
537 io_set_callback(ioc, (io_callback_t)(0));
538 io_submit(ctx, 1, &ioc);
539 io_getevents(ctx, 1, 1, &ioev, &ts);
540 ''',
541                         'HAVE_LINUX_KERNEL_AIO',
542                         msg='Checking for linux kernel asynchronous io support',
543                         headers='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
544                         lib='aio')
545
546     conf.CHECK_CODE('''
547 struct msghdr msg;
548 union {
549         struct cmsghdr cm;
550         char control[CMSG_SPACE(sizeof(int))];
551 } control_un;
552 msg.msg_control = control_un.control;
553 msg.msg_controllen = sizeof(control_un.control);
554 ''',
555         'HAVE_STRUCT_MSGHDR_MSG_CONTROL',
556         msg='Checking if we can use msg_control for passing file descriptors',
557         headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
558     conf.CHECK_CODE('''
559 struct msghdr msg;
560 int fd;
561 msg.msg_acctrights = (caddr_t) &fd;
562 msg.msg_acctrightslen = sizeof(fd);
563 ''',
564         'HAVE_STRUCT_MSGHDR_MSG_ACCTRIGHTS',
565         msg='Checking if we can use msg_acctrights for passing file descriptors',
566         headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
567
568     if Options.options.with_winbind:
569         conf.env.build_winbind = True
570         conf.DEFINE('WITH_WINBIND', '1')
571
572     conf.find_program('awk', var='AWK')
573     conf.find_program('perl', var='PERL')
574
575     conf.CHECK_HEADERS('asm/types.h')
576
577     conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
578                     headers='unistd.h sys/types.h',
579                     msg="Checking for major macro")
580
581     conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
582                     headers='unistd.h sys/types.h',
583                     msg="Checking for minor macro")
584
585     conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
586                                 headers='unistd.h sys/types.h dirent.h',
587                                 define='HAVE_DIRENT_D_OFF')
588
589     conf.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
590     if conf.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
591         netgrent_cflags = '-Werror-implicit-function-declaration'
592     else:
593         netgrent_cflags = ''
594     conf.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
595                     msg="Checking for setnetgrent prototype",
596                     headers='netdb.h netgroup.h',
597                     cflags=netgrent_cflags)
598     conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
599                     msg="Checking for getnetgrent prototype",
600                     headers='netdb.h netgroup.h',
601                     cflags=netgrent_cflags)
602     conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
603                     msg="Checking for endnetgrent prototype",
604                     headers='netdb.h netgroup.h',
605                     cflags=netgrent_cflags)
606
607
608     # Look for CUPS
609     if Options.options.with_cups:
610         conf.find_program('cups-config', var='CUPS_CONFIG')
611         if conf.env.CUPS_CONFIG:
612             # we would normally use --libs here, but cups-config incorrectly adds
613             # gssapi_krb5 and other libraries to its --libs output. That breaks the use
614             # of an in-tree heimdal kerberos
615             conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
616                            package="", uselib_store="CUPS")
617         conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
618         conf.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
619         if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
620             conf.DEFINE('HAVE_CUPS', '1')
621         else:
622             conf.undefine('HAVE_CUPS')
623             conf.SET_TARGET_TYPE('cups', 'EMPTY')
624     else:
625         # define an empty subsystem for cups, to allow it to be used as an empty dependency
626         conf.SET_TARGET_TYPE('cups', 'EMPTY')
627
628     if Options.options.with_iprint:
629         if conf.CONFIG_SET('HAVE_CUPS'):
630             conf.DEFINE('HAVE_IPRINT', '1')
631         else:
632             Logs.warn("--enable-iprint=yes but cups support not sufficient")
633     if Options.options.with_syslog:
634         conf.DEFINE('WITH_SYSLOG', '1')
635     if Options.options.with_automount:
636         conf.DEFINE('WITH_AUTOMOUNT', '1')
637
638     # Check for LDAP
639     if Options.options.with_ldap:
640         conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
641         conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
642         conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
643         conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
644
645         # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
646         # for the samba logs
647         conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
648                             define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
649
650         conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
651         conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
652
653         # Check if ldap_set_rebind_proc() takes three arguments
654         if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
655                            'LDAP_SET_REBIND_PROC_ARGS',
656                            msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
657                            headers='ldap.h lber.h', link=False):
658             conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
659         else:
660             conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
661
662         # last but not least, if ldap_init() exists, we want to use ldap
663         if conf.CONFIG_SET('HAVE_LDAP_INIT') and conf.CONFIG_SET('HAVE_LDAP_H'):
664             conf.DEFINE('HAVE_LDAP', '1')
665             conf.DEFINE('LDAP_DEPRECATED', '1')
666             conf.env['HAVE_LDAP'] = '1'
667             # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
668             # SASL wrapping hooks
669             if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
670                     conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
671                 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
672         else:
673             conf.fatal("LDAP support not found. "
674                        "Try installing libldap2-dev or openldap-devel. "
675                        "Otherwise, use --without-ldap to build without "
676                        "LDAP support. "
677                        "LDAP support is required for the LDAP passdb backend, "
678                        "LDAP idmap backends and ADS. "
679                        "ADS support improves communication with "
680                        "Active Directory domain controllers.")
681     else:
682         conf.SET_TARGET_TYPE('ldap', 'EMPTY')
683         conf.SET_TARGET_TYPE('lber', 'EMPTY')
684
685     if Options.options.with_ads == False:
686         use_ads = False
687         use_ads_krb5 = False
688         use_ads_ldap = False
689     else:
690         use_ads = True
691         use_ads_krb5 = True
692         use_ads_ldap = True
693         if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
694            not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
695             Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
696             use_ads_krb5 = False
697         if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
698             Logs.warn("krb5_mk_req_extended not found in -lkrb5")
699             use_ads_krb5 = False
700         if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
701             Logs.warn("krb5_get_host_realm not found in -lkrb5")
702             use_ads_krb5 = False
703         if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
704             Logs.warn("krb5_free_host_realm not found in -lkrb5")
705             use_ads_krb5 = False
706         if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
707             Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
708             use_ads_krb5 = False
709         if not conf.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
710             Logs.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
711             use_ads_krb5 = False
712         if not conf.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
713             Logs.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
714             use_ads_krb5 = False
715         if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
716             Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
717             use_ads_krb5 = False
718         if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
719             Logs.warn("krb5_principal_compare_any_realm not found in -lkrb5")
720             use_ads_krb5 = False
721         if not conf.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
722            not conf.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
723             Logs.warn("krb5_c_string_to_key not found in -lkrb5")
724             use_ads_krb5 = False
725         if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
726            not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
727             Logs.warn("no CREATE_KEY_FUNCTIONS detected")
728             use_ads_krb5 = False
729         if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
730            not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
731             Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
732             use_ads_krb5 = False
733         if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
734            not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
735             Logs.warn("no KT_FREE_FUNCTION detected")
736             use_ads_krb5 = False
737         if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
738             Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
739             use_ads_krb5 = False
740
741         # We don't actually use
742         # gsskrb5_extract_authz_data_from_sec_context, but it is a
743         # clue that this Heimdal, which does the PAC processing we
744         # need on the standard gss_inquire_sec_context_by_oid
745         if not conf.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
746             not (conf.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
747                      conf.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
748             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")
749             use_ads_krb5 = False
750
751         if not conf.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
752             Logs.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
753             use_ads_krb5 = False
754
755         if use_ads_krb5:
756             conf.DEFINE('HAVE_KRB5', '1')
757             conf.env['HAVE_KRB5'] = '1'
758         else:
759             conf.undefine('HAVE_KRB5_H')
760             conf.undefine('HAVE_GSSAPI_H')
761             conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
762             conf.undefine('HAVE_GSSAPI_GSSAPI_H')
763             use_ads = False
764
765         if not conf.CONFIG_SET('HAVE_LDAP'):
766             use_ads = False
767             use_ads_ldap = False
768
769     if use_ads:
770         conf.DEFINE('WITH_ADS', '1')
771         conf.env['HAVE_ADS'] = '1'
772         Logs.info("Building with Active Directory support.")
773     elif Options.options.with_ads == False:
774         Logs.info("Building without Active Directory support (--without-ads).")
775     else:
776         if not use_ads_krb5:
777             Logs.warn("Active Directory support not available: krb5 libs don't have all required features")
778         if not use_ads_ldap:
779             Logs.warn("Active Directory support not available: LDAP support is not available.")
780         if Options.options.with_ads:
781             conf.fatal("Active Directory support not found. Use --without-ads "
782                        "for building without Active Directory support. "
783                        "ADS support improves communication with "
784                        "Active Directory domain controllers.")
785         else:
786             # this is the auto-mode case
787             Logs.warn("Building without Active Directory support.")
788
789
790     if Options.options.with_utmp:
791         conf.env.with_utmp = True
792         if not conf.CHECK_HEADERS('utmp.h'): conf.env.with_utmp = False
793         conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
794         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
795                                     define='HAVE_UT_UT_NAME')
796         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers='utmp.h',
797                                     define='HAVE_UT_UT_USER')
798         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_id', headers='utmp.h',
799                                     define='HAVE_UT_UT_ID')
800         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_host', headers='utmp.h',
801                                     define='HAVE_UT_UT_HOST')
802         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_time', headers='utmp.h',
803                                     define='HAVE_UT_UT_TIME')
804         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_tv', headers='utmp.h',
805                                     define='HAVE_UT_UT_TV')
806         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_type', headers='utmp.h',
807                                     define='HAVE_UT_UT_TYPE')
808         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_pid', headers='utmp.h',
809                                     define='HAVE_UT_UT_PID')
810         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers='utmp.h',
811                                     define='HAVE_UT_UT_EXIT')
812         conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers='utmpx.h',
813                                     define='HAVE_UX_UT_SYSLEN')
814         conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
815                         'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
816                         msg="Checking whether pututline returns pointer")
817         conf.CHECK_SIZEOF(['((struct utmp *)NULL)->ut_line'], headers='utmp.h',
818                           define='SIZEOF_UTMP_UT_LINE', critical=False)
819         if not conf.CONFIG_SET('SIZEOF_UTMP_UT_LINE'):
820             conf.env.with_utmp = False
821         elif int(conf.env.SIZEOF_UTMP_UT_LINE) < 15:
822             conf.env.with_utmp = False
823         if conf.env.with_utmp:
824             conf.DEFINE('WITH_UTMP', 1)
825         else:
826             Logs.warn("--with-utmp but utmp support not sufficient")
827
828     if Options.options.with_avahi:
829         conf.env.with_avahi = True
830         if not conf.CHECK_HEADERS('avahi-common/watch.h avahi-client/client.h'): conf.env.with_avahi = False
831         if not conf.CHECK_FUNCS_IN('avahi_client_new', 'avahi-client'): conf.env.with_avahi = False
832         if not conf.CHECK_FUNCS_IN('avahi_strerror', 'avahi-common'): conf.env.with_avahi = False
833         if conf.env.with_avahi:
834             conf.DEFINE('WITH_AVAHI_SUPPORT', 1)
835     else:
836         conf.SET_TARGET_TYPE('avahi-common', 'EMPTY')
837         conf.SET_TARGET_TYPE('avahi-client', 'EMPTY')
838
839     if Options.options.with_iconv:
840         conf.env.with_iconv = True
841         if not conf.CHECK_FUNCS_IN('iconv_open', 'iconv', headers='iconv.h'):
842             conf.env.with_iconv = False
843         if conf.env.with_iconv:
844             conf.DEFINE('HAVE_ICONV', 1)
845
846     if Options.options.with_pam:
847         use_pam=True
848         conf.CHECK_HEADERS('security/pam_appl.h pam/pam_appl.h')
849         if not conf.CONFIG_SET('HAVE_SECURITY_PAM_APPL_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_APPL_H'):
850             Logs.warn("--with-pam=yes but pam_appl.h not found")
851             use_pam=False
852         conf.CHECK_FUNCS_IN('pam_get_data', 'pam')
853         conf.CHECK_HEADERS('security/pam_modules.h pam/pam_modules.h')
854         if not conf.CONFIG_SET('HAVE_SECURITY_PAM_MODULES_H') and not conf.CONFIG_SET('HAVE_PAM_PAM_MODULES_H'):
855             Logs.warn("--with-pam=yes but pam_modules.h not found")
856             use_pam=False
857         conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
858         conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
859         conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
860         conf.CHECK_CODE('''
861 #if defined(HAVE_SECURITY_PAM_APPL_H)
862 #include <security/pam_appl.h>
863 #elif defined(HAVE_PAM_PAM_APPL_H)
864 #include <pam/pam_appl.h>
865 #endif
866 pam_set_item(0, PAM_RHOST, 0);
867 ''',
868             'HAVE_PAM_RHOST',
869             lib='pam',
870             msg="Checking whether PAM_RHOST is available");
871         conf.CHECK_CODE('''
872 #if defined(HAVE_SECURITY_PAM_APPL_H)
873 #include <security/pam_appl.h>
874 #elif defined(HAVE_PAM_PAM_APPL_H)
875 #include <pam/pam_appl.h>
876 #endif
877 pam_set_item(0, PAM_TTY, 0);
878 ''',
879             'HAVE_PAM_TTY',
880             lib='pam',
881             msg="Checking whether PAM_TTY is available");
882         conf.CHECK_CODE('''
883 #if (!defined(LINUX))
884
885 #define PAM_EXTERN extern
886 #if defined(HAVE_SECURITY_PAM_APPL_H)
887 #include <security/pam_appl.h>
888 #elif defined(HAVE_PAM_PAM_APPL_H)
889 #include <pam/pam_appl.h>
890 #endif
891
892 #endif
893
894 #if defined(HAVE_SECURITY_PAM_MODULES_H)
895 #include <security/pam_modules.h>
896 #elif defined(HAVE_PAM_PAM_MODULES_H)
897 #include <pam/pam_modules.h>
898 #endif
899
900 #if defined(HAVE_SECURITY__PAM_MACROS_H)
901 #include <security/_pam_macros.h>
902 #elif defined(HAVE_PAM__PAM_MACROS_H)
903 #include <pam/_pam_macros.h>
904 #endif
905
906 #ifdef HAVE_SECURITY_PAM_EXT_H
907 #include <security/pam_ext.h>
908 #endif
909
910 int i; i = PAM_RADIO_TYPE;
911 ''',
912             'HAVE_PAM_RADIO_TYPE',
913             lib='pam',
914             msg="Checking whether PAM_RADIO_TYPE is available");
915         if use_pam:
916             conf.DEFINE('WITH_PAM', 1)
917             conf.DEFINE('WITH_PAM_MODULES', 1)
918
919     if Options.options.with_pam_smbpass:
920         conf.env.with_pam_smbpass = True
921
922     seteuid = False
923
924 #
925 # Ensure we select the correct set of system calls on Linux.
926 #
927     if (host_os.rfind('linux') > -1):
928         conf.CHECK_CODE('''
929 #if defined(HAVE_UNISTD_H)
930 #include <unistd.h>
931 #endif
932 #include <stdlib.h>
933 #include <stdio.h>
934 #include <sys/types.h>
935 #include <errno.h>
936
937 #ifdef HAVE_SYS_PRIV_H
938 #include <sys/priv.h>
939 #endif
940 #ifdef HAVE_SYS_ID_H
941 #include <sys/id.h>
942 #endif
943
944 #if defined(HAVE_SYSCALL_H)
945 #include <syscall.h>
946 #endif
947
948 #if defined(HAVE_SYS_SYSCALL_H)
949 #include <sys/syscall.h>
950 #endif
951
952 syscall(SYS_setresuid32, -1, -1, -1);
953 syscall(SYS_setresgid32, -1, -1, -1);
954 syscall(SYS_setreuid32, -1, -1);
955 syscall(SYS_setregid32, -1, -1);
956 syscall(SYS_setuid32, -1);
957 syscall(SYS_setgid32, -1);
958 syscall(SYS_setgroups32, 0, NULL);
959 ''',
960             'USE_LINUX_32BIT_SYSCALLS',
961             msg="Checking whether Linux should use 32-bit credential calls");
962
963         if (conf.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
964             seteuid = conf.CHECK_CODE('''
965                                 #define AUTOCONF_TEST 1
966                                 #define USE_LINUX_THREAD_CREDENTIALS 1
967                                 #define USE_LINUX_32BIT_SYSCALLS 1
968                                 #include "../lib/util/setid.c"
969                                 #include "./lib/util_sec.c"
970                                 ''',
971                                 'USE_LINUX_THREAD_CREDENTIALS',
972                                 addmain=False,
973                                 execute=True,
974                                 msg="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
975         else:
976             seteuid = conf.CHECK_CODE('''
977                                 #define AUTOCONF_TEST 1
978                                 #define USE_LINUX_THREAD_CREDENTIALS 1
979                                 #include "../lib/util/setid.c"
980                                 #include "./lib/util_sec.c"
981                                 ''',
982                                 'USE_LINUX_THREAD_CREDENTIALS',
983                                 addmain=False,
984                                 execute=True,
985                                 msg="Checking whether we can use Linux thread-specific credentials")
986     if not seteuid:
987         seteuid = conf.CHECK_CODE('''
988                                 #define AUTOCONF_TEST 1
989                                 #define USE_SETREUID 1
990                                 #include "../lib/util/setid.c"
991                                 #include "./lib/util_sec.c"
992                                 ''',
993                                 'USE_SETREUID',
994                                 addmain=False,
995                                 execute=True,
996                                 msg="Checking whether setreuid is available")
997     if not seteuid:
998         seteuid = conf.CHECK_CODE('''
999                                 #define AUTOCONF_TEST 1
1000                                 #define USE_SETRESUID 1
1001                                 #include "../lib/util/setid.c"
1002                                 #include "./lib/util_sec.c"
1003                                 ''',
1004                                 'USE_SETRESUID',
1005                                 addmain=False,
1006                                 execute=True,
1007                                 msg="Checking whether setresuid is available")
1008     if not seteuid:
1009         seteuid = conf.CHECK_CODE('''
1010                                 #define AUTOCONF_TEST 1
1011                                 #define USE_SETEUID 1
1012                                 #include "../lib/util/setid.c"
1013                                 #include "./lib/util_sec.c"
1014                                 ''',
1015                                 'USE_SETEUID',
1016                                 addmain=False,
1017                                 execute=True,
1018                                 msg="Checking whether seteuid is available")
1019     if not seteuid:
1020         seteuid = conf.CHECK_CODE('''
1021                                 #define AUTOCONF_TEST 1
1022                                 #define USE_SETUIDX 1
1023                                 #include "../lib/util/setid.c"
1024                                 #include "./lib/util_sec.c"
1025                                 ''',
1026                                 'USE_SETUIDX',
1027                                 addmain=False,
1028                                 execute=True,
1029                                 mandatory=True,
1030                                 msg="Checking whether setuidx is available")
1031     if Options.options.with_dnsupdate:
1032         if not conf.CONFIG_SET('HAVE_KRB5'):
1033             Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
1034         else:
1035             conf.DEFINE('WITH_DNS_UPDATES', 1)
1036     conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
1037     if Options.options.developer:
1038         if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
1039             conf.DEFINE('VALGRIND', '1')
1040
1041     if conf.CHECK_CODE('''
1042 #include <bits/sockaddr.h>
1043 #include <linux/netlink.h>
1044 ''',
1045                 'HAVE_LINUX_NETLINK_H',
1046                 msg="Checking whether Linux netlink is available"):
1047
1048         conf.CHECK_CODE('''
1049 #include <bits/sockaddr.h>
1050 #include <linux/netlink.h>
1051 #include <linux/rtnetlink.h>
1052 ''',
1053                 'HAVE_LINUX_RTNETLINK_H',
1054                 msg='Checking whether Linux rtnetlink is available')
1055
1056     conf.CHECK_CODE('''
1057 #include "../tests/fcntl_lock.c"
1058 ''',
1059                 'HAVE_FCNTL_LOCK',
1060                 addmain=False,
1061                 execute=True,
1062                 msg='Checking whether fcntl locking is available')
1063
1064 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
1065     if not conf.CHECK_CODE('''
1066 #define _XOPEN_SOURCE 600
1067 #include <stdlib.h>
1068 #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
1069 #error probably broken posix_fallocate
1070 #endif
1071 ''',
1072                            '_HAVE_UNBROKEN_POSIX_FALLOCATE',
1073                            msg='Checking for broken posix_fallocate'):
1074         conf.DEFINE('HAVE_BROKEN_POSIX_FALLOCATE', '1')
1075
1076
1077     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
1078                                 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
1079     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
1080                                 define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
1081     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
1082                                 define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
1083     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
1084                                 define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
1085     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
1086                                 define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
1087     if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
1088        conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
1089        conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
1090        conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIME_N') or \
1091        conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_UMTIME'):
1092         conf.DEFINE('HAVE_STAT_HIRES_TIMESTAMPS', '1')
1093
1094     # recent FreeBSD, NetBSD have creation timestamps called birthtime:
1095     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
1096                                 define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
1097     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
1098                                 define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
1099     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
1100                                 define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
1101
1102     conf.CHECK_CODE('''
1103 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
1104 ''',
1105                 'HAVE_POSIX_FADVISE',
1106                 msg='Checking whether posix_fadvise is available',
1107                 headers='unistd.h fcntl.h')
1108
1109     for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
1110         conf.CHECK_CODE('''
1111                         #include <unistd.h>
1112                         return sysconf(%s) == -1 ? 1 : 0;
1113                         ''' % v,
1114                         'SYSCONF%s' % v,
1115                         msg='Checking whether sysconf(%s) is available' % v)
1116
1117     conf.CHECK_CODE('''
1118 #include <sys/syscall.h>
1119 #include <unistd.h>
1120 syscall(SYS_initgroups, 16, NULL, NULL, 0);
1121                     ''',
1122                     'HAVE_DARWIN_INITGROUPS',
1123                     msg='Checking whether to use the Darwin-specific initgroups system call')
1124
1125     conf.CHECK_CODE('''struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
1126                     'HAVE_UTIMBUF',
1127                     headers='sys/types.h utime.h',
1128                     msg='Checking whether struct utimbuf is available')
1129
1130     if conf.CHECK_CODE('''struct sigevent s;''',
1131                     'HAVE_STRUCT_SIGEVENT',
1132                     headers='sys/types.h stdlib.h stddef.h signal.h',
1133                     msg='Checking whether we have the struct sigevent'):
1134         conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
1135                                     define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
1136                                     headers='signal.h');
1137         conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
1138                                     define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
1139                                     headers='signal.h');
1140
1141     if os.path.exists('/proc/sys/kernel/core_pattern'):
1142         conf.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
1143
1144     if conf.CHECK_CODE('''
1145 #include <time.h>
1146 main() {
1147         struct tm *tm;
1148         if (sizeof(time_t) == 8) {
1149                 time_t max_time = 0x7fffffffffffffffll;
1150                 tm = gmtime(&max_time);
1151                 /* This should fail with 32-bit tm_year. */
1152                 if (tm == NULL) {
1153                         /* Max time_t that works with 32-bit int tm_year in struct tm. */
1154                         max_time = 67768036191676799ll;
1155                         tm = gmtime(&max_time);
1156                         if (tm) {
1157                                 exit(0);
1158                         }
1159                 }
1160         }
1161         exit(1);
1162 }''',
1163         '__TIME_T_MAX',
1164         addmain=False,
1165         execute=True,
1166         msg="Checking for the maximum value of the 'time_t' type"):
1167             conf.DEFINE('TIME_T_MAX', '67768036191676799ll')
1168
1169     conf.CHECK_CODE('''
1170 #if defined(HAVE_UNISTD_H)
1171 #include <unistd.h>
1172 #endif
1173 #include <sys/types.h>
1174 main() { dev_t dev = makedev(1,2); return 0; }
1175 ''',
1176         'HAVE_MAKEDEV',
1177         addmain=False,
1178         msg='Checking whether the macro for makedev is available')
1179
1180     conf.CHECK_CODE('''
1181 #include <stdio.h>
1182 #include <limits.h>
1183 #include <signal.h>
1184
1185 void exit_on_core(int ignored) {
1186         exit(1);
1187 }
1188
1189 main() {
1190         char *newpath;
1191         signal(SIGSEGV, exit_on_core);
1192         newpath = realpath("/tmp", NULL);
1193         exit((newpath != NULL) ? 0 : 1);
1194 }
1195 ''',
1196         'REALPATH_TAKES_NULL',
1197         addmain=False,
1198         execute=True,
1199         msg='Checking whether the realpath function allows a NULL argument')
1200
1201     conf.CHECK_CODE('''#include "../tests/ftruncate.c"''',
1202                     'HAVE_FTRUNCATE_EXTEND',
1203                     msg='Checking for ftruncate extend',
1204                     addmain=False,
1205                     execute=True)
1206
1207     if Options.options.with_sendfile_support:
1208         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):
1209             conf.CHECK_CODE('''
1210                             int tofd, fromfd;
1211                             off_t offset;
1212                             size_t total;
1213                             ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
1214                             ''',
1215                             '_HAVE_SENDFILE',
1216                             headers='sys/sendfile.h',
1217                             msg='Checking for linux sendfile support')
1218
1219             if conf.CONFIG_SET('_HAVE_SENDFILE'):
1220                 conf.DEFINE('HAVE_SENDFILE', '1')
1221                 conf.DEFINE('LINUX_SENDFILE_API', '1')
1222                 conf.DEFINE('WITH_SENDFILE', '1')
1223         elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
1224             conf.CHECK_CODE('''
1225                             #include <sys/types.h>
1226                             #include <unistd.h>
1227                             #include <sys/socket.h>
1228                             #include <sys/uio.h>
1229                             int fromfd, tofd, ret, total=0;
1230                             off_t offset, nwritten;
1231                             struct sf_hdtr hdr;
1232                             struct iovec hdtrl;
1233                             hdr.headers = &hdtrl;
1234                             hdr.hdr_cnt = 1;
1235                             hdr.trailers = NULL;
1236                             hdr.trl_cnt = 0;
1237                             hdtrl.iov_base = NULL;
1238                             hdtrl.iov_len = 0;
1239                             ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
1240                             ''',
1241                             '_HAVE_SENDFILE',
1242                             msg='Checking for freebsd sendfile support')
1243             if conf.CONFIG_SET('_HAVE_SENDFILE'):
1244                 conf.DEFINE('HAVE_SENDFILE', '1')
1245                 conf.DEFINE('FREEBSD_SENDFILE_API', '1')
1246                 conf.DEFINE('WITH_SENDFILE', '1')
1247         elif (host_os.rfind('darwin') > -1):
1248             conf.CHECK_CODE('''
1249                             #include <sys/types.h>
1250                             #include <sys/socket.h>
1251                             #include <sys/uio.h>
1252                             int fromfd, tofd, ret;
1253                             off_t offset, nwritten;
1254                             struct sf_hdtr hdr;
1255                             struct iovec hdtrl;
1256                             hdr.headers = &hdtrl;
1257                             hdr.hdr_cnt = 1;
1258                             hdr.trailers = (void *)0;
1259                             hdr.trl_cnt = 0;
1260                             hdtrl.iov_base = (void *)0;
1261                             hdtrl.iov_len = 0;
1262                             ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
1263                             ''',
1264                             '_HAVE_SENDFILE',
1265                             msg='Checking for darwin sendfile support')
1266             if conf.CONFIG_SET('_HAVE_SENDFILE'):
1267                 conf.DEFINE('HAVE_SENDFILE', '1')
1268                 conf.DEFINE('DARWIN_SENDFILE_API', '1')
1269                 conf.DEFINE('WITH_SENDFILE', '1')
1270         elif (host_os.rfind('hpux') > -1) or (host_os.rfind('osf') > -1):
1271             conf.CHECK_CODE('''
1272                             #include <sys/socket.h>
1273                             #include <sys/uio.h>
1274                             int fromfd, tofd;
1275                             size_t total=0;
1276                             struct iovec hdtrl[2];
1277                             ssize_t nwritten;
1278                             off_t offset;
1279                             hdtrl[0].iov_base = 0;
1280                             hdtrl[0].iov_len = 0;
1281                             nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
1282                             ''',
1283                             '_HAVE_SENDFILE',
1284                             msg='Checking for osf/hpux sendfile support')
1285             if conf.CONFIG_SET('_HAVE_SENDFILE'):
1286                 conf.DEFINE('HAVE_SENDFILE', '1')
1287                 conf.DEFINE('HPUX_SENDFILE_API', '1')
1288                 conf.DEFINE('WITH_SENDFILE', '1')
1289         elif (host_os.rfind('solaris') > -1):
1290             conf.CHECK_FUNCS_IN('sendfile', 'sendfilev')
1291             conf.CHECK_CODE('''
1292                             #include <sys/sendfile.h>,
1293                             int sfvcnt;
1294                             size_t xferred;
1295                             struct sendfilevec vec[2];
1296                             ssize_t nwritten;
1297                             int tofd;
1298                             sfvcnt = 2;
1299                             vec[0].sfv_fd = SFV_FD_SELF;
1300                             vec[0].sfv_flag = 0;
1301                             vec[0].sfv_off = 0;
1302                             vec[0].sfv_len = 0;
1303                             vec[1].sfv_fd = 0;
1304                             vec[1].sfv_flag = 0;
1305                             vec[1].sfv_off = 0;
1306                             vec[1].sfv_len = 0;
1307                             nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
1308                             ''',
1309                             '_HAVE_SENDFILEV',
1310                             msg='Checking for solaris sendfilev support')
1311             if conf.CONFIG_SET('_HAVE_SENDFILEV'):
1312                 conf.DEFINE('HAVE_SENDFILEV', '1')
1313                 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
1314                 conf.DEFINE('WITH_SENDFILE', '1')
1315         elif (host_os.rfind('aix') > -1):
1316             conf.CHECK_CODE('''
1317                             #include <sys/socket.h>
1318                             int fromfd, tofd;
1319                             size_t total=0;
1320                             struct sf_parms hdtrl;
1321                             ssize_t nwritten;
1322                             hdtrl.header_data = 0;
1323                             hdtrl.header_length = 0;
1324                             hdtrl.file_descriptor = fromfd;
1325                             hdtrl.file_offset = 0;
1326                             hdtrl.file_bytes = 0;
1327                             hdtrl.trailer_data = 0;
1328                             hdtrl.trailer_length = 0;
1329                             nwritten = send_file(&tofd, &hdtrl, 0);
1330                             ''',
1331                             '_HAVE_SENDFILE',
1332                             msg='Checking for AIX send_file support')
1333             if conf.CONFIG_SET('_HAVE_SENDFILE'):
1334                 conf.DEFINE('HAVE_SENDFILE', '1')
1335                 conf.DEFINE('AIX_SENDFILE_API', '1')
1336                 conf.DEFINE('WITH_SENDFILE', '1')
1337
1338     # Check for getcwd allowing a NULL arg.
1339     conf.CHECK_CODE('''
1340 #include <unistd.h>
1341 main() {
1342         char *s = getcwd(NULL,0);
1343         exit(s != NULL ?  0 : 1);
1344 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
1345         msg="getcwd takes a NULL argument")
1346
1347
1348     # UnixWare 7.x has its getspnam in -lgen
1349     conf.CHECK_FUNCS_IN('getspnam', 'gen')
1350     conf.CHECK_FUNCS_IN('getspnam', 'security')
1351     conf.CHECK_FUNCS_IN('getspnam', 'sec')
1352
1353     if Options.options.with_quotas:
1354         # For quotas on Veritas VxFS filesystems
1355         conf.CHECK_HEADERS('sys/fs/vx_quota.h')
1356         # For sys/quota.h and linux/quota.h
1357         conf.CHECK_HEADERS('sys/quota.h')
1358         # For quotas on BSD systems
1359         conf.CHECK_HEADERS('ufs/ufs/quota.h')
1360         # For quotas on Linux XFS filesystems
1361         if conf.CHECK_HEADERS('xfs/xqm.h'):
1362             conf.DEFINE('HAVE_XFS_QUOTAS', '1')
1363         else:
1364             # For Irix XFS
1365             conf.CHECK_CODE('''
1366                 #include "confdefs.h"
1367                 #ifdef HAVE_SYS_TYPES_H
1368                 #include <sys/types.h>
1369                 #endif
1370                 #ifdef HAVE_ASM_TYPES_H
1371                 #include <asm/types.h>
1372                 #endif
1373                 #include <sys/quota.h>
1374                 int i = Q_XGETQUOTA;''',
1375                 define='HAVE_XFS_QUOTAS',
1376                 msg='for XFS QUOTA in <sys/quota.h>',
1377                 execute=False,
1378                 local_include=False)
1379         
1380         # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
1381         conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define='HAVE_DQB_FSOFTLIMIT',
1382                                 headers='sys/quota.h')
1383         #darwin style quota bytecount
1384         conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_curbytes', define='HAVE_STRUCT_DQBLK_DQB_CURBYTES',
1385                                 headers='sys/quota.h')
1386         if conf.CHECK_HEADERS('rpcsvc/rquota.h'):
1387             conf.DEFINE('HAVE_NFS_QUOTAS', '1')
1388             conf.CHECK_STRUCTURE_MEMBER('struct getquota_rslt', 'getquota_rslt_u',
1389                                         define='HAVE_GETQUOTA_RSLT_GETQUOTA_RSLT_U',
1390                                         headers='rpcsvc/rquota.h')
1391
1392         if (host_os.rfind('linux') > -1):
1393             conf.DEFINE('HAVE_QUOTACTL_LINUX', '1')
1394         elif not conf.CONFIG_SET("HAVE_XFS_QUOTAS"):
1395             if not conf.CHECK_CODE('''
1396                 #define HAVE_QUOTACTL_4A 1
1397                 #define AUTOCONF_TEST 1
1398                 #include "../tests/sysquotas.c"
1399                 ''',
1400                                    cflags=conf.env['WERROR_CFLAGS'],
1401                                    define='HAVE_QUOTACTL_4A',
1402                                    msg='for QUOTACTL_4A: long quotactl(int cmd, char *special, qid_t id, caddr_t addr)',
1403                                    execute=True,
1404                                    addmain=False):
1405
1406                 conf.CHECK_CODE('''
1407                 #define HAVE_QUOTACTL_4B 1
1408                 #define AUTOCONF_TEST 1
1409                 #include "../tests/sysquotas.c"
1410                 ''',
1411                                 cflags=conf.env['WERROR_CFLAGS'],
1412                                 define='HAVE_QUOTACTL_4B',
1413                                 msg='for QUOTACTL_4B:  int quotactl(const char *path, int cmd, int id, char *addr)',
1414                                 execute=True,
1415                                 addmain=False)
1416
1417         conf.CHECK_CODE('''
1418                      clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
1419 ''', 
1420                         headers="rpc/rpc.h rpc/types.h rpcsvc/rquota.h rpc/nettype.h rpc/xdr.h", 
1421                         define='HAVE_NFS_QUOTAS',
1422                         msg='for NFS QUOTAS',
1423                         execute=True,
1424                         local_include=False)
1425
1426         if conf.CONFIG_SET('HAVE_QUOTACTL_LINUX') or \
1427            conf.CONFIG_SET('HAVE_QUOTACTL_4A') or \
1428            conf.CONFIG_SET('HAVE_QUOTACTL_4B') or \
1429            conf.CONFIG_SET('HAVE_XFS_QUOTAS'):
1430             conf.DEFINE('HAVE_SYS_QUOTAS', '1')
1431             conf.DEFINE('WITH_QUOTAS', '1')
1432
1433     #
1434     # checking for clustering extensions (CTDB)
1435     #
1436     if Options.options.with_cluster_support == False:
1437         # configure is called with --without-cluster-support,
1438         # so don't check for and build w/o ctdb support.
1439         have_cluster_support = False
1440
1441     else:
1442
1443         have_cluster_support = True
1444         ctdb_broken = ""
1445         CTDB_CFLAGS = ""
1446
1447         srcdir = os.path.realpath(conf.srcdir)
1448         if 'EXTRA_INCLUDES' in conf.env:
1449             includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/')
1450         else:
1451             includes = ''
1452
1453         if Options.options.ctdb_dir:
1454             CTDB_INCLUDE = Options.options.ctdb_dir + '/include'
1455         else:
1456             CTDB_INCLUDE = conf.srcdir + '/ctdb/include'
1457         includes = includes + ' ' + CTDB_INCLUDE
1458
1459         if not conf.env.USING_SYSTEM_TDB:
1460             includes = includes + ' ' + srcdir + '/lib/tdb/include'
1461
1462         if not conf.env.USING_SYSTEM_TALLOC:
1463             includes = includes + ' ' + srcdir + '/lib/talloc'
1464
1465         ok = conf.CHECK_CODE('''
1466             #define NO_CONFIG_H
1467             #include "replace.h"
1468             #include "system/wait.h"
1469             #include "system/network.h"
1470             #define private #error __USED_RESERVED_WORD_private__
1471             #include <talloc.h>
1472             #include <tdb.h>
1473             #include <ctdb.h>
1474
1475             int main(void)
1476             {
1477                 return 0;
1478             }
1479             ''',
1480             'HAVE_CTDB_CHECK_CODE',
1481             addmain=False,
1482             includes=includes,
1483             msg='Checking for header ctdb.h')
1484         if ok:
1485             CTDB_CFLAGS += ' -DHAVE_CTDB_H=1'
1486         else:
1487             have_cluster_support = False
1488             ctdb_broken = "ctdb.h is required for cluster support"
1489
1490         conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1491         if have_cluster_support:
1492             ok = conf.CHECK_CODE('''
1493                 #define NO_CONFIG_H
1494                 #include "replace.h"
1495                 #include "system/wait.h"
1496                 #include "system/network.h"
1497                 #define private #error __USED_RESERVED_WORD_private__
1498                 #include <talloc.h>
1499                 #include <tdb.h>
1500                 #include <ctdb.h>
1501                 #include <ctdb_private.h>
1502
1503                 int main(void)
1504                 {
1505                     return 0;
1506                 }
1507                 ''',
1508                 'HAVE_CTDB_CHECK_CODE',
1509                 addmain=False,
1510                 includes=includes,
1511                 msg='Checking for header ctdb_private.h')
1512             if ok:
1513                 CTDB_CFLAGS += ' -DHAVE_CTDB_PRIVATE_H=1'
1514             else:
1515                 have_cluster_support = False
1516                 ctdb_broken = "ctdb_private.h is required for cluster support"
1517
1518         conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1519         if have_cluster_support:
1520             ok = conf.CHECK_CODE('''
1521                 #define NO_CONFIG_H
1522                 #include "replace.h"
1523                 #include "system/wait.h"
1524                 #include "system/network.h"
1525                 #define private #error __USED_RESERVED_WORD_private__
1526                 #include <talloc.h>
1527                 #include <tdb.h>
1528                 #include <ctdb.h>
1529                 #include <ctdb_protocol.h>
1530
1531                 int main(void)
1532                 {
1533                     return 0;
1534                 }
1535                 ''',
1536                 'HAVE_CTDB_CHECK_CODE',
1537                 addmain=False,
1538                 includes=includes,
1539                 msg='Checking for header ctdb_protocol.h')
1540             if ok:
1541                 CTDB_CFLAGS += ' -DHAVE_CTDB_PROTOCOL_H=1'
1542
1543         conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1544         if have_cluster_support:
1545             ok = conf.CHECK_CODE('''
1546                 #define NO_CONFIG_H
1547                 #include "replace.h"
1548                 #include "system/wait.h"
1549                 #include "system/network.h"
1550                 #include <talloc.h>
1551                 #include <tdb.h>
1552                 #include <ctdb.h>
1553                 #include <ctdb_private.h>
1554
1555                 int main(void)
1556                 {
1557                    int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
1558                    return 0;
1559                 }
1560                 ''',
1561                 'HAVE_CTDB_CHECK_CODE',
1562                 addmain=False,
1563                 includes=includes,
1564                 msg='Checking for transaction support (TRANS3_COMMIT control)')
1565             if ok:
1566                 CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL=1'
1567             else:
1568                 have_cluster_support = False
1569                 ctdb_broken = "ctdb transaction support missing or too old"
1570
1571         conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1572         if have_cluster_support:
1573             ok = conf.CHECK_CODE('''
1574                 #define NO_CONFIG_H
1575                 #include "replace.h"
1576                 #include "system/wait.h"
1577                 #include "system/network.h"
1578                 #include <talloc.h>
1579                 #include <tdb.h>
1580                 #include <ctdb.h>
1581                 #include <ctdb_private.h>
1582
1583                 int main(void)
1584                 {
1585                     int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
1586                     return 0;
1587                 }
1588                 ''',
1589                 'HAVE_CTDB_CHECK_CODE',
1590                 addmain=False,
1591                 includes=includes,
1592                 msg='Checking for SCHEDULE_FOR_DELETION control')
1593             if ok:
1594                 CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL=1'
1595             else:
1596                 if not Options.options.enable_old_ctdb:
1597                     have_cluster_support = False
1598                     ctdb_broken = "SCHEDULE_FOR_DELETION control missing"
1599                 else:
1600                     Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
1601
1602         conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1603         if have_cluster_support:
1604             ok = conf.CHECK_CODE('''
1605                #define NO_CONFIG_H
1606                #include "replace.h"
1607                #include "system/wait.h"
1608                #include "system/network.h"
1609                #include <talloc.h>
1610                #include <tdb.h>
1611                #include <ctdb.h>
1612
1613                int main(void)
1614                {
1615                    int i = (int)CTDB_WANT_READONLY;
1616                    return 0;
1617                }
1618                ''',
1619                'HAVE_CTDB_CHECK_CODE',
1620                addmain=False,
1621                includes=includes,
1622                msg='Checking for CTDB readonly records support')
1623             if ok:
1624                 CTDB_CFLAGS += ' -DHAVE_CTDB_WANT_READONLY_DECL=1'
1625             else:
1626                 if not Options.options.enable_old_ctdb:
1627                     have_cluster_support = False
1628                     ctdb_broken = "support for CTDB readonly records missing"
1629                 else:
1630                     Logs.warn("ignoring missing READONLY support (--enable-old-ctdb)")
1631
1632         conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1633         if have_cluster_support:
1634             ok = conf.CHECK_CODE('''
1635                 #define NO_CONFIG_H
1636                 #include "replace.h"
1637                 #include "system/wait.h"
1638                 #include "system/network.h"
1639                 #include <talloc.h>
1640                 #include <tdb.h>
1641                 #include <ctdb.h>
1642                 #include <ctdb_private.h>
1643
1644                 int main(void)
1645                 {
1646                     struct ctdb_control_tcp _x;
1647                     return 0;
1648                 }
1649                 ''',
1650                 'HAVE_CTDB_CHECK_CODE',
1651                 addmain=False,
1652                 includes=includes,
1653                 msg='Checking for ctdb ipv4 support')
1654             if ok:
1655                 CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP=1'
1656             else:
1657                 have_cluster_support = False
1658                 ctdb_broken = "missing struct ctdb_control_tcp"
1659
1660         conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1661         if have_cluster_support:
1662             ok = conf.CHECK_CODE('''
1663                 #define NO_CONFIG_H
1664                 #include "replace.h"
1665                 #include "system/wait.h"
1666                 #include "system/network.h"
1667                 #include <talloc.h>
1668                 #include <tdb.h>
1669                 #include <ctdb.h>
1670                 #include <ctdb_private.h>
1671
1672                 int main(void)
1673                 {
1674                     struct ctdb_control_tcp_addr _x;
1675                     return 0;
1676                 }
1677                 ''',
1678                 'HAVE_CTDB_CHECK_CODE',
1679                 addmain=False,
1680                 includes=includes,
1681                 msg='Checking for ctdb ipv6 support')
1682             if ok:
1683                 CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP_ADDR=1'
1684
1685         conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1686         if have_cluster_support:
1687             ok = conf.CHECK_CODE('''
1688                 #define NO_CONFIG_H
1689                 #include "replace.h"
1690                 #include "system/wait.h"
1691                 #include "system/network.h"
1692                 #include <talloc.h>
1693                 #include <tdb.h>
1694                 #include <ctdb.h>
1695                 #include <ctdb_private.h>
1696
1697                 int main(void)
1698                 {
1699                     int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
1700                     return 0;
1701                 }
1702                 ''',
1703                 'HAVE_CTDB_CHECK_CODE',
1704                 addmain=False,
1705                 includes=includes,
1706                 msg='Checking for CHECK_SRVIDS control')
1707             if ok:
1708                 CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL=1'
1709             else:
1710                 if not Options.options.enable_old_ctdb:
1711                     have_cluster_support = False
1712                     ctdb_broken = "CHECK_SRVIDS control missing"
1713                 else:
1714                     Logs.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
1715
1716     conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
1717     conf.undefine('HAVE_CTDB_CHECK_CODE')
1718     if have_cluster_support:
1719         Logs.info("building with cluster support")
1720         conf.env['CTDB_CFLAGS'] = CTDB_CFLAGS
1721         conf.env['CTDB_INCLUDE'] = CTDB_INCLUDE
1722     else:
1723         if Options.options.with_cluster_support == False:
1724             Logs.info("building without cluster support (--without-cluster-support)")
1725         elif Options.options.with_cluster_support == True:
1726             Logs.error("Cluster support not available: " + ctdb_broken)
1727             conf.fatal("Cluster support not found, but --with-cluster-support was specified")
1728         else:
1729             Logs.info("building without cluster support: " + ctdb_broken)
1730         conf.env['CTDB_CFLAGS'] = ''
1731
1732
1733     conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
1734                     'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
1735                     addmain=False,
1736                     link=False,
1737                     msg='Checking whether we can compile with __attribute__((destructor))')
1738
1739     conf.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
1740                     'SEEKDIR_RETURNS_VOID',
1741                     headers='sys/types.h dirent.h',
1742                     msg='Checking whether seekdir returns void')
1743
1744     if Options.options.with_profiling_data:
1745         conf.DEFINE('WITH_PROFILE', 1);
1746
1747     if Options.options.with_pthreadpool:
1748         if conf.CONFIG_SET('HAVE_PTHREAD'):
1749             conf.DEFINE('WITH_PTHREADPOOL', '1')
1750         else:
1751             Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
1752             conf.undefine('WITH_PTHREADPOOL')
1753
1754     if conf.CHECK_HEADERS('gpfs_gpl.h'):
1755         conf.DEFINE('HAVE_GPFS', '1')
1756
1757     if (conf.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
1758         conf.CHECK_DECLS('FS_IOC_GETFLAGS FS_COMPR_FL', headers='linux/fs.h')):
1759             conf.DEFINE('HAVE_LINUX_IOCTL', '1')
1760
1761     conf.env['CCFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64"
1762     if Options.options.libcephfs_dir:
1763         conf.env['CPPPATH_CEPHFS'] = Options.options.libcephfs_dir + '/include'
1764         conf.env['LIBPATH_CEPHFS'] = Options.options.libcephfs_dir + '/lib'
1765
1766     if conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and conf.CHECK_LIB('cephfs'):
1767         conf.DEFINE('HAVE_CEPH', '1')
1768
1769     if Options.options.with_glusterfs:
1770         conf.check_cfg(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs',
1771                        msg='Checking for glusterfs-api >= 4', uselib_store="GFAPI")
1772         conf.CHECK_HEADERS('api/glfs.h', lib='gfapi')
1773         conf.CHECK_LIB('gfapi', shlib=True)
1774
1775         if conf.CONFIG_SET('HAVE_API_GLFS_H'):
1776             conf.DEFINE('HAVE_GLUSTERFS', '1')
1777         else:
1778             conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
1779             conf.undefine('HAVE_GLUSTERFS')
1780     else:
1781         conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
1782         conf.undefine('HAVE_GLUSTERFS')
1783
1784     conf.env.build_regedit = False
1785     if not Options.options.with_regedit == False:
1786         conf.PROCESS_SEPARATE_RULE('system_ncurses')
1787         if conf.CONFIG_SET('HAVE_NCURSES'):
1788             conf.env.build_regedit = True
1789
1790     if conf.env.build_regedit:
1791         Logs.info("building regedit")
1792     else:
1793         if Options.options.with_regedit == False:
1794             Logs.info("not building regedit (--without-regedit)")
1795         elif Options.options.with_regedit == True:
1796             Logs.error("ncurses not available, cannot build regedit")
1797             conf.fatal("ncurses not available, but --with-regedit was specified")
1798         else:
1799             Logs.info("ncurses not available, not building regedit")
1800
1801
1802     default_static_modules.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
1803                                       auth_sam auth_unix auth_winbind auth_wbc
1804                                       auth_domain auth_builtin vfs_default
1805                                       nss_info_template idmap_tdb idmap_passdb
1806                                       idmap_nss'''))
1807
1808     default_shared_modules.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
1809                                       vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
1810                                       vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 
1811                                       auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
1812                                       vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
1813                                       vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
1814                                       vfs_media_harmony
1815                                       vfs_commit
1816                                       vfs_worm
1817                                       vfs_crossrename vfs_linux_xfs_sgid
1818                                       vfs_time_audit idmap_autorid idmap_tdb2
1819                                       idmap_ad
1820                                       idmap_rid idmap_hash idmap_rfc2307'''))
1821
1822     if Options.options.developer:
1823         default_static_modules.extend(TO_LIST('charset_weird'))
1824         default_shared_modules.extend(TO_LIST('perfcount_test'))
1825         default_shared_modules.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
1826         default_shared_modules.extend(TO_LIST('auth_skel pdb_test'))
1827
1828     if Options.options.enable_selftest or Options.options.developer:
1829         default_shared_modules.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr'))
1830         
1831
1832     if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
1833         default_static_modules.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
1834
1835     if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
1836         default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
1837
1838     if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
1839         default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
1840
1841     if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
1842         default_shared_modules.extend(TO_LIST('vfs_fileid'))
1843
1844     if (conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_ACCTRIGHTS')):
1845         default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
1846
1847     if Options.options.with_pthreadpool:
1848         default_shared_modules.extend(TO_LIST('vfs_aio_pthread'))
1849
1850     if conf.CONFIG_SET('HAVE_AIO'):
1851         default_shared_modules.extend(TO_LIST('vfs_aio_posix'))
1852
1853     if conf.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
1854         default_shared_modules.extend(TO_LIST('vfs_aio_linux'))
1855
1856     if conf.CONFIG_SET('HAVE_LDAP'):
1857         default_static_modules.extend(TO_LIST('pdb_ldapsam idmap_ldap'))
1858
1859     if conf.CONFIG_SET('DARWINOS'):
1860         default_static_modules.extend(TO_LIST('charset_macosxfs'))
1861
1862     if conf.CONFIG_SET('HAVE_GPFS'):
1863         default_shared_modules.extend(TO_LIST('vfs_gpfs'))
1864
1865     if conf.CONFIG_SET('HAVE_LINUX_IOCTL'):
1866         default_shared_modules.extend(TO_LIST('vfs_btrfs'))
1867
1868     if conf.CONFIG_SET('SAMBA_FAM_LIBS'):
1869         default_shared_modules.extend(TO_LIST('vfs_notify_fam'))
1870
1871     if conf.CONFIG_SET("HAVE_CEPH"):
1872         default_shared_modules.extend(TO_LIST('vfs_ceph'))
1873
1874     if conf.CONFIG_SET('HAVE_GLUSTERFS'):
1875         default_shared_modules.extend(TO_LIST('vfs_glusterfs'))
1876
1877     explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
1878     explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
1879
1880     def replace_list_item(lst, item, value):
1881         try:
1882             idx = lst.index(item)
1883             lst[idx] = value
1884         except:
1885             pass
1886     # PDB module file name should have the same name as module registers itself
1887     # In Autoconf build we export LDAP passdb module as ldapsam but WAF build
1888     # was always exporting pdb_ldap. In order to support existing packages
1889     # allow referring to pdb_ldapsam as pdb_ldap but use proper name internally.
1890     replace_list_item(explicit_shared_modules, 'pdb_ldap', 'pdb_ldapsam')
1891     replace_list_item(explicit_static_modules, 'pdb_ldap', 'pdb_ldapsam')
1892
1893     final_static_modules = default_static_modules
1894     final_shared_modules = default_shared_modules
1895
1896     for m in explicit_static_modules:
1897         if m in final_shared_modules:
1898             final_shared_modules.remove(m)
1899         final_static_modules.append(m)
1900     for m in explicit_shared_modules:
1901         if m in final_static_modules:
1902             final_static_modules.remove(m)
1903         final_shared_modules.append(m)
1904
1905     if ("auth_domain" not in final_static_modules) or \
1906             ("auth_builtin" not in final_static_modules) or \
1907             ("auth_sam" not in final_static_modules) or \
1908             ("auth_winbind" not in final_static_modules):
1909         raise Utils.WafError('These auth modules MUST be configured as static modules: auth_domain, auth_builtin, auth_sam, auth_winbind')
1910
1911     conf.env['static_modules'] = final_static_modules
1912     conf.env['shared_modules'] = final_shared_modules
1913
1914     conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
1915
1916     static_list = {}
1917     shared_list = {}
1918
1919     prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
1920     conf.env['MODULE_PREFIXES'] = prefixes
1921     for p in prefixes:
1922         for m in final_static_modules:
1923             if m.find(p) == 0:
1924                 if not p in static_list:
1925                     static_list[p] = []
1926                 static_list[p].append(m)
1927         for m in final_shared_modules:
1928             if m.find(p) == 0:
1929                 if not p in shared_list:
1930                     shared_list[p] = []
1931                 shared_list[p].append(m)
1932
1933     for p in prefixes:
1934         static_env = "%s_STATIC" % p.upper()
1935         shared_env = "%s_SHARED" % p.upper()
1936         conf.env[static_env] = []
1937         conf.env[shared_env] = []
1938         if p in static_list:
1939             decl_list=""
1940             for entry in static_list[p]:
1941                 decl_list += "extern NTSTATUS %s_init(void); " % entry
1942                 conf.env[static_env].append('%s' % entry)
1943             decl_list = decl_list.rstrip()
1944             conf.DEFINE('static_decl_%s' % p, decl_list)
1945             conf.DEFINE('static_init_%s' % p, '{ %s_init(); }' % '_init();  '.join(static_list[p]))
1946         else:
1947             conf.DEFINE('static_decl_%s' % p, '')
1948             conf.DEFINE('static_init_%s' % p, '{}')
1949         if p in shared_list:
1950             for entry in shared_list[p]:
1951                 conf.DEFINE('%s_init' % entry, 'samba_init_module')
1952                 conf.env[shared_env].append('%s' % entry)
1953
1954     conf.SAMBA_CONFIG_H('include/config.h')
1955
1956 def ctags(ctx):
1957     "build 'tags' file using ctags"
1958     import Utils
1959     source_root = os.path.dirname(Utils.g_module.root_path)
1960     cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
1961     print("Running: %s" % cmd)
1962     os.system(cmd)
1963