tests/krb5: Calculate correct gMSA password to fix flapping test
[samba.git] / source3 / wscript
index 1e1fa970d8e85072742ba1ecd60ad805978a99d8..4048ec5aad50c4be3958e53b7c6f4418e8af4301 100644 (file)
@@ -13,7 +13,6 @@ import build.charset
 from wafsamba import samba_utils
 from samba_utils import TO_LIST
 import samba3
-from waflib.Tools import bison
 
 default_prefix = Options.default_prefix = '/usr/local/samba'
 
@@ -44,7 +43,7 @@ def options(opt):
 # ------------------
 #
 # Most of the calls to opt.samba_add_onoff_option() implicitly
-# or explicity use default=True
+# or explicitly use default=True
 #
 # To assist users and distributors to build Samba with the full feature
 # set, the build system will abort if our dependent libraries and their
@@ -63,7 +62,6 @@ def options(opt):
 
     opt.samba_add_onoff_option('winbind')
     opt.samba_add_onoff_option('ads')
-    opt.samba_add_onoff_option('ldap')
     opt.samba_add_onoff_option('cups', with_name="enable", without_name="disable")
     opt.samba_add_onoff_option('iprint', with_name="enable", without_name="disable")
     opt.samba_add_onoff_option('pam')
@@ -73,7 +71,6 @@ def options(opt):
     opt.samba_add_onoff_option('avahi', with_name="enable", without_name="disable")
     opt.samba_add_onoff_option('iconv')
     opt.samba_add_onoff_option('acl-support')
-    opt.samba_add_onoff_option('dnsupdate')
     opt.samba_add_onoff_option('syslog')
     opt.samba_add_onoff_option('automount')
     opt.samba_add_onoff_option('dmapi', default=None) # None means autodetection
@@ -102,6 +99,7 @@ def options(opt):
 
     # default = None means autodetection
     opt.samba_add_onoff_option('spotlight', with_name="enable", without_name="disable", default=None)
+    opt.samba_add_onoff_option('wsp', with_name="enable", without_name="disable", default=True)
 
 def configure(conf):
     default_static_modules = []
@@ -110,10 +108,6 @@ def configure(conf):
     forced_static_modules = []
     forced_shared_modules = []
 
-    if Options.options.developer:
-        conf.ADD_CFLAGS('-DDEVELOPER -DDEBUG_PASSWORD')
-        conf.env.developer = True
-
     if sys.platform != 'openbsd5':
         conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
 
@@ -126,7 +120,7 @@ def configure(conf):
     conf.CHECK_HEADERS('linux/falloc.h linux/ioctl.h')
 
     conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod mknodat')
-    conf.CHECK_FUNCS('strtol strchr strupr chflags')
+    conf.CHECK_FUNCS('strtol strchr strupr chflags fchflags')
     conf.CHECK_FUNCS('getrlimit fsync setpgid')
     conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
     conf.CHECK_FUNCS('innetgr')
@@ -136,13 +130,12 @@ def configure(conf):
     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 clearenv strcasecmp fcvt fcvtl')
+    conf.CHECK_FUNCS('getpwent_r setenv clearenv strcasecmp')
     conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
-    conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
+    conf.CHECK_FUNCS('lutimes utimensat futimens')
     conf.CHECK_FUNCS('mlock munlock mlockall munlockall')
     conf.CHECK_FUNCS('memalign posix_memalign hstrerror')
-    conf.CHECK_FUNCS_IN('yp_get_default_domain', 'nsl')
+    conf.CHECK_FUNCS('getdomainname')
     conf.CHECK_FUNCS_IN('dn_expand _dn_expand __dn_expand', 'resolv')
     conf.CHECK_FUNCS_IN('dn_expand', 'inet')
     conf.CHECK_DECLS('readahead', reverse=True, headers='fcntl.h')
@@ -165,44 +158,9 @@ long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
         if conf.env.HAVE_SYS_INOTIFY_H:
            conf.DEFINE('HAVE_INOTIFY', 1)
 
-    # Check for kernel change notify support
-    conf.CHECK_CODE('''
-#ifndef F_NOTIFY
-#define F_NOTIFY 1026
-#endif
-main() {
-        exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
-}''', 'HAVE_KERNEL_CHANGE_NOTIFY', addmain=False, execute=True,
-        headers='fcntl.h signal.h',
-        msg="Checking for kernel change notify support")
-
     # Check for Linux kernel oplocks
-    conf.CHECK_CODE('''
-#include <sys/types.h>
-#include <fcntl.h>
-#include <signal.h>
-#ifndef F_GETLEASE
-#define F_GETLEASE 1025
-#endif
-main() {
-        exit(fcntl(open("/tmp", O_RDONLY), F_GETLEASE, 0) == -1 ?  1 : 0);
-}''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
-        msg="Checking for Linux kernel oplocks")
-
-    # Check for kernel share modes
-    conf.CHECK_CODE('''
-#include <sys/types.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/file.h>
-#ifndef LOCK_MAND
-#define LOCK_MAND        32
-#define LOCK_READ        64
-#endif
-main() {
-        exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
-}''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
-        msg="Checking for kernel share modes")
+    if conf.CHECK_DECLS('F_SETLEASE', headers='linux/fcntl.h', reverse=True):
+        conf.DEFINE('HAVE_KERNEL_OPLOCKS_LINUX', 1)
 
     # check for fam libs
     samba_fam_libs=None
@@ -407,20 +365,17 @@ int main(int argc, char **argv) {
 DNSServiceRegister
 atexit
 chflags
+fchflags
 chmod
 crypt16
 devnm
-dirfd
 endmntent
 execl
 fchmod
 fchown
-fcvt
-fcvtl
 fseeko
 fsync
 futimens
-futimes
 getauthuid
 getcwd
 getgrent
@@ -527,11 +482,11 @@ vsyslog
                 Logs.info('Using HPUX ACLs')
                 conf.DEFINE('HAVE_HPUX_ACLS',1)
                 conf.DEFINE('POSIX_ACL_NEEDS_MASK',1)
-                default_static_modules.extend(['vfs_hpuxacl'])
+                required_static_modules.extend(['vfs_hpuxacl'])
         elif (host_os.rfind('aix') > -1):
                 Logs.info('Using AIX ACLs')
                 conf.DEFINE('HAVE_AIX_ACLS',1)
-                default_static_modules.extend(['vfs_aixacl', 'vfs_aixacl2'])
+                required_static_modules.extend(['vfs_aixacl', 'vfs_aixacl2'])
         elif (host_os.rfind('darwin') > -1):
             Logs.warn('ACLs on Darwin currently not supported')
             conf.fatal("ACL support not available on Darwin/MacOS. "
@@ -564,11 +519,7 @@ return acl_get_perm_np(permset_d, perm);
             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(['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(['vfs_tru64acl'])
+                required_static_modules.extend(['vfs_solarisacl'])
             else:
                 conf.fatal("ACL support not found. Try installing libacl1-dev "
                            "or libacl-devel.  "
@@ -648,19 +599,19 @@ msg.msg_accrightslen = sizeof(fd);
     conf.CHECK_HEADERS('asm/types.h')
 
     conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
-                    headers='unistd.h sys/types.h',
+                    headers='sys/sysmacros.h unistd.h sys/types.h',
                     msg="Checking for major macro")
 
     conf.CHECK_CODE('dev_t dev; int i = minor(dev); return 0', "HAVE_DEVICE_MINOR_FN",
-                    headers='unistd.h sys/types.h',
+                    headers='sys/sysmacros.h unistd.h sys/types.h',
                     msg="Checking for minor macro")
 
     conf.CHECK_STRUCTURE_MEMBER('struct dirent', 'd_off',
                                 headers='unistd.h sys/types.h dirent.h',
                                 define='HAVE_DIRENT_D_OFF')
 
-    if (conf.CONFIG_SET('HAVE_YP_GET_DEFAULT_DOMAIN')):
-           conf.DEFINE('HAVE_NETGROUP', '1')
+    if (conf.CONFIG_SET('HAVE_GETDOMAINNAME')):
+        conf.DEFINE('HAVE_NETGROUP', '1')
 
     # Look for CUPS
     if Options.options.with_cups:
@@ -692,53 +643,6 @@ msg.msg_accrightslen = sizeof(fd);
     if Options.options.with_automount:
         conf.DEFINE('WITH_AUTOMOUNT', '1')
 
-    # Check for LDAP
-    if Options.options.with_ldap:
-        conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
-        conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
-        conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
-        conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
-
-        # if we LBER_OPT_LOG_PRINT_FN we can intercept ldap logging and print it out
-        # for the samba logs
-        conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
-                            define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
-
-        conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
-        conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
-
-        # Check if ldap_set_rebind_proc() takes three arguments
-        if conf.CHECK_CODE('ldap_set_rebind_proc(0, 0, 0)',
-                           'LDAP_SET_REBIND_PROC_ARGS',
-                           msg="Checking whether ldap_set_rebind_proc takes 3 arguments",
-                           headers='ldap.h lber.h', link=False):
-            conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '3')
-        else:
-            conf.DEFINE('LDAP_SET_REBIND_PROC_ARGS', '2')
-
-        # last but not least, if ldap_init() exists, we want to use ldap
-        if conf.CONFIG_SET('HAVE_LDAP_INIT') and conf.CONFIG_SET('HAVE_LDAP_H'):
-            conf.DEFINE('HAVE_LDAP', '1')
-            conf.DEFINE('LDAP_DEPRECATED', '1')
-            conf.env['HAVE_LDAP'] = '1'
-            # if ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF are available, we can add
-            # SASL wrapping hooks
-            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 == False:
         use_ads = False
         use_ads_krb5 = False
@@ -819,13 +723,13 @@ msg.msg_accrightslen = sizeof(fd);
             conf.undefine('HAVE_GSSAPI_GSSAPI_H')
             use_ads = False
 
-        if not conf.CONFIG_SET('HAVE_LDAP'):
+        if not conf.CONFIG_SET('HAVE_LDAP_TRANSPORT_WRAPPING'):
+            Logs.warn("need ber_sockbuf_add_io() and LDAP_OPT_SOCKBUF for SASL and TLS support")
             use_ads = False
             use_ads_ldap = False
 
     if use_ads:
-        conf.DEFINE('WITH_ADS', '1')
-        conf.env['HAVE_ADS'] = '1'
+        conf.DEFINE('HAVE_ADS', '1')
         Logs.info("Building with Active Directory support.")
         # these have broken dependencies
         forced_shared_modules.extend(['idmap_ad', 'idmap_rfc2307'])
@@ -852,7 +756,7 @@ msg.msg_accrightslen = sizeof(fd);
     if Options.options.with_utmp:
         conf.env.with_utmp = True
         if not conf.CHECK_HEADERS('utmp.h'): conf.env.with_utmp = False
-        conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx getutxent')
+        conf.CHECK_FUNCS('pututline pututxline updwtmp updwtmpx getutmpx')
         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
                                     define='HAVE_UT_UT_NAME')
         conf.CHECK_STRUCTURE_MEMBER('struct utmp', 'ut_user', headers='utmp.h',
@@ -1093,11 +997,6 @@ syscall(SYS_setgroups32, 0, NULL);
                                 execute=True,
                                 mandatory=True,
                                 msg="Checking whether setuidx is available")
-    if Options.options.with_dnsupdate:
-        if not conf.CONFIG_SET('HAVE_KRB5'):
-            Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
-        else:
-            conf.DEFINE('WITH_DNS_UPDATES', 1)
     # valgrind.h or valgrind/valgrind.h is checked in lib/replace/wscript
     if Options.options.developer:
         if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
@@ -1135,7 +1034,7 @@ syscall(SYS_setgroups32, 0, NULL);
 
 #define DATA "ofdtest.fcntl"
 
-int main() {
+int main(void) {
         struct flock lck = {
            .l_whence = SEEK_SET,
            .l_type = F_WRLCK,
@@ -1244,7 +1143,7 @@ err:
 
 int main(void)
 {
-        uint64_t *hint, get_hint;
+        uint64_t hint, get_hint;
         int fd;
 
         fd = open(DATA, O_RDONLY | O_CREAT | O_EXCL);
@@ -1252,8 +1151,8 @@ int main(void)
             goto err;
         }
 
-        *hint = RWH_WRITE_LIFE_SHORT;
-        int ret = fcntl(fd, F_SET_RW_HINT, hint);
+        hint = RWH_WRITE_LIFE_SHORT;
+        int ret = fcntl(fd, F_SET_RW_HINT, &hint);
         if (ret == -1) {
             goto err;
         }
@@ -1267,8 +1166,8 @@ int main(void)
             goto err;
         }
 
-        *hint = RWH_WRITE_LIFE_EXTREME;
-        ret = fcntl(fd, F_SET_FILE_RW_HINT, hint);
+        hint = RWH_WRITE_LIFE_EXTREME;
+        ret = fcntl(fd, F_SET_FILE_RW_HINT, &hint);
         if (ret == -1) {
             goto err;
         }
@@ -1293,7 +1192,7 @@ err:
             'HAVE_RW_HINTS',
             addmain=False,
             execute=True,
-            msg="Checking whether fcntl supports setting/geting hints")
+            msg="Checking whether fcntl supports setting/getting hints")
 
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
                                 define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
@@ -1364,7 +1263,7 @@ syscall(SYS_initgroups, 16, NULL, NULL, 0);
 
     if conf.CHECK_CODE('''
 #include <time.h>
-main() {
+int main(void) {
         struct tm *tm;
         if (sizeof(time_t) == 8) {
                 time_t max_time = 0x7fffffffffffffffll;
@@ -1395,7 +1294,7 @@ main() {
 #if defined(HAVE_SYS_SYSMACROS_H)
 #include <sys/sysmacros.h>
 #endif
-main() { dev_t dev = makedev(1,2); return 0; }
+int main(void) { dev_t dev = makedev(1,2); return 0; }
 ''',
         'HAVE_MAKEDEV',
         addmain=False,
@@ -1405,12 +1304,13 @@ main() { dev_t dev = makedev(1,2); return 0; }
 #include <stdio.h>
 #include <limits.h>
 #include <signal.h>
+#include <stdlib.h>
 
 void exit_on_core(int ignored) {
         exit(1);
 }
 
-main() {
+int main(void) {
         char *newpath;
         signal(SIGSEGV, exit_on_core);
         newpath = realpath("/tmp", NULL);
@@ -1428,6 +1328,12 @@ main() {
                     addmain=False,
                     execute=True)
 
+    conf.CHECK_CODE('''#include "../tests/readlink.c"''',
+                    'HAVE_BROKEN_READLINK',
+                    msg='Checking for readlink breakage',
+                    addmain=False,
+                    execute=True)
+
     conf.SET_TARGET_TYPE('sendfile', 'EMPTY')
     conf.CHECK_LIB('sendfile')
     if not Options.options.with_sendfile_support == False:
@@ -1561,9 +1467,9 @@ main() {
     # Check for getcwd allowing a NULL arg.
     conf.CHECK_CODE('''
 #include <unistd.h>
-main() {
+int main(void) {
         char *s = getcwd(NULL,0);
-        exit(s != NULL ?  0 : 1);
+        return s != NULL ?  0 : 1;
 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
         msg="getcwd takes a NULL argument")
 
@@ -1603,7 +1509,7 @@ main() {
                 execute=False,
                 local_include=False)
 
-        # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
+        # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struct dqblk
         conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define='HAVE_DQB_FSOFTLIMIT',
                                 headers='sys/quota.h')
         #darwin style quota bytecount
@@ -1691,18 +1597,6 @@ main() {
                     define='HAVE_UNSHARE_CLONE_FS',
                     msg='for Linux unshare(CLONE_FS)')
 
-    # Check for mallinfo
-    conf.CHECK_CODE('''
-    struct mallinfo mi;
-    int tmp;
-
-    mi = mallinfo();
-    tmp = mi.arena + mi.ordblks + mi.smblks + mi.hblks +
-          mi.hblkhd + mi.usmblks + mi.fsmblks +  mi.uordblks +
-          mi.fordblks + mi.keepcost;
-    return tmp;
-    ''', 'HAVE_MALLINFO', msg="Checking for mallinfo()", headers='malloc.h')
-
     #
     # cluster support (CTDB)
     #
@@ -1714,11 +1608,6 @@ main() {
         conf.env.with_ctdb = True
         conf.DEFINE('CLUSTER_SUPPORT', 1)
 
-    conf.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
-                    'SEEKDIR_RETURNS_VOID',
-                    headers='sys/types.h dirent.h',
-                    msg='Checking whether seekdir returns void')
-
     if Options.options.with_profiling_data:
         conf.DEFINE('WITH_PROFILE', 1);
         conf.CHECK_FUNCS('getrusage', headers="sys/time.h sys/resource.h")
@@ -1740,6 +1629,22 @@ main() {
             conf.CHECK_FUNCS_IN('ceph_statx', 'cephfs',
                                 headers='cephfs/libcephfs.h')):
             conf.DEFINE('HAVE_CEPH', '1')
+            conf.CHECK_FUNCS_IN('ceph_select_filesystem', 'cephfs',
+                                headers='cephfs/libcephfs.h')
+            conf.DEFINE('HAVE_MANDATORY_CEPH_API', '1')
+            for api in ['ceph_mkdirat', 'ceph_openat', 'ceph_unlinkat',
+                        'ceph_symlinkat', 'ceph_readlinkat', 'ceph_statxat',
+                        'ceph_fdopendir']:
+                if not conf.CHECK_FUNCS_IN(api, 'cephfs',
+                                           headers='cephfs/libcephfs.h'):
+                    conf.undefine('HAVE_MANDATORY_CEPH_API')
+            if not conf.env.HAVE_MANDATORY_CEPH_API:
+                Logs.warn("Installed Ceph version support is at the verge of "
+                          "deprecation due to the absence of some mandatory "
+                          "libcephfs APIs. This warning there shall result in "
+                          "disabling the Ceph VFS module altogether with the "
+                          "next major Samba version. It is highly recommended "
+                          "to update to a more recent/active version of Ceph.")
         else:
             Logs.warn('''Ceph support disabled due to --without-acl-support
                       or lack of ceph_statx support''')
@@ -1766,6 +1671,13 @@ main() {
         conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 7.6" --cflags --libs',
                        msg='Checking for glusterfs-api >= 7.6',
                        uselib_store="GFAPI_VER_7_6")
+        conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 7.9" --cflags --libs',
+                       msg='Checking for glusterfs-api >= 7.9',
+                       uselib_store="GFAPI_VER_7_9")
+        conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 7.11" --cflags --libs',
+                       msg='Checking for glusterfs-api >= 7.11',
+                       uselib_store="GFAPI_VER_7_11")
+
     else:
         conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
         conf.undefine('HAVE_GLUSTERFS')
@@ -1779,6 +1691,19 @@ main() {
                                       and conf.CHECK_LIB('uring', shlib=True)):
             conf.CHECK_FUNCS_IN('io_uring_ring_dontfork', 'uring',
                                 headers='liburing.h')
+            # There are a few distributions, which
+            # don't seem to have linux/openat2.h available
+            # during the liburing build, which means liburing/compat.h
+            # defines struct open_how directly instead of including
+            # linux/openat2.h, while linux/openat2.h is
+            # available on the installed system, which cause problems
+            # when we try to include both files.
+            #
+            # check if struct open_how is defined in liburing/compat.h
+            # itself and not via including linux/openat2.h
+            conf.CHECK_TYPE_IN('struct open_how', 'liburing/compat.h',
+                               cflags='-D_LINUX_OPENAT2_H',
+                               define='HAVE_STRUCT_OPEN_HOW_LIBURING_COMPAT_H')
             conf.DEFINE('HAVE_LIBURING', '1')
 
     conf.env.build_regedit = False
@@ -1849,23 +1774,6 @@ main() {
             conf.DEFINE('HAVE_TRACKER', '1')
             break
 
-    Logs.info("Checking for bison")
-    bison.configure(conf)
-    if conf.env['BISON']:
-        conf.CHECK_COMMAND('%s --version  | head -n1' % conf.env.BISON[0],
-                           msg='Using bison version',
-                           define=None,
-                           on_target=False)
-
-    Logs.info("Checking for flex")
-    conf.find_program('flex', var='FLEX')
-    if conf.env['FLEX']:
-        conf.env.FLEXFLAGS = ['-t']
-        conf.CHECK_COMMAND('%s --version' % conf.env.FLEX[0],
-                           msg='Using flex version',
-                           define=None,
-                           on_target=False)
-
     with_spotlight_tracker_backend = (
         conf.CONFIG_SET('HAVE_TRACKER')
         and conf.CONFIG_SET('HAVE_GLIB')
@@ -1881,6 +1789,14 @@ main() {
         and conf.CONFIG_GET('HAVE_UTF8_NORMALISATION')
     )
 
+    conf.env.with_wsp = False
+    if conf.CONFIG_GET('ENABLE_SELFTEST'):
+        Options.options.with_wsp = True
+    if Options.options.with_wsp:
+        Logs.info("building with WSP support")
+        conf.DEFINE('WITH_WSP', '1')
+        conf.env.with_wsp = True
+
     conf.env.with_spotlight = False
     if Options.options.with_spotlight is not False:
         backends = ['noindex']
@@ -1915,12 +1831,11 @@ main() {
             conf.fatal("Unmet dependencies for Spotlight backends")
 
         Logs.info("Building with Spotlight support, available backends: %s" % ', '.join(backends))
-        default_static_modules.extend(['rpc_mdssvc_module'])
         conf.DEFINE('WITH_SPOTLIGHT', '1')
         conf.env.with_spotlight = True
 
     if not conf.CONFIG_SET('HAVE_RPC_XDR_H'):
-        conf.CHECK_HEADERS('rpc/xdr.h', lib='tirpc')
+        conf.CHECK_HEADERS('rpc/types.h rpc/xdr.h', together=True, lib='tirpc')
 
     if conf.CHECK_FUNCS_IN('nscd_flush_cache', 'nscd', headers='libnscd.h'):
         conf.DEFINE('HAVE_NSCD_FLUSH_CACHE', '1')
@@ -1949,16 +1864,17 @@ main() {
 
     if Options.options.developer:
         default_static_modules.extend(['charset_weird'])
-        default_shared_modules.extend(['perfcount_test'])
-        default_shared_modules.extend(['vfs_skel_opaque', 'vfs_skel_transparent', 'vfs_shadow_copy_test'])
-        default_shared_modules.extend(['auth_skel', 'pdb_test'])
-        default_shared_modules.extend(['vfs_fake_dfq'])
-        default_shared_modules.extend(['gpext_security', 'gpext_registry', 'gpext_scripts'])
+        default_shared_modules.extend(['vfs_skel_opaque',
+                                       'vfs_skel_transparent',
+                                       'vfs_shadow_copy_test',
+                                       'pdb_test',
+                                       'vfs_fake_dfq',
+                                       'gpext_security', 'gpext_registry', 'gpext_scripts'])
 
     if Options.options.enable_selftest or Options.options.developer:
-        default_shared_modules.extend(['vfs_fake_acls', 'vfs_nfs4acl_xattr'])
-        default_shared_modules.extend(['vfs_error_inject'])
-        default_shared_modules.extend(['vfs_delay_inject'])
+        default_shared_modules.extend(['vfs_fake_acls', 'vfs_nfs4acl_xattr',
+                                       'vfs_error_inject',
+                                       'vfs_delay_inject'])
 
     if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
         default_static_modules.extend(['pdb_samba_dsdb', 'auth_samba4', 'vfs_dfs_samba4'])
@@ -2093,11 +2009,12 @@ main() {
     conf.env['shared_modules'] = final_shared_modules
 
     conf.DEFINE('STRING_STATIC_MODULES', ' '.join(final_static_modules), quote=True)
+    conf.DEFINE('STRING_SHARED_MODULES', ' '.join(final_shared_modules), quote=True)
 
     static_list = {}
     shared_list = {}
 
-    prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount', 'rpc']
+    prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext']
     conf.env['MODULE_PREFIXES'] = prefixes
     for p in prefixes:
         for m in final_static_modules:
@@ -2138,7 +2055,7 @@ main() {
                  and conf.CHECK_HEADERS('dbus/dbus.h', lib='dbus-1')
                  and conf.CHECK_LIB('dbus-1', shlib=True))):
         conf.fatal("vfs_snapper is enabled but prerequisite dbus-1 package not "
-                   "found. Use --with-shared-modules=!vfs_snapper to disable "
+                   "found. Use --with-shared-modules='!vfs_snapper' to disable "
                    "vfs_snapper support.")
 
     conf.SAMBA_CONFIG_H('include/config.h')