s3:winbindd: make use of cli_rpc_pipe_open_schannel_with_creds()
[obnox/samba/samba-obnox.git] / source3 / wscript
index 765f761ece376f0088c47b4bb19e0e01f2b20740..bb57db533816f15fd8278f9a3fe504069a001109 100644 (file)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#!/usr/bin/env python
 
 srcdir=".."
 
@@ -23,7 +23,6 @@ def set_options(opt):
                    action="store", dest='shared_modules', default=None)
 
     opt.SAMBA3_ADD_OPTION('winbind')
-    opt.SAMBA3_ADD_OPTION('swat')
     opt.SAMBA3_ADD_OPTION('ads')
     opt.SAMBA3_ADD_OPTION('ldap')
     opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
@@ -41,17 +40,27 @@ def set_options(opt):
     opt.SAMBA3_ADD_OPTION('syslog')
     opt.SAMBA3_ADD_OPTION('automount')
     opt.SAMBA3_ADD_OPTION('aio-support')
+    opt.SAMBA3_ADD_OPTION('dmapi', default=None) # None means autodetection
+    opt.SAMBA3_ADD_OPTION('fam', default=None) # None means autodetection
     opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
+    opt.SAMBA3_ADD_OPTION('libarchive', default=None)
 
-    opt.SAMBA3_ADD_OPTION('cluster-support')
+    opt.SAMBA3_ADD_OPTION('cluster-support', default=None)
 
-    opt.add_option('--with-ctdb-dir',
-                   help=("Directory under which ctdb is installed"),
-                   action="store", dest='ctdb_dir', default=None)
-    opt.add_option('--enable-old-ctdb',
-                  help=("enable building against (too) old version of ctdb (default=false)"),
-                  action="store_true", dest='enable_old_ctdb', default=False)
+    opt.SAMBA3_ADD_OPTION('regedit', default=None)
 
+    opt.SAMBA3_ADD_OPTION('fake-kaserver',
+                          help=("Include AFS fake-kaserver support"), default=False)
+
+    opt.add_option('--with-libcephfs',
+                   help=("Directory under which libcephfs is installed"),
+                   action="store", dest='libcephfs_dir', default=None)
+
+    opt.SAMBA3_ADD_OPTION('glusterfs', with_name="enable", without_name="disable", default=True)
+
+    opt.add_option('--enable-vxfs',
+                  help=("enable support for VxFS (default=no)"),
+                  action="store_true", dest='enable_vxfs', default=False)
 
 
 def configure(conf):
@@ -64,14 +73,11 @@ def configure(conf):
         conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
         conf.env.developer = True
 
-    if Options.options.with_swat:
-        conf.env['build_swat'] = True
-
     if sys.platform != 'openbsd5':
         conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
 
     conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
-    conf.CHECK_HEADERS('linux/falloc.h')
+    conf.CHECK_HEADERS('linux/falloc.h linux/ioctl.h')
 
     conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
     conf.CHECK_FUNCS('strtol strchr strupr chflags')
@@ -80,10 +86,11 @@ def configure(conf):
     conf.CHECK_FUNCS('sigprocmask sigblock sigaction sigset innetgr')
     conf.CHECK_FUNCS('initgroups select poll rdchk getgrnam getgrent pathconf')
     conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups syscall sysconf')
-    conf.CHECK_FUNCS('atexit grantpt fallocate posix_fallocate')
+    conf.CHECK_FUNCS('atexit grantpt posix_openpt fallocate posix_fallocate')
     conf.CHECK_FUNCS('fseeko setluid')
     conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
     conf.CHECK_FUNCS('fdopendir')
+    conf.CHECK_FUNCS('fstatat')
     conf.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
     conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
     conf.CHECK_FUNCS_IN('nanosleep', 'rt')
@@ -92,7 +99,6 @@ def configure(conf):
     conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
     conf.CHECK_FUNCS('shmget')
     conf.CHECK_FUNCS_IN('shm_open', 'rt', checklibc=True)
-    conf.CHECK_FUNCS('gettext dgettext bindtextdomain textdomain bind_textdomain_codeset')
     #FIXME: for some reason this one still fails
     conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
     conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
@@ -100,9 +106,6 @@ def configure(conf):
     conf.CHECK_DECLS('fdatasync', reverse=True)
     conf.CHECK_DECLS('readahead', reverse=True, headers='fcntl.h')
 
-    if conf.CONFIG_SET('HAVE_LONG_LONG'):
-        conf.DEFINE('HAVE_LONGLONG', 1)
-
     if conf.CHECK_CODE('''
 #if defined(HAVE_UNISTD_H)
 #include <unistd.h>
@@ -160,7 +163,123 @@ main() {
 main() {
         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
-        msg="Checking for krenel share modes")
+        msg="Checking for kernel share modes")
+
+    # check for fam libs
+    samba_fam_libs=None
+    check_for_fam=False
+    if Options.options.with_fam is None:
+        check_for_fam=True
+    elif Options.options.with_fam == True:
+        check_for_fam=True
+
+    if check_for_fam and conf.CHECK_HEADERS('fam.h'):
+        if conf.CHECK_FUNCS_IN('FAMOpen2', 'fam'):
+            samba_fam_libs='fam'
+        elif conf.CHECK_FUNCS_IN('FAMOpen2', 'fam C'):
+            samba_fam_libs='fam C'
+        conf.CHECK_TYPE('enum FAMCodes', headers='fam.h',
+            define='HAVE_FAM_H_FAMCODES_TYPEDEF',
+            msg='Checking whether enum FAMCodes is available')
+        conf.CHECK_FUNCS_IN('FAMNoExists', 'fam')
+
+    if samba_fam_libs is not None:
+        conf.DEFINE('SAMBA_FAM_LIBS', samba_fam_libs)
+    else:
+        if Options.options.with_fam == True:
+            conf.fatal('FAM support requested, but no suitable FAM library found')
+        elif check_for_fam:
+            Logs.warn('no suitable FAM library found')
+
+    # check for libarchive (tar command in smbclient)
+    # None means autodetect, True/False means enable/disable
+    conf.env['archive_lib'] = ''
+    if Options.options.with_libarchive is not False:
+        libarchive_mandatory = Options.options.with_libarchive == True
+        Logs.info("Checking for libarchive existence")
+        if conf.CHECK_BUNDLED_SYSTEM('libarchive', minversion='3.1.2'):
+            conf.env['archive_lib'] = 'libarchive'
+        elif libarchive_mandatory:
+            conf.fatal('libarchive support requested, but no suitable pkgconfig found')
+
+    # check for DMAPI libs
+    if Options.options.with_dmapi == False:
+        have_dmapi = False
+    else:
+        have_dmapi = True
+        Logs.info("Checking for DMAPI library existence")
+        samba_dmapi_lib = ''
+        if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dm'):
+            samba_dmapi_lib = 'dm'
+        else:
+            if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'jfsdm'):
+                samba_dmapi_lib = 'jfsdm'
+            else:
+                if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dmapi'):
+                    samba_dmapi_lib = 'dmapi'
+                else:
+                    if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'xdsm'):
+                        samba_dmapi_lib = 'xdsm'
+        # only bother to test headers and compilation when a candidate
+        # library has been found
+        if samba_dmapi_lib == '':
+            have_dmapi = False
+            broken_dmapi = "no suitable DMAPI library found"
+
+        if have_dmapi:
+            conf.CHECK_HEADERS('sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h dmapi.h')
+            conf.CHECK_CODE('''
+#include <time.h>      /* needed by Tru64 */
+#include <sys/types.h> /* needed by AIX */
+#ifdef HAVE_XFS_DMAPI_H
+#include <xfs/dmapi.h>
+#elif defined(HAVE_SYS_DMI_H)
+#include <sys/dmi.h>
+#elif defined(HAVE_SYS_JFSDMAPI_H)
+#include <sys/jfsdmapi.h>
+#elif defined(HAVE_SYS_DMAPI_H)
+#include <sys/dmapi.h>
+#elif defined(HAVE_DMAPI_H)
+#include <dmapi.h>
+#endif
+
+/* This link test is designed to fail on IRI 6.4, but should
+ * succeed on Linux, IRIX 6.5 and AIX.
+ */
+int main(int argc, char **argv)
+{
+       char * version;
+       dm_eventset_t events;
+       /* This doesn't take an argument on IRIX 6.4. */
+       dm_init_service(&version);
+       /* IRIX 6.4 expects events to be a pointer. */
+       DMEV_ISSET(DM_EVENT_READ, events);
+
+       return 0;
+}
+''',
+            'USEABLE_DMAPI_LIBRARY',
+            addmain=False,
+            execute=False,
+            lib=samba_dmapi_lib,
+            msg='Checking whether DMAPI lib '+samba_dmapi_lib+' can be used')
+            if not conf.CONFIG_SET('USEABLE_DMAPI_LIBRARY'):
+                have_dmapi = False
+                broken_dmapi = "no usable DMAPI library found"
+
+    if have_dmapi:
+        Logs.info("Building with DMAPI support.")
+        conf.env['dmapi_lib'] = samba_dmapi_lib
+        conf.DEFINE('USE_DMAPI', 1)
+    else:
+        if Options.options.with_dmapi == False:
+            Logs.info("Building without DMAPI support (--without-dmapi).")
+        elif Options.options.with_dmapi == True:
+            Logs.error("DMAPI support not available: " + broken_dmapi)
+            conf.fatal('DMAPI support requested but not found.');
+        else:
+            Logs.warn("Building without DMAPI support: " + broken_dmapi)
+        conf.env['dmapi_lib'] = ''
 
     # Check for various members of the stat structure
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
@@ -171,18 +290,20 @@ main() {
                                 headers='sys/types.h sys/stat.h unistd.h')
 
     if "HAVE_BLKCNT_T" in conf.env:
-       conf.CHECK_CODE('''
-       return sizeof(blkcnt_t) == 4 ? 0 : 1''',
-               'SIZEOF_BLKCNT_T_4', execute=True,
-               headers='replace.h sys/types.h sys/stat.h unistd.h',
-               msg="Checking whether blkcnt_t is 32 bit")
+        conf.CHECK_CODE('''
+        static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 4)];''',
+                'SIZEOF_BLKCNT_T_4',
+                headers='replace.h sys/types.h sys/stat.h unistd.h',
+                msg="Checking whether blkcnt_t is 32 bit")
 
+    # If sizeof is 4 it can't be 8
     if "HAVE_BLKCNT_T" in conf.env:
-       conf.CHECK_CODE('''
-       return sizeof(blkcnt_t) == 8 ? 0 : 1''',
-               'SIZEOF_BLKCNT_T_8', execute=True,
-               headers='replace.h sys/types.h sys/stat.h unistd.h',
-               msg="Checking whether blkcnt_t is 64 bit")
+        if not conf.CONFIG_SET('SIZEOF_BLKCNT_T_4'):
+            conf.CHECK_CODE('''
+            static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 8)];''',
+                    'SIZEOF_BLKCNT_T_8',
+                    headers='replace.h sys/types.h sys/stat.h unistd.h',
+                    msg="Checking whether blkcnt_t is 64 bit")
 
     # Check for POSIX capability support
     conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
@@ -221,12 +342,28 @@ main() {
 
     # Check if the compiler will optimize out functions
     conf.CHECK_CODE('''
-if (0) {
-    this_function_does_not_exist();
-} else {
-    return 1;
+#include <sys/types.h>
+size_t __unsafe_string_function_usage_here_size_t__(void);
+#define CHECK_STRING_SIZE(d, len) (sizeof(d) != (len) && sizeof(d) != sizeof(char *))
+static size_t push_string_check_fn(void *dest, const char *src, size_t dest_len) {
+       return 0;
+}
+
+#define push_string_check(dest, src, dest_len) \
+    (CHECK_STRING_SIZE(dest, dest_len) \
+    ? __unsafe_string_function_usage_here_size_t__()   \
+    : push_string_check_fn(dest, src, dest_len))
+
+int main(int argc, char **argv) {
+    char outbuf[1024];
+    char *p = outbuf;
+    const char *foo = "bar";
+    p += 31 + push_string_check(p + 31, foo, sizeof(outbuf) - (p + 31 - outbuf));
+    return 0;
 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
-        msg="Checking if the compiler will optimize out functions")
+            addmain=False,
+            add_headers=False,
+            msg="Checking if the compiler will optimize out functions")
 
     # Check if the compiler supports the LL suffix on long long integers
     # AIX needs this
@@ -236,8 +373,8 @@ if (0) {
 
     conf.CHECK_FUNCS('''
 _acl __acl atexit 
-bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
-__closedir crypt16 devnm dgettext dirfd
+ _chdir __chdir chflags chmod _close __close _closedir
+__closedir crypt16 devnm dirfd
 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
 _facl __facl _fchdir
 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
@@ -246,14 +383,14 @@ fsetxattr _fstat __fstat fsync
 futimens futimes __fxstat getauthuid
 getcwd _getcwd __getcwd getdents __getdents getdirentries
 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
-getpwanam getpwent_r getrlimit gettext
+getpwanam getpwent_r getrlimit
 glob grantpt hstrerror initgroups innetgr
 llseek _llseek __llseek _lseek __lseek
 _lstat __lstat lutimes
 __lxstat memalign mknod mlock mlockall munlock munlockall
 _open __open _opendir __opendir
 pathconf poll posix_fallocate
-posix_memalign prctl pread _pread __pread
+posix_memalign pread _pread __pread
 pwrite _pwrite __pwrite
 rdchk _read __read _readdir __readdir
 _seekdir __seekdir
@@ -262,7 +399,7 @@ setmntent setpgid setpriv setsid setuidx
 shmget shm_open sigaction sigblock sigprocmask sigset
 _stat __stat statvfs
 strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctl sysctlbyname
-__sys_llseek syslog _telldir __telldir textdomain timegm
+__sys_llseek syslog _telldir __telldir timegm
 utimensat vsyslog _write __write __xstat
 ''')
 
@@ -289,9 +426,10 @@ utimensat vsyslog _write __write __xstat
         conf.ADD_CFLAGS('-fno-common')
         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
     elif (host_os.rfind('freebsd') > -1):
+        conf.DEFINE('FREEBSD', 1)
         if conf.CHECK_HEADERS('sunacl.h'):
             conf.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
-            conf.CHECK_FUNCS_IN('acl', 'sunacl')
+            conf.CHECK_FUNCS_IN(['acl'], 'sunacl')
         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
     elif (host_os.rfind('irix') > -1):
         conf.DEFINE('IRIX', 1)
@@ -311,35 +449,24 @@ utimensat vsyslog _write __write __xstat
         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
 
     if Options.options.with_acl_support:
-       if (host_os.rfind('sysv5') > -1) and conf.CHECK_FUNCS_IN('sec', 'facl', checklibc=True):
-               Logs.info('Using UnixWare ACLs')
-                conf.DEFINE('HAVE_UNIXWARE_ACLS',1)
-                default_static_modules.extend(TO_LIST('vfs_solarisacl'))
-       elif (host_os.rfind('solaris') > -1) and conf.CHECK_FUNCS_IN('sec', 'facl'):
-               Logs.info('Using solaris ACLs')
-                conf.DEFINE('HAVE_SOLARIS_ACLS',1)
-                default_static_modules.extend(TO_LIST('vfs_solarisacl'))
-       elif (host_os.rfind('hpux') > -1):
+        if (host_os.rfind('hpux') > -1):
                Logs.info('Using HPUX ACLs')
                 conf.DEFINE('HAVE_HPUX_ACLS',1)
                 conf.DEFINE('POSIX_ACL_NEEDS_MASK',1)
                 default_static_modules.extend(TO_LIST('vfs_hpuxacl'))
-       elif (host_os.rfind('irix') > -1):
-               Logs.info('Using IRIX ACLs')
-                conf.DEFINE('HAVE_IRIX_ACLS',1)
-                default_static_modules.extend(TO_LIST('vfs_irixacl'))
        elif (host_os.rfind('aix') > -1):
                Logs.info('Using AIX ACLs')
                 conf.DEFINE('HAVE_AIX_ACLS',1)
-                default_static_modules.extend(TO_LIST('vfs_aixacl'))
-       elif (host_os.rfind('osf') > -1) and conf.CHECK_FUNCS_IN('pacl', 'acl_get_fd'):
-               Logs.info('Using Tru64 ACLs')
-                conf.DEFINE('HAVE_TRU64_ACLS',1)
-                default_static_modules.extend(TO_LIST('vfs_tru64acl'))
+                default_static_modules.extend(TO_LIST('vfs_aixacl vfs_aixacl2'))
         elif (host_os.rfind('darwin') > -1):
-            Logs.warn('ACLs on Dwarwin currently not supported')
+            Logs.warn('ACLs on Darwin currently not supported')
+            conf.fatal("ACL support not available on Darwin/MacOS. "
+                       "Use --without-acl-support for building without "
+                       "ACL support. "
+                       "ACL support is required to change permissions "
+                       "from Windows clients.")
         else:
-            conf.CHECK_FUNCS_IN('acl_get_file', 'acl')
+            conf.CHECK_FUNCS_IN(['acl_get_file'], 'acl')
             if conf.CHECK_CODE('''
 acl_t acl;
 int entry_id;
@@ -358,14 +485,29 @@ return acl_get_perm_np(permset_d, perm);
                         headers='sys/types.h sys/acl.h', link=True,
                         msg="Checking whether acl_get_perm_np() is available")
                 default_static_modules.extend(TO_LIST('vfs_posixacl'))
-
+                conf.CHECK_VARIABLE('ACL_EVERYONE', headers='sys/acl.h')
+            elif conf.CHECK_FUNCS_IN(['facl'], 'sec'):
+                Logs.info('Using solaris or UnixWare ACLs')
+                conf.DEFINE('HAVE_SOLARIS_UNIXWARE_ACLS',1)
+                default_static_modules.extend(TO_LIST('vfs_solarisacl'))
+            elif conf.CHECK_FUNCS_IN(['acl_get_fd'], 'pacl'):
+                Logs.info('Using Tru64 ACLs')
+                conf.DEFINE('HAVE_TRU64_ACLS',1)
+                default_static_modules.extend(TO_LIST('vfs_tru64acl'))
+            else:
+                conf.fatal("ACL support not found. Try installing libacl1-dev "
+                           "or libacl-devel.  "
+                           "Otherwise, use --without-acl-support to build "
+                           "without ACL support. "
+                           "ACL support is required to change permissions from "
+                           "Windows clients.")
 
     if conf.CHECK_FUNCS('dirfd'):
         conf.DEFINE('HAVE_DIRFD_DECL', 1)
 
     conf.CHECK_CODE('struct statfs fsd; fsid_t fsid = fsd.f_fsid; return statfs(".", &fsd);',
                     'HAVE_STATFS_F_FSID',
-                    msg="vfs_fileid: checking for statfs() and struct statfs.f_fsid",
+                    msg="vfs_fileid checking for statfs() and struct statfs.f_fsid",
                     headers='sys/types.h sys/statfs.h',
                     execute=True)
 
@@ -402,13 +544,14 @@ return acl_get_perm_np(permset_d, perm);
             conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
             conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
             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')
-            conf.CHECK_CODE('struct aiocb a; return aio_suspend(&a, 1, NULL);', 'HAVE_AIO_SUSPEND', msg='Checking for aio_suspend', headers='aio.h', lib='aio rt')
+            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')
         if not conf.CONFIG_SET('HAVE_AIO'):
             conf.DEFINE('HAVE_NO_AIO', '1')
     else:
         conf.DEFINE('HAVE_NO_AIO', '1')
 
     if host_os.rfind('linux') > -1:
+       conf.CHECK_FUNCS('eventfd')
        conf.CHECK_FUNCS_IN('io_submit', 'aio')
        conf.CHECK_CODE('''
 struct io_event ioev;
@@ -440,17 +583,17 @@ union {
 msg.msg_control = control_un.control;
 msg.msg_controllen = sizeof(control_un.control);
 ''',
-        'HAVE_MSGHDR_MSG_CONTROL',
+        'HAVE_STRUCT_MSGHDR_MSG_CONTROL',
         msg='Checking if we can use msg_control for passing file descriptors',
         headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
     conf.CHECK_CODE('''
 struct msghdr msg;
 int fd;
-msg.msg_acctrights = (caddr_t) &fd;
-msg.msg_acctrightslen = sizeof(fd);
+msg.msg_accrights = (caddr_t) &fd;
+msg.msg_accrightslen = sizeof(fd);
 ''',
-        'HAVE_MSGHDR_MSG_ACCTRIGHTS',
-        msg='Checking if we can use msg_acctrights for passing file descriptors',
+        'HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS',
+        msg='Checking if we can use msg_accrights for passing file descriptors',
         headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
 
     if Options.options.with_winbind:
@@ -458,7 +601,6 @@ msg.msg_acctrightslen = sizeof(fd);
         conf.DEFINE('WITH_WINBIND', '1')
 
     conf.find_program('awk', var='AWK')
-    conf.find_program('perl', var='PERL')
 
     conf.CHECK_HEADERS('asm/types.h')
 
@@ -557,59 +699,74 @@ msg.msg_acctrightslen = sizeof(fd);
             if conf.CONFIG_SET('HAVE_BER_SOCKBUF_ADD_IO') and \
                     conf.CONFIG_SET('HAVE_LDAP_OPT_SOCKBUF'):
                 conf.DEFINE('HAVE_LDAP_SASL_WRAPPING', '1')
+        else:
+            conf.fatal("LDAP support not found. "
+                       "Try installing libldap2-dev or openldap-devel. "
+                       "Otherwise, use --without-ldap to build without "
+                       "LDAP support. "
+                       "LDAP support is required for the LDAP passdb backend, "
+                       "LDAP idmap backends and ADS. "
+                       "ADS support improves communication with "
+                       "Active Directory domain controllers.")
     else:
         conf.SET_TARGET_TYPE('ldap', 'EMPTY')
         conf.SET_TARGET_TYPE('lber', 'EMPTY')
 
-    if Options.options.with_ads:
-        use_ads=True
+    if Options.options.with_ads == False:
+        use_ads = False
+        use_ads_krb5 = False
+        use_ads_ldap = False
+    else:
+        use_ads = True
+        use_ads_krb5 = True
+        use_ads_ldap = True
         if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
            not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
             Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
             Logs.warn("krb5_mk_req_extended not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
             Logs.warn("krb5_get_host_realm not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
             Logs.warn("krb5_free_host_realm not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
             Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC'):
             Logs.warn("krb5_get_init_creds_opt_alloc not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT'):
             Logs.warn("krb5_get_init_creds_opt_free was not found or was too old in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
             Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM'):
             Logs.warn("krb5_principal_compare_any_realm not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_C_STRING_TO_KEY') and \
            not conf.CONFIG_SET('HAVE_KRB5_STRING_TO_KEY_SALT'):
             Logs.warn("krb5_c_string_to_key not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_PRINCIPAL2SALT') and \
            not conf.CONFIG_SET('HAVE_KRB5_GET_PW_SALT'):
             Logs.warn("no CREATE_KEY_FUNCTIONS detected")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
            not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
             Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
            not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
             Logs.warn("no KT_FREE_FUNCTION detected")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
             Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
 
         # We don't actually use
         # gsskrb5_extract_authz_data_from_sec_context, but it is a
@@ -618,24 +775,47 @@ msg.msg_acctrightslen = sizeof(fd);
         if not conf.CONFIG_SET('HAVE_GSS_GET_NAME_ATTRIBUTE') and \
             not (conf.CONFIG_SET('HAVE_GSSKRB5_EXTRACT_AUTHZ_DATA_FROM_SEC_CONTEXT') and \
                      conf.CONFIG_SET('HAVE_GSS_INQUIRE_SEC_CONTEXT_BY_OID')):
-            Logs.warn("need eiterh gss_get_name_attribute or gsskrb5_extract_authz_data_from_sec_context and gss_inquire_sec_context_by_oid in -lgssapi for PAC support")
-            use_ads=False
+            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")
+            use_ads_krb5 = False
 
         if not conf.CONFIG_SET('HAVE_GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT'):
             Logs.warn("need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support")
-            use_ads=False
+            use_ads_krb5 = False
 
-        if use_ads:
-            conf.DEFINE('WITH_ADS', '1')
+        if use_ads_krb5:
             conf.DEFINE('HAVE_KRB5', '1')
-            if conf.CONFIG_SET('HAVE_LDAP'):
-                conf.env['HAVE_ADS'] = '1'
+            conf.env['HAVE_KRB5'] = '1'
         else:
-            Logs.warn("krb5 libs don't have all features required for Active Directory support")
             conf.undefine('HAVE_KRB5_H')
             conf.undefine('HAVE_GSSAPI_H')
             conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
             conf.undefine('HAVE_GSSAPI_GSSAPI_H')
+            use_ads = False
+
+        if not conf.CONFIG_SET('HAVE_LDAP'):
+            use_ads = False
+            use_ads_ldap = False
+
+    if use_ads:
+        conf.DEFINE('WITH_ADS', '1')
+        conf.env['HAVE_ADS'] = '1'
+        Logs.info("Building with Active Directory support.")
+    elif Options.options.with_ads == False:
+        Logs.info("Building without Active Directory support (--without-ads).")
+    else:
+        if not use_ads_krb5:
+            Logs.warn("Active Directory support not available: krb5 libs don't have all required features")
+        if not use_ads_ldap:
+            Logs.warn("Active Directory support not available: LDAP support is not available.")
+        if Options.options.with_ads:
+            conf.fatal("Active Directory support not found. Use --without-ads "
+                       "for building without Active Directory support. "
+                       "ADS support improves communication with "
+                       "Active Directory domain controllers.")
+        else:
+            # this is the auto-mode case
+            Logs.warn("Building without Active Directory support.")
+
 
     if Options.options.with_utmp:
         conf.env.with_utmp = True
@@ -659,17 +839,21 @@ msg.msg_acctrightslen = sizeof(fd);
                                     define='HAVE_UT_UT_PID')
         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_exit.e_exit', headers='utmp.h',
                                     define='HAVE_UT_UT_EXIT')
-        conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr_v6', headers='utmp.h',
-                                    define='HAVE_UT_UT_ADDR_V6')
-        conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_addr', headers='utmp.h',
-                                    define='HAVE_UT_UT_ADDR')
         conf.CHECK_STRUCTURE_MEMBER('struct utmpx', 'ut_syslen', headers='utmpx.h',
                                     define='HAVE_UX_UT_SYSLEN')
         conf.CHECK_CODE('struct utmp utarg; struct utmp *utreturn; utreturn = pututline(&utarg);',
                         'PUTUTLINE_RETURNS_UTMP', headers='utmp.h',
                         msg="Checking whether pututline returns pointer")
+        conf.CHECK_SIZEOF(['((struct utmp *)NULL)->ut_line'], headers='utmp.h',
+                          define='SIZEOF_UTMP_UT_LINE', critical=False)
+        if not conf.CONFIG_SET('SIZEOF_UTMP_UT_LINE'):
+            conf.env.with_utmp = False
+        elif int(conf.env.SIZEOF_UTMP_UT_LINE) < 15:
+            conf.env.with_utmp = False
         if conf.env.with_utmp:
             conf.DEFINE('WITH_UTMP', 1)
+        else:
+            Logs.warn("--with-utmp but utmp support not sufficient")
 
     if Options.options.with_avahi:
         conf.env.with_avahi = True
@@ -762,6 +946,9 @@ int i; i = PAM_RADIO_TYPE;
             conf.DEFINE('WITH_PAM', 1)
             conf.DEFINE('WITH_PAM_MODULES', 1)
 
+    if Options.options.with_pam_smbpass:
+        conf.env.with_pam_smbpass = True
+
     seteuid = False
 
 #
@@ -1274,218 +1461,16 @@ main() {
             conf.DEFINE('WITH_QUOTAS', '1')
 
     #
-    # checking for clustering extensions (CTDB)
+    # cluster support (CTDB)
     #
     if not Options.options.with_cluster_support:
-        have_cluster_support = False
-
+        Logs.info("building without cluster support (--without-cluster-support)")
+        conf.env.with_ctdb = False
     else:
-
-        if Options.options.ctdb_dir:
-            conf.ADD_EXTRA_INCLUDES(Options.options.ctdb_dir + '/include')
-
-        srcdir = os.path.realpath(conf.srcdir)
-        if 'EXTRA_INCLUDES' in conf.env:
-            includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/')
-        else:
-            includes = ''
-
-        have_cluster_support = True
-        ctdb_broken = ""
-
-        conf.CHECK_CODE('''
-            #define NO_CONFIG_H
-            #include "replace.h"
-            #include "system/wait.h"
-            #include "system/network.h"
-            #define private #error __USED_RESERVED_WORD_private__
-            #include <talloc.h>
-            #include <tdb.h>
-            #include <ctdb.h>
-
-            int main(void)
-            {
-                return 0;
-            }
-            ''',
-            'HAVE_CTDB_H',
-            addmain=False,
-            includes=includes,
-            msg='Checking for header ctdb.h')
-
-        if not conf.CONFIG_SET('HAVE_CTDB_H'):
-            have_cluster_support = False
-            ctdb_broken = "ctdb.h is required for cluster support"
-
-        if have_cluster_support:
-            conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #define private #error __USED_RESERVED_WORD_private__
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                    return 0;
-                }
-                ''',
-                'HAVE_CTDB_PRIVATE_H',
-                addmain=False,
-                includes=includes,
-                msg='Checking for header ctdb_private.h')
-
-            if not conf.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
-                have_cluster_support = False
-                ctdb_broken = "ctdb_private.h is required for cluster support"
-
-        if have_cluster_support:
-            conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                   int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
-                   return 0;
-                }
-                ''',
-                'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
-                addmain=False,
-                includes=includes,
-                msg='Checking for transaction support (TRANS3_COMMIT control)')
-
-            if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
-                have_cluster_support = False
-                ctdb_broken = "ctdb transaction support missing or too old"
-
-        if have_cluster_support:
-            conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                    int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
-                    return 0;
-                }
-                ''',
-                'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
-                addmain=False,
-                includes=includes,
-                msg='Checking for SCHEDULE_FOR_DELETION control')
-
-            if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
-                if not Options.options.enable_old_ctdb:
-                    have_cluster_support = False
-                    ctdb_broken = "SCHEDULE_FOR_DELETION control missing"
-                else:
-                    Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
-
-        if have_cluster_support:
-            conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                    struct ctdb_control_tcp _x;
-                    return 0;
-                }
-                ''',
-                'HAVE_STRUCT_CTDB_CONTROL_TCP',
-                addmain=False,
-                includes=includes,
-                msg='Checking for ctdb ipv4 support')
-
-            if not conf.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
-                have_cluster_support = False
-                ctdb_broken = "missing struct ctdb_control_tcp"
-
-        if have_cluster_support:
-            conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                    struct ctdb_control_tcp_addr _x;
-                    return 0;
-                }
-                ''',
-                'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
-                addmain=False,
-                includes=includes,
-                msg='Checking for ctdb ipv6 support')
-
-        if have_cluster_support:
-            conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                    int i = (int)CTDB_CONTROL_CHECK_SRVIDS;
-                    return 0;
-                }
-                ''',
-                'HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL',
-                addmain=False,
-                includes=includes,
-                msg='Checking for CHECK_SRVIDS control')
-
-            if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL'):
-                if not Options.options.enable_old_ctdb:
-                    have_cluster_support = False
-                    ctdb_broken = "CHECK_SRVIDS control missing"
-                else:
-                    Logs.warn("ignoring missing CHECK_SRVIDS control (--enable-old-ctdb)")
-
-    if have_cluster_support:
         Logs.info("building with cluster support")
-        conf.DEFINE('CLUSTER_SUPPORT', 1);
-    else:
-        if not Options.options.with_cluster_support:
-            Logs.info("building without cluster support")
-        else:
-            Logs.warn("building without cluster support: " + ctdb_broken)
-        conf.undefine('CLUSTER_SUPPORT')
-
-
+        conf.env['CTDB_CFLAGS'] = '-DCLUSTER_SUPPORT=1'
+        conf.env['CTDB_INCLUDE'] = conf.srcdir + '/ctdb/include'
+        conf.env.with_ctdb = True
 
     conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
                     'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
@@ -1501,38 +1486,6 @@ main() {
     if Options.options.with_profiling_data:
         conf.DEFINE('WITH_PROFILE', 1);
 
-    PTHREAD_CFLAGS='error'
-    PTHREAD_LDFLAGS='error'
-
-    if PTHREAD_LDFLAGS == 'error':
-        if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
-            PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
-            PTHREAD_LDFLAGS='-lpthread'
-    if PTHREAD_LDFLAGS == 'error':
-        if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
-            PTHREAD_CFLAGS='-D_THREAD_SAFE'
-            PTHREAD_LDFLAGS='-lpthreads'
-    if PTHREAD_LDFLAGS == 'error':
-        if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
-            PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread'
-            PTHREAD_LDFLAGS='-pthread'
-    if PTHREAD_LDFLAGS == 'error':
-        if conf.CHECK_FUNCS('pthread_attr_init'):
-            PTHREAD_CFLAGS='-D_REENTRANT'
-            PTHREAD_LDFLAGS='-lpthread'
-    # especially for HP-UX, where the CHECK_FUNC macro fails to test for
-    # pthread_attr_init. On pthread_mutex_lock it works there...
-    if PTHREAD_LDFLAGS == 'error':
-        if conf.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
-            PTHREAD_CFLAGS='-D_REENTRANT'
-            PTHREAD_LDFLAGS='-lpthread'
-
-    if PTHREAD_CFLAGS != 'error' and PTHREAD_LDFLAGS != 'error':
-        conf.ADD_CFLAGS(PTHREAD_CFLAGS)
-        conf.ADD_LDFLAGS(PTHREAD_LDFLAGS)
-        conf.CHECK_HEADERS('pthread.h')
-        conf.DEFINE('HAVE_PTHREAD', '1')
-
     if Options.options.with_pthreadpool:
         if conf.CONFIG_SET('HAVE_PTHREAD'):
             conf.DEFINE('WITH_PTHREADPOOL', '1')
@@ -1543,6 +1496,70 @@ main() {
     if conf.CHECK_HEADERS('gpfs_gpl.h'):
         conf.DEFINE('HAVE_GPFS', '1')
 
+    if (conf.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
+       conf.CHECK_DECLS('FS_IOC_GETFLAGS FS_COMPR_FL', headers='linux/fs.h')):
+           conf.DEFINE('HAVE_LINUX_IOCTL', '1')
+
+    conf.env['CCFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64"
+    if Options.options.libcephfs_dir:
+        conf.env['CPPPATH_CEPHFS'] = Options.options.libcephfs_dir + '/include'
+        conf.env['LIBPATH_CEPHFS'] = Options.options.libcephfs_dir + '/lib'
+
+    if conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and conf.CHECK_LIB('cephfs'):
+        conf.DEFINE('HAVE_CEPH', '1')
+
+    if Options.options.with_glusterfs:
+        conf.check_cfg(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs',
+                       msg='Checking for glusterfs-api >= 4', uselib_store="GFAPI")
+        conf.CHECK_HEADERS('api/glfs.h', lib='gfapi')
+        conf.CHECK_LIB('gfapi', shlib=True)
+
+        if conf.CONFIG_SET('HAVE_API_GLFS_H'):
+            conf.DEFINE('HAVE_GLUSTERFS', '1')
+        else:
+            conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
+            conf.undefine('HAVE_GLUSTERFS')
+    else:
+        conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
+        conf.undefine('HAVE_GLUSTERFS')
+
+    if Options.options.enable_vxfs:
+       conf.DEFINE('HAVE_VXFS', '1')
+
+    if conf.check_cfg(package='dbus-1', args='--cflags --libs',
+                      msg='Checking for dbus', uselib_store="DBUS-1"):
+        if (conf.CHECK_HEADERS('dbus/dbus.h', lib='dbus-1')
+                                      and conf.CHECK_LIB('dbus-1', shlib=True)):
+            conf.DEFINE('HAVE_DBUS', '1')
+
+    conf.env.build_regedit = False
+    if not Options.options.with_regedit == False:
+        conf.PROCESS_SEPARATE_RULE('system_ncurses')
+        if conf.CONFIG_SET('HAVE_NCURSES'):
+            conf.env.build_regedit = True
+
+    if conf.env.build_regedit:
+        Logs.info("building regedit")
+    else:
+        if Options.options.with_regedit == False:
+            Logs.info("not building regedit (--without-regedit)")
+        elif Options.options.with_regedit == True:
+            Logs.error("ncurses not available, cannot build regedit")
+            conf.fatal("ncurses not available, but --with-regedit was specified")
+        else:
+            Logs.info("ncurses not available, not building regedit")
+
+    conf.CHECK_FUNCS_IN('DES_pcbc_encrypt', 'crypto')
+    if Options.options.with_fake_kaserver == True:
+        conf.CHECK_HEADERS('afs/param.h afs/stds.h', together=True)
+        conf.CHECK_HEADERS('afs/param.h afs/stds.h', together=True)
+        if (conf.CONFIG_SET('HAVE_AFS_PARAM_H') and conf.CONFIG_SET('HAVE_AFS_STDS_H') and conf.CONFIG_SET('HAVE_DES_PCBC_ENCRYPT')):
+            conf.DEFINE('WITH_FAKE_KASERVER', '1')
+        else:
+            conf.fatal('AFS headers not available, but --with-fake-kaserver was specified')
+
+
+
     default_static_modules.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
                                       auth_sam auth_unix auth_winbind auth_wbc
                                       auth_domain auth_builtin vfs_default
@@ -1555,10 +1572,13 @@ main() {
                                       auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
                                       vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
                                       vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
-                                     vfs_media_harmony
+                                     vfs_media_harmony vfs_fruit
+                                     vfs_commit
+                                     vfs_worm
                                       vfs_crossrename vfs_linux_xfs_sgid
                                       vfs_time_audit idmap_autorid idmap_tdb2
-                                      idmap_rid idmap_hash'''))
+                                      idmap_ad
+                                      idmap_rid idmap_hash idmap_rfc2307'''))
 
     if Options.options.developer:
         default_static_modules.extend(TO_LIST('charset_weird'))
@@ -1567,7 +1587,7 @@ main() {
         default_shared_modules.extend(TO_LIST('auth_skel pdb_test'))
 
     if Options.options.enable_selftest or Options.options.developer:
-        default_shared_modules.extend(TO_LIST('vfs_fake_acls'))
+       default_shared_modules.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr'))
         
 
     if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
@@ -1582,7 +1602,7 @@ main() {
     if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
         default_shared_modules.extend(TO_LIST('vfs_fileid'))
 
-    if (conf.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
+    if (conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS')):
         default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
 
     if Options.options.with_pthreadpool:
@@ -1595,7 +1615,7 @@ main() {
         default_shared_modules.extend(TO_LIST('vfs_aio_linux'))
 
     if conf.CONFIG_SET('HAVE_LDAP'):
-        default_static_modules.extend(TO_LIST('pdb_ldap idmap_ldap'))
+        default_static_modules.extend(TO_LIST('pdb_ldapsam idmap_ldap'))
 
     if conf.CONFIG_SET('DARWINOS'):
         default_static_modules.extend(TO_LIST('charset_macosxfs'))
@@ -1603,9 +1623,40 @@ main() {
     if conf.CONFIG_SET('HAVE_GPFS'):
        default_shared_modules.extend(TO_LIST('vfs_gpfs'))
 
+    if conf.CONFIG_SET('HAVE_LINUX_IOCTL'):
+       default_shared_modules.extend(TO_LIST('vfs_btrfs'))
+
+    if conf.CONFIG_SET('SAMBA_FAM_LIBS'):
+        default_shared_modules.extend(TO_LIST('vfs_notify_fam'))
+
+    if conf.CONFIG_SET("HAVE_CEPH"):
+        default_shared_modules.extend(TO_LIST('vfs_ceph'))
+
+    if conf.CONFIG_SET('HAVE_GLUSTERFS'):
+        default_shared_modules.extend(TO_LIST('vfs_glusterfs'))
+
+    if conf.CONFIG_SET('HAVE_VXFS'):
+        default_shared_modules.extend(TO_LIST('vfs_vxfs'))
+
+    if conf.CONFIG_SET('HAVE_DBUS'):
+       default_shared_modules.extend(TO_LIST('vfs_snapper'))
+
     explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
     explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
 
+    def replace_list_item(lst, item, value):
+        try:
+            idx = lst.index(item)
+            lst[idx] = value
+        except:
+            pass
+    # PDB module file name should have the same name as module registers itself
+    # In Autoconf build we export LDAP passdb module as ldapsam but WAF build
+    # was always exporting pdb_ldap. In order to support existing packages
+    # allow referring to pdb_ldapsam as pdb_ldap but use proper name internally.
+    replace_list_item(explicit_shared_modules, 'pdb_ldap', 'pdb_ldapsam')
+    replace_list_item(explicit_static_modules, 'pdb_ldap', 'pdb_ldapsam')
+
     final_static_modules = default_static_modules
     final_shared_modules = default_shared_modules
 
@@ -1618,6 +1669,12 @@ main() {
             final_static_modules.remove(m)
         final_shared_modules.append(m)
 
+    if ("auth_domain" not in final_static_modules) or \
+            ("auth_builtin" not in final_static_modules) or \
+            ("auth_sam" not in final_static_modules) or \
+            ("auth_winbind" not in final_static_modules):
+        raise Utils.WafError('These auth modules MUST be configured as static modules: auth_domain, auth_builtin, auth_sam, auth_winbind')
+
     conf.env['static_modules'] = final_static_modules
     conf.env['shared_modules'] = final_shared_modules