build: Check correctly for sendfile (missing .h in header)
[nivanova/samba-autobuild/.git] / source3 / wscript
old mode 100644 (file)
new mode 100755 (executable)
index 4432585..b08fc77
@@ -28,7 +28,6 @@ def set_options(opt):
     opt.SAMBA3_ADD_OPTION('winbind')
     opt.SAMBA3_ADD_OPTION('swat')
     opt.SAMBA3_ADD_OPTION('ads')
-    opt.SAMBA3_ADD_OPTION('mit-krb5-checks', default=False)
     opt.SAMBA3_ADD_OPTION('ldap')
     opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
     opt.SAMBA3_ADD_OPTION('iprint', with_name="enable", without_name="disable")
@@ -69,24 +68,24 @@ def configure(conf):
     if Options.options.with_swat:
         conf.env['build_swat'] = True
 
-    conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=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_FUNCS('getcwd fchown chmod fchmod mknod mknod64')
+    conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
     conf.CHECK_FUNCS('strtol strchr strupr chflags')
     conf.CHECK_FUNCS('getrlimit fsync fdatasync setpgid')
     conf.CHECK_FUNCS('setsid glob strpbrk crypt16 getauthuid')
     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 sysconf stat64 fstat64')
-    conf.CHECK_FUNCS('lstat64 fopen64 atexit grantpt lseek64 ftruncate64 fallocate fallocate64 posix_fallocate posix_fallocate64')
-    conf.CHECK_FUNCS('fseek64 fseeko64 ftell64 ftello64 setluid')
+    conf.CHECK_FUNCS('setpriv setgidx setuidx setgroups sysconf')
+    conf.CHECK_FUNCS('atexit grantpt fallocate posix_fallocate')
+    conf.CHECK_FUNCS('fseeko setluid')
     conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
-    conf.CHECK_FUNCS('opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64')
-    conf.CHECK_FUNCS('fdopendir fdopendir64')
-    conf.CHECK_FUNCS('getpwent_r getdents64 setenv strcasecmp fcvt fcvtl')
+    conf.CHECK_FUNCS('fdopendir')
+    conf.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
     conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
     conf.CHECK_FUNCS_IN('nanosleep', 'rt')
     conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
@@ -115,9 +114,8 @@ long ret = splice(0,0,1,0,400,0);
         conf.CHECK_DECLS('splice', reverse=True, headers='fcntl.h')
 
     # Check for inotify support
-    conf.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h')
-    conf.CHECK_FUNCS('inotify_init')
-    if "HAVE_LINUX_INOTIFY_H" in conf.env and "HAVE_INOTIFY_INIT" in conf.env:
+    conf.CHECK_HEADERS('sys/inotify.h')
+    if "HAVE_SYS_INOTIFY_H" in conf.env:
         conf.DEFINE('HAVE_INOTIFY', 1)
 
     # Check for kernel change notify support
@@ -156,8 +154,8 @@ main() {
 #include <signal.h>
 #include <sys/file.h>
 #ifndef LOCK_MAND
-#define LOCK_MAND      32
-#define LOCK_READ      64
+#define LOCK_MAND        32
+#define LOCK_READ        64
 #endif
 main() {
         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
@@ -165,13 +163,26 @@ main() {
         msg="Checking for krenel share modes")
 
     # Check for various members of the stat structure
-    conf.CHECK_TYPES('blksize_t blkcnt_t')
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
                                 headers='sys/stat.h')
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blksize', define='HAVE_STAT_ST_BLKSIZE',
                                 headers='sys/stat.h')
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_flags', define='HAVE_STAT_ST_FLAGS',
-                               headers='sys/types.h sys/stat.h unistd.h')
+                                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")
+
+    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")
 
     # Check for POSIX capability support
     conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')
@@ -224,39 +235,34 @@ if (0) {
                     msg="Checking for LL suffix on long long integers")
 
     conf.CHECK_FUNCS('''
-_acl __acl add_proplist_entry atexit attr_getf attr_list attr_listf
-attropen attr_remove attr_removef attr_set attr_setf backtrace_symbols
+_acl __acl atexit 
 bindtextdomain _chdir __chdir chflags chmod _close __close _closedir
-__closedir closedir64 creat64 crypt16 delproplist devnm dgettext dirfd
+__closedir crypt16 devnm dgettext dirfd
 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
-extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file
-extattr_get_link extattr_list_fd extattr_list_file extattr_list_link
-extattr_set_fd extattr_set_file extattr_set_link _facl __facl _fchdir
+_facl __facl _fchdir
 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
-fdelproplist fgetea fgetproplist fgetxattr flistea flistxattr fopen64
-_fork __fork fremoveea fremovexattr fseek64 fseeko64 fsetea
-fsetproplist fsetxattr _fstat __fstat fstat64 _fstat64 __fstat64 fsync
-ftell64 ftello64 ftruncate64 futimens futimes __fxstat getauthuid
-getcwd _getcwd __getcwd getdents __getdents getdents64 getdirentries
+_fork __fork fseeko
+fsetxattr _fstat __fstat fsync
+futimens futimes __fxstat getauthuid
+getcwd _getcwd __getcwd getdents __getdents getdirentries
 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
-getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
+getpwanam getpwent_r getrlimit gettext
 glob grantpt hstrerror initgroups innetgr
-inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
-llseek _llseek __llseek lremoveea lremovexattr _lseek __lseek lseek64
-lsetea lsetxattr _lstat __lstat lstat64 _lstat64 __lstat64 lutimes
-__lxstat memalign mknod mknod64 mlock mlockall munlock munlockall
-_open __open open64 _open64 __open64 _opendir __opendir
-opendir64 pathconf poll posix_fallocate posix_fallocate64
-posix_memalign prctl pread _pread __pread pread64 _pread64 __pread64
-pwrite _pwrite __pwrite pwrite64 _pwrite64
-__pwrite64 rdchk _read __read _readdir __readdir readdir64 _readdir64
-__readdir64 removeea removexattr rewinddir64 _seekdir __seekdir
-seekdir64 select setea setenv setgidx setgroups setlocale setluid
-setmntent setpgid setpriv setproplist setsid setuidx
-setxattr shmget shm_open sigaction sigblock sigprocmask sigset
-sizeof_proplist_entry _stat __stat stat64 _stat64 __stat64 statvfs
-strcasecmp strchr strpbrk strsignal strtol strupr sysconf sysctlbyname
-__sys_llseek syslog _telldir __telldir telldir64 textdomain timegm
+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
+pwrite _pwrite __pwrite
+rdchk _read __read _readdir __readdir
+_seekdir __seekdir
+select setenv setgidx setgroups setlocale setluid
+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
 utimensat vsyslog _write __write __xstat
 ''')
 
@@ -299,10 +305,8 @@ utimensat vsyslog _write __write __xstat
 
     #FIXME: add more checks
     if Options.options.with_acl_support:
-        if host_os.rfind('linux') > -1:
-           conf.CHECK_FUNCS_IN('acl_get_file', 'acl')
-           conf.CHECK_FUNCS_IN('getxattr', 'attr')
-            if conf.CHECK_CODE('''
+        conf.CHECK_FUNCS_IN('acl_get_file', 'acl')
+        if conf.CHECK_CODE('''
 acl_t acl;
 int entry_id;
 acl_entry_t *entry_p;
@@ -310,8 +314,8 @@ return acl_get_entry(acl, entry_id, entry_p);
 ''',
                         'HAVE_POSIX_ACLS',
                         headers='sys/types.h sys/acl.h', link=False,
-                       msg="Checking for POSIX ACL support") :
-                conf.CHECK_CODE('''
+                        msg="Checking for POSIX ACL support") :
+            conf.CHECK_CODE('''
 acl_permset_t permset_d;
 acl_perm_t perm;
 return acl_get_perm_np(permset_d, perm);
@@ -319,9 +323,6 @@ return acl_get_perm_np(permset_d, perm);
                         'HAVE_ACL_GET_PERM_NP',
                         headers='sys/types.h sys/acl.h', link=True,
                         msg="Checking whether acl_get_perm_np() is available")
-        else:
-            conf.DEFINE('HAVE_NO_ACLS', 1)
-            conf.SET_TARGET_TYPE('acl', 'EMPTY')
     else:
         conf.DEFINE('HAVE_NO_ACLS', 1)
         conf.SET_TARGET_TYPE('acl', 'EMPTY')
@@ -337,58 +338,26 @@ return acl_get_perm_np(permset_d, perm);
 
     if conf.CONFIG_SET('HAVE_FALLOCATE'):
         conf.CHECK_CODE('''
-               int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
-               'HAVE_LINUX_FALLOCATE',
-               msg="Checking whether the Linux 'fallocate' function is available",
-               headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
-    if conf.CONFIG_SET('HAVE_FALLOCATE64'):
-        conf.CHECK_CODE('''
-               int ret = fallocate64(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
-               'HAVE_LINUX_FALLOCATE64',
-               msg="Checking whether the Linux 'fallocate64' function is available",
-               headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
+                int ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0, 10);''',
+                'HAVE_LINUX_FALLOCATE',
+                msg="Checking whether the Linux 'fallocate' function is available",
+                headers='unistd.h sys/types.h fcntl.h linux/falloc.h')
     conf.CHECK_CODE('''
-               ssize_t err = readahead(0,0,0x80000);''',
-               'HAVE_LINUX_READAHEAD',
-               msg="Checking whether Linux readahead is available",
-               headers='unistd.h fcntl.h')
+                ssize_t err = readahead(0,0,0x80000);''',
+                'HAVE_LINUX_READAHEAD',
+                msg="Checking whether Linux readahead is available",
+                headers='unistd.h fcntl.h')
     conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
 
-    conf.CHECK_CODE('''
-               struct ucred cred;
-               socklen_t cred_len;
-               int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);''',
-               'HAVE_PEERCRED',
-               msg="Checking whether we can use SO_PEERCRED to get socket credentials",
-               headers='sys/types.h sys/socket.h')
-
-    conf.CHECK_CODE('''
-               #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
-               #include <sys/types.h>
-               #else
-               __COMPILE_ERROR_
-               #endif
-               int i;''',
-               'HAVE_EXPLICIT_LARGEFILE_SUPPORT',
-               msg="Checking whether large file support can be enabled")
-
     if Options.options.with_aio_support:
-       conf.CHECK_FUNCS_IN('aio_read', 'aio')
-       conf.CHECK_FUNCS_IN('aio_read', 'rt')
+        conf.CHECK_FUNCS_IN('aio_read', 'aio')
+        conf.CHECK_FUNCS_IN('aio_read', 'rt')
         conf.CHECK_CODE('struct aiocb a; return aio_read(&a);',
-                       'HAVE_AIO',
-                       msg='Checking for asynchronous io support',
-                       headers='sys/types.h aio.h',
-                       lib='aio rt')
-        conf.CHECK_CODE('struct aiocb64 a; return aio_read64(&a);',
-                       'HAVE_AIO64',
-                       msg='Checking for 64-bit asynchronous io support',
-                       headers='sys/types.h aio.h',
-                       lib='aio rt')
-        if conf.CONFIG_SET('HAVE_AIO64'):
-            conf.DEFINE('HAVE_AIOCB64', '1')
-            conf.DEFINE('WITH_AIO', '1')
-        elif conf.CONFIG_SET('HAVE_AIO'):
+                        'HAVE_AIO',
+                        msg='Checking for asynchronous io support',
+                        headers='sys/types.h aio.h',
+                        lib='aio rt')
+        if conf.CONFIG_SET('HAVE_AIO'):
             conf.DEFINE('WITH_AIO', '1')
         if conf.CONFIG_SET('HAVE_AIO'):
             conf.CHECK_CODE('struct aiocb a; return aio_read(&a);', 'HAVE_AIO_READ', msg='Checking for aio_read', headers='aio.h', lib='aio rt')
@@ -398,14 +367,29 @@ return acl_get_perm_np(permset_d, perm);
             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')
-        if conf.CONFIG_SET('HAVE_AIO64'):
-            conf.CHECK_CODE('struct aiocb a; return aio_read64(&a);', 'HAVE_AIO_READ64', msg='Checking for aio_read64', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('struct aiocb a; return aio_write64(&a);', 'HAVE_AIO_WRITE64', msg='Checking for aio_write64', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('struct aiocb a; return aio_fsync64(1, &a);', 'HAVE_AIO_FSYNC64', msg='Checking for aio_fsync64', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('struct aiocb a; return aio_return64(&a);', 'HAVE_AIO_RETURN64', msg='Checking for aio_return64', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('struct aiocb a; return aio_error64(&a);', 'HAVE_AIO_ERROR64', msg='Checking for aio_error64', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('struct aiocb a; return aio_cancel64(1, &a);', 'HAVE_AIO_CANCEL64', msg='Checking for aio_cancel64', headers='aio.h', lib='aio rt')
-           conf.CHECK_CODE('struct aiocb a; return aio_suspend64(&a, 1, NULL);', 'HAVE_AIO_SUSPEND64', msg='Checking for aio_suspend64', headers='aio.h', lib='aio rt')
+           if host_os.rfind('linux') > -1:
+               conf.CHECK_FUNCS_IN('io_submit', 'aio')
+               conf.CHECK_CODE('''
+struct io_event ioev;
+struct iocb *ioc;
+io_context_t ctx;
+struct timespec ts;
+int fd;
+char *buf;
+fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+io_queue_init(128,&ctx);
+io_prep_pwrite(ioc, 1, buf, 1, 0);
+io_prep_pread(ioc, 1, buf, 1, 0);
+io_set_eventfd(ioc, fd);
+io_set_callback(ioc, (io_callback_t)(0));
+io_submit(ctx, 1, &ioc);
+io_getevents(ctx, 1, 1, &ioev, &ts);
+''',
+                       'HAVE_LINUX_KERNEL_AIO',
+                       msg='Checking for linux kernel asynchronous io support',
+                       headers='unistd.h stdlib.h sys/types.h fcntl.h sys/eventfd.h libaio.h',
+                       lib='aio')
+
         if not conf.CONFIG_SET('HAVE_AIO'):
             conf.DEFINE('HAVE_NO_AIO', '1')
     else:
@@ -414,24 +398,24 @@ return acl_get_perm_np(permset_d, perm);
     conf.CHECK_CODE('''
 struct msghdr msg;
 union {
-       struct cmsghdr cm;
+        struct cmsghdr cm;
         char control[CMSG_SPACE(sizeof(int))];
 } control_un;
 msg.msg_control = control_un.control;
 msg.msg_controllen = sizeof(control_un.control);
 ''',
-       'HAVE_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')
+        'HAVE_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);
 ''',
-       'HAVE_MSGHDR_MSG_ACCTRIGHTS',
-       msg='Checking if we can use msg_acctrights for passing file descriptors',
-       headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
+        'HAVE_MSGHDR_MSG_ACCTRIGHTS',
+        msg='Checking if we can use msg_acctrights for passing file descriptors',
+        headers='sys/types.h stdlib.h stddef.h sys/socket.h sys/un.h')
 
     if Options.options.with_winbind:
         conf.env.build_winbind = True
@@ -440,12 +424,6 @@ msg.msg_acctrightslen = sizeof(fd);
     conf.find_program('awk', var='AWK')
     conf.find_program('perl', var='PERL')
 
-    # Darwin has extra options to xattr-family functions
-    conf.CHECK_CODE('getxattr(0, 0, 0, 0, 0, 0);',
-                    'XATTR_ADD_OPT',
-                    msg="Checking whether xattr interface takes additional options",
-                    headers='sys/types.h attr/xattr.h sys/xattr.h')
-
     conf.CHECK_HEADERS('asm/types.h')
 
     conf.CHECK_CODE('dev_t dev; int i = major(dev); return 0', "HAVE_DEVICE_MAJOR_FN",
@@ -486,8 +464,8 @@ msg.msg_acctrightslen = sizeof(fd);
             # we would normally use --libs here, but cups-config incorrectly adds
             # gssapi_krb5 and other libraries to its --libs output. That breaks the use
             # of an in-tree heimdal kerberos
-           conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
-                           package="", uselib_store="cups")
+            conf.check_cfg(path=conf.env.CUPS_CONFIG, args="--cflags --ldflags",
+                           package="", uselib_store="CUPS")
         conf.CHECK_HEADERS('cups/cups.h cups/language.h', lib='cups')
         conf.CHECK_FUNCS_IN('httpConnect httpConnectEncrypt', 'cups')
         if conf.CONFIG_SET('HAVE_CUPS_CUPS_H') and conf.CONFIG_SET('HAVE_CUPS_LANGUAGE_H'):
@@ -500,7 +478,7 @@ msg.msg_acctrightslen = sizeof(fd);
         conf.SET_TARGET_TYPE('cups', 'EMPTY')
 
     if Options.options.with_iprint:
-       if conf.CONFIG_SET('HAVE_CUPS'):
+        if conf.CONFIG_SET('HAVE_CUPS'):
             conf.DEFINE('HAVE_IPRINT', '1')
         else:
             Logs.warn("--enable-iprint=yes but cups support not sufficient")
@@ -547,202 +525,6 @@ msg.msg_acctrightslen = sizeof(fd);
         conf.SET_TARGET_TYPE('ldap', 'EMPTY')
         conf.SET_TARGET_TYPE('lber', 'EMPTY')
 
-    # Check for kerberos
-    have_gssapi=False
-    if Options.options.with_mit_krb5_checks and conf.env.developer:
-        Logs.info("Looking for kerberos features")
-        conf.find_program('krb5-config', var='KRB5_CONFIG')
-        if conf.env.KRB5_CONFIG:
-            conf.check_cfg(path="krb5-config", args="--cflags --libs",
-                       package="gssapi", uselib_store="krb5")
-        conf.CHECK_HEADERS('krb5.h krb5/locate_plugin.h', lib='krb5')
-        conf.CHECK_HEADERS('gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h gssapi/gssapi_krb5.h com_err.h', lib='krb5')
-
-        if conf.CONFIG_SET('HAVE_KRB5_LOCATE_PLUGIN_H'):
-            conf.env['WINBIND_KRB5_LOCATOR'] = 'bin/winbind_krb5_locator.so'
-
-        conf.CHECK_FUNCS_IN('_et_list', 'com_err')
-        conf.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
-       conf.CHECK_FUNCS_IN('des_set_key','crypto')
-        conf.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
-        conf.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
-        if conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi') or \
-           conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi_krb5'):
-            have_gssapi=True
-        conf.CHECK_FUNCS_IN('gss_wrap_iov gss_krb5_import_cred gss_get_name_attribute gss_mech_krb5 gss_oid_equal gss_inquire_sec_context_by_oid', 'gssapi gssapi_krb5 krb5')
-        conf.CHECK_FUNCS_IN('krb5_mk_req_extended krb5_kt_compare', 'krb5')
-        conf.CHECK_FUNCS('''
-krb5_set_real_time krb5_set_default_in_tkt_etypes krb5_set_default_tgs_enctypes
-krb5_set_default_tgs_ktypes krb5_principal2salt krb5_use_enctype
-krb5_string_to_key krb5_get_pw_salt krb5_string_to_key_salt krb5_auth_con_setkey
-krb5_auth_con_setuseruserkey krb5_locate_kdc krb5_get_permitted_enctypes
-krb5_get_default_in_tkt_etypes krb5_free_data_contents
-krb5_principal_get_comp_string krb5_free_unparsed_name
-krb5_free_keytab_entry_contents krb5_kt_free_entry krb5_krbhst_init
-krb5_krbhst_get_addrinfo krb5_c_enctype_compare krb5_enctypes_compatible_keys
-krb5_crypto_init krb5_crypto_destroy krb5_decode_ap_req free_AP_REQ
-krb5_verify_checksum krb5_c_verify_checksum krb5_principal_compare_any_realm
-krb5_parse_name_norealm krb5_princ_size krb5_get_init_creds_opt_set_pac_request
-krb5_get_renewed_creds krb5_get_kdc_cred krb5_free_error_contents
-initialize_krb5_error_table krb5_get_init_creds_opt_alloc
-krb5_get_init_creds_opt_free krb5_get_init_creds_opt_get_error
-krb5_enctype_to_string krb5_fwd_tgt_creds krb5_auth_con_set_req_cksumtype
-krb5_get_creds_opt_alloc krb5_get_creds_opt_set_impersonate krb5_get_creds
-krb5_get_credentials_for_user krb5_get_host_realm krb5_free_host_realm''',
-                         lib='krb5 k5crypto')
-        conf.CHECK_DECLS('''krb5_get_credentials_for_user
-                            krb5_auth_con_set_req_cksumtype''',
-                            headers='krb5.h', always=True)
-        conf.CHECK_VARIABLE('AP_OPTS_USE_SUBKEY', headers='krb5.h')
-        conf.CHECK_VARIABLE('KV5M_KEYTAB', headers='krb5.h')
-        conf.CHECK_VARIABLE('KRB5_KU_OTHER_CKSUM', headers='krb5.h')
-        conf.CHECK_VARIABLE('KRB5_KEYUSAGE_APP_DATA_CKSUM', headers='krb5.h')
-        conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'key', headers='krb5.h',
-                                    define='HAVE_KRB5_KEYTAB_ENTRY_KEY')
-        conf.CHECK_STRUCTURE_MEMBER('krb5_keytab_entry', 'keyblock', headers='krb5.h',
-                                    define='HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK')
-        conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'magic', headers='krb5.h',
-                                    define='HAVE_MAGIC_IN_KRB5_ADDRESS')
-        conf.CHECK_STRUCTURE_MEMBER('krb5_address', 'addrtype', headers='krb5.h',
-                                    define='HAVE_ADDRTYPE_IN_KRB5_ADDRESS')
-        conf.CHECK_STRUCTURE_MEMBER('krb5_ticket', 'enc_part2', headers='krb5.h',
-                                    define='HAVE_KRB5_TKT_ENC_PART2')
-        conf.CHECK_STRUCTURE_MEMBER('krb5_creds', 'keyblock', headers='krb5.h',
-                                    define='HAVE_KRB5_KEYBLOCK_IN_CREDS')
-        conf.CHECK_STRUCTURE_MEMBER('krb5_creds', 'session', headers='krb5.h',
-                                    define='HAVE_KRB5_SESSION_IN_CREDS')
-        conf.CHECK_STRUCTURE_MEMBER('krb5_ap_req', 'ticket', headers='krb5.h',
-                                    define='HAVE_TICKET_POINTER_IN_KRB5_AP_REQ')
-
-        conf.CHECK_TYPE('krb5_encrypt_block', headers='krb5.h')
-
-        conf.CHECK_CODE('''
-krb5_ticket ticket;
-krb5_kvno kvno;
-krb5_enctype enctype;
-enctype = ticket.enc_part.enctype;
-kvno = ticket.enc_part.kvno;
-''',
-                        'KRB5_TICKET_HAS_KEYINFO',
-                        headers='krb5.h', link=False,
-                        msg="Checking whether the krb5_ticket structure contains the kvno and enctype")
-        conf.CHECK_CODE('''
-krb5_context ctx;
-krb5_get_init_creds_opt *opt = NULL;
-krb5_get_init_creds_opt_free(ctx, opt);
-''',
-                        'KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT',
-                        headers='krb5.h', link=False,
-                        msg="Checking whether krb5_get_init_creds_opt_free takes a context argument")
-        conf.CHECK_CODE('krb5_mk_error(0,0,0)',
-                        'HAVE_SHORT_KRB5_MK_ERROR_INTERFACE',
-                        headers='krb5.h', link=False,
-                        msg="Checking whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal")
-        conf.CHECK_CODE('''
-const krb5_data *pkdata;
-krb5_context context;
-krb5_principal principal;
-pkdata = krb5_princ_component(context, principal, 0);
-''',
-                        'HAVE_KRB5_PRINC_COMPONENT',
-                        headers='krb5.h', lib='krb5',
-                        msg="Checking whether krb5_princ_component is available")
-
-        conf.CHECK_CODE('''
-int main(void) {
-char buf[256];
-krb5_enctype_to_string(1, buf, 256);
-return 0;
-}''',
-                        'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG',
-                        headers='krb5.h', lib='krb5 k5crypto',
-                        addmain=False, cflags='-Werror',
-                        msg="Checking whether krb5_enctype_to_string takes size_t argument")
-
-        conf.CHECK_CODE('''
-int main(void) {
-krb5_context context = NULL;
-char *str = NULL;
-krb5_enctype_to_string(context, 1, &str);
-if (str) free (str);
-return 0;
-}''',
-                        'HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG',
-                        headers='krb5.h stdlib.h', lib='krb5',
-                        addmain=False, cflags='-Werror',
-                        msg="Checking whether krb5_enctype_to_string takes krb5_context argument")
-        conf.CHECK_CODE('''
-int main(void) {
-krb5_context ctx = NULL;
-krb5_principal princ = NULL;
-const char *str = krb5_princ_realm(ctx, princ)->data;
-return 0;
-}''',
-                        'HAVE_KRB5_PRINC_REALM',
-                        headers='krb5.h', lib='krb5',
-                        addmain=False,
-                        msg="Checking whether the macro krb5_princ_realm is defined")
-        conf.CHECK_CODE('''
-int main(void) {
-    krb5_context context;
-    krb5_principal principal;
-    const char *realm; realm = krb5_principal_get_realm(context, principal);
-    return 0;
-}''',
-                        'HAVE_KRB5_PRINCIPAL_GET_REALM',
-                        headers='krb5.h', lib='krb5',
-                        addmain=False,
-                        msg="Checking whether krb5_principal_get_realm is defined")
-        if conf.CHECK_CODE('''krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);''',
-                        'KRB5_VERIFY_CHECKSUM_ARGS',
-                        headers='krb5.h', lib='krb5',
-                       msg="Checking whether krb5_verify_checksum takes 7 arguments"):
-            conf.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '7')
-       else:
-            conf.DEFINE('KRB5_VERIFY_CHECKSUM_ARGS', '6')
-
-       conf.CHECK_CODE('''
-krb5_enctype enctype;
-enctype = ENCTYPE_ARCFOUR_HMAC_MD5;
-''',
-            '_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5',
-            headers='krb5.h', lib='krb5',
-            msg="Checking whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available");
-       conf.CHECK_CODE('''
-krb5_keytype keytype;
-keytype = KEYTYPE_ARCFOUR_56;
-''',
-            '_HAVE_KEYTYPE_ARCFOUR_56',
-            headers='krb5.h', lib='krb5',
-            msg="Checking whether the HAVE_KEYTYPE_ARCFOUR_56 key type definition is available");
-       if conf.CONFIG_SET('_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and conf.CONFIG_SET('_HAVE_KEYTYPE_ARCFOUR_56'):
-            conf.DEFINE('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', '1')
-
-       conf.CHECK_CODE('''
-krb5_enctype enctype;
-enctype = ENCTYPE_ARCFOUR_HMAC;
-''',
-            'HAVE_ENCTYPE_ARCFOUR_HMAC',
-            headers='krb5.h', lib='krb5',
-            msg="Checking whether the ENCTYPE_ARCFOUR_HMAC key type definition is available");
-
-       conf.CHECK_CODE('''
-krb5_context context;
-krb5_keytab keytab;
-krb5_init_context(&context);
-return krb5_kt_resolve(context, "WRFILE:api", &keytab);
-''',
-            'HAVE_WRFILE_KEYTAB',
-            headers='krb5.h', lib='krb5', execute=True,
-            msg="Checking whether the WRFILE:-keytab is supported");
-
-        # Check for KRB5_DEPRECATED handling
-        conf.CHECK_CODE('''#define KRB5_DEPRECATED 1
-#include <krb5.h>''',
-        'HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER', addmain=False,
-        link=False,
-        msg="Checking for KRB5_DEPRECATED define taking an identifier")
-
     if Options.options.with_ads:
         use_ads=True
         if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
@@ -752,6 +534,31 @@ return krb5_kt_resolve(context, "WRFILE:api", &keytab);
         if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
             Logs.warn("krb5_mk_req_extended not found in -lkrb5")
             use_ads=False
+        if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
+            Logs.warn("krb5_get_host_realm not found in -lkrb5")
+            use_ads=False
+        if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
+            Logs.warn("krb5_free_host_realm not found in -lkrb5")
+            use_ads=False
+        if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
+            Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
+            use_ads=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
+        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
+        if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
+            Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
+            use_ads=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
+        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
         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")
@@ -764,24 +571,27 @@ return krb5_kt_resolve(context, "WRFILE:api", &keytab);
            not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
             Logs.warn("no KT_FREE_FUNCTION detected")
             use_ads=False
-        if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM') and \
-           not conf.CONFIG_SET('HAVE_KRB5_VERIFY_CHECKSUM'):
-            Logs.warn("no KRB5_VERIFY_CHECKSUM_FUNCTION detected")
+        if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
+            Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
             use_ads=False
-        if not conf.CONFIG_SET('KRB5_TICKET_HAS_KEYINFO'):
-            # We only need the following functions if we can't get the enctype
-            # and kvno out of the ticket directly (ie. on Heimdal).
-            if not conf.CONFIG_SET('HAVE_FREE_AP_REQ'):
-                Logs.warn("no KRB5_AP_REQ_FREE_FUNCTION detected")
-                use_ads=False
-            if not conf.CONFIG_SET('HAVE_KRB5_DECODE_AP_REQ'):
-                Logs.warn("no KRB5_AP_REQ_DECODING_FUNCTION detected")
-                use_ads=False
+
+        # We don't actually use
+        # gsskrb5_extract_authz_data_from_sec_context, but it is a
+        # clue that this Heimdal, which does the PAC processing we
+        # need on the standard gss_inquire_sec_context_by_oid
+        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
+
+        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
+
         if use_ads:
             conf.DEFINE('WITH_ADS', '1')
             conf.DEFINE('HAVE_KRB5', '1')
-            if have_gssapi:
-                conf.DEFINE('HAVE_GSSAPI', '1')
             if conf.CONFIG_SET('HAVE_LDAP'):
                 conf.env['HAVE_ADS'] = '1'
         else:
@@ -792,6 +602,8 @@ return krb5_kt_resolve(context, "WRFILE:api", &keytab);
             conf.undefine('HAVE_GSSAPI_GSSAPI_H')
 
     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_STRUCTURE_MEMBER('struct utmp', 'ut_name', headers='utmp.h',
                                     define='HAVE_UT_UT_NAME')
@@ -820,7 +632,8 @@ return krb5_kt_resolve(context, "WRFILE:api", &keytab);
         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.DEFINE('WITH_UTMP', 1)
+        if conf.env.with_utmp:
+            conf.DEFINE('WITH_UTMP', 1)
 
     if Options.options.with_avahi:
         conf.env.with_avahi = True
@@ -854,7 +667,7 @@ return krb5_kt_resolve(context, "WRFILE:api", &keytab);
         conf.CHECK_HEADERS('security/pam_ext.h security/_pam_macros.h')
         conf.CHECK_HEADERS('pam/pam_ext.h pam/_pam_macros.h')
         conf.CHECK_FUNCS_IN('pam_vsyslog', 'pam')
-       conf.CHECK_CODE('''
+        conf.CHECK_CODE('''
 #if defined(HAVE_SECURITY_PAM_APPL_H)
 #include <security/pam_appl.h>
 #elif defined(HAVE_PAM_PAM_APPL_H)
@@ -865,7 +678,7 @@ pam_set_item(0, PAM_RHOST, 0);
             'HAVE_PAM_RHOST',
             lib='pam',
             msg="Checking whether PAM_RHOST is available");
-       conf.CHECK_CODE('''
+        conf.CHECK_CODE('''
 #if defined(HAVE_SECURITY_PAM_APPL_H)
 #include <security/pam_appl.h>
 #elif defined(HAVE_PAM_PAM_APPL_H)
@@ -876,7 +689,7 @@ pam_set_item(0, PAM_TTY, 0);
             'HAVE_PAM_TTY',
             lib='pam',
             msg="Checking whether PAM_TTY is available");
-       conf.CHECK_CODE('''
+        conf.CHECK_CODE('''
 #if (!defined(LINUX))
 
 #define PAM_EXTERN extern
@@ -916,56 +729,50 @@ int i; i = PAM_RADIO_TYPE;
     seteuid = False
     if not seteuid:
         seteuid = conf.CHECK_CODE('''
-                               #define AUTOCONF_TEST 1
-                               #define USE_SETREUID 1
-                               #include "./lib/util_sec.c"
-                               ''',
-                               'USE_SETREUID',
-                               addmain=False,
-                               execute=True,
-                               msg="Checking whether setreuid is available")
+                                #define AUTOCONF_TEST 1
+                                #define USE_SETREUID 1
+                                #include "./lib/util_sec.c"
+                                ''',
+                                'USE_SETREUID',
+                                addmain=False,
+                                execute=True,
+                                msg="Checking whether setreuid is available")
     if not seteuid:
         seteuid = conf.CHECK_CODE('''
-                               #define AUTOCONF_TEST 1
-                               #define USE_SETRESUID 1
-                               #include "./lib/util_sec.c"
-                               ''',
-                               'USE_SETRESUID',
-                               addmain=False,
-                               execute=True,
-                               msg="Checking whether setresuid is available")
+                                #define AUTOCONF_TEST 1
+                                #define USE_SETRESUID 1
+                                #include "./lib/util_sec.c"
+                                ''',
+                                'USE_SETRESUID',
+                                addmain=False,
+                                execute=True,
+                                msg="Checking whether setresuid is available")
     if not seteuid:
         seteuid = conf.CHECK_CODE('''
-                               #define AUTOCONF_TEST 1
-                               #define USE_SETEUID 1
-                               #include "./lib/util_sec.c"
-                               ''',
-                               'USE_SETEUID',
-                               addmain=False,
-                               execute=True,
-                               msg="Checking whether seteuid is available")
+                                #define AUTOCONF_TEST 1
+                                #define USE_SETEUID 1
+                                #include "./lib/util_sec.c"
+                                ''',
+                                'USE_SETEUID',
+                                addmain=False,
+                                execute=True,
+                                msg="Checking whether seteuid is available")
     if not seteuid:
         seteuid = conf.CHECK_CODE('''
-                               #define AUTOCONF_TEST 1
-                               #define USE_SETUIDX 1
-                               #include "./lib/util_sec.c"
-                               ''',
-                               'USE_SETUIDX',
-                               addmain=False,
-                               execute=True,
-                               mandatory=True,
-                               msg="Checking whether setuidx is available")
+                                #define AUTOCONF_TEST 1
+                                #define USE_SETUIDX 1
+                                #include "./lib/util_sec.c"
+                                ''',
+                                'USE_SETUIDX',
+                                addmain=False,
+                                execute=True,
+                                mandatory=True,
+                                msg="Checking whether setuidx is available")
     if Options.options.with_dnsupdate:
-        conf.CHECK_HEADERS('uuid/uuid.h')
-        conf.CHECK_FUNCS_IN('uuid_generate', 'uuid')
-        if not conf.CONFIG_SET('HAVE_UUID_UUID_H') and not conf.CONFIG_SET('HAVE_UUID_GENERATE'):
-            Logs.warn("--with-dnsupdate=yes but uuid support not sufficient")
-        elif not conf.CONFIG_SET('HAVE_GSSAPI'):
+        if not conf.CONFIG_SET('HAVE_KRB5'):
             Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
         else:
             conf.DEFINE('WITH_DNS_UPDATES', 1)
-    else:
-        conf.SET_TARGET_TYPE('uuid', 'EMPTY')
     conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
     if Options.options.developer:
         if conf.CONFIG_SET('HAVE_VALGRIND_H') or conf.CONFIG_SET('HAVE_VALGRIND_VALGRIND_H'):
@@ -975,74 +782,33 @@ int i; i = PAM_RADIO_TYPE;
 #include <bits/sockaddr.h>
 #include <linux/netlink.h>
 ''',
-               'HAVE_LINUX_NETLINK_H',
+                'HAVE_LINUX_NETLINK_H',
                 msg="Checking whether Linux netlink is available"):
         conf.CHECK_CODE('''
 #include <bits/sockaddr.h>
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 ''',
-               'HAVE_LINUX_RTNETLINK_H',
-               msg='Checking whether Linux rtnetlink is available')
-    if conf.CHECK_TYPE('struct dirent64', headers='sys/types.h dirent.h') and conf.CONFIG_SET('HAVE_READDIR64'):
-        conf.DEFINE('HAVE_STRUCT_DIRENT64', '1')
-    else:
-        conf.undefine('HAVE_STRUCT_DIRENT64')
-
+                'HAVE_LINUX_RTNETLINK_H',
+                msg='Checking whether Linux rtnetlink is available')
     conf.CHECK_CODE('''
 #include "../tests/fcntl_lock.c"
 ''',
-               'HAVE_FCNTL_LOCK',
-               addmain=False,
-               execute=True,
-               msg='Checking whether fcntl locking is available')
-
-    conf.CHECK_CODE('''
-#include "../tests/fcntl_lock64.c"
-''',
-               'HAVE_BROKEN_FCNTL64_LOCKS',
-               addmain=False,
-               execute=True,
-               msg='Checking whether fcntl64 locks are broken')
-
-    if not conf.CONFIG_SET('HAVE_BROKEN_FCNTL64_LOCKS'):
-        conf.CHECK_CODE('''
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_FCNTL_H
-#include <sys/fcntl.h>
-#endif
-main() { struct flock64 fl64;
-#if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
-exit(0);
-#else
-exit(1);
-#endif
-}
-''',
-               'HAVE_STRUCT_FLOCK64',
-               addmain=False,
-               execute=True,
-               msg="Checking whether the flock64 struct is available")
+                'HAVE_FCNTL_LOCK',
+                addmain=False,
+                execute=True,
+                msg='Checking whether fcntl locking is available')
 
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec',
-                               define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
+                                define='HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') # Linux, Solaris
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimensec',
-                               define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
+                                define='HAVE_STRUCT_STAT_ST_MTIMENSEC') # BSD, if defined _POSIX_SOURCE
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtimespec.tv_nsec',
-                               define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
+                                define='HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') # BSD, if not defined _POSIX_SOURCE
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtime_n',
-                               define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
+                                define='HAVE_STRUCT_STAT_ST_MTIME_N') # AIX
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_umtime',
-                               define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
+                                define='HAVE_STRUCT_STAT_ST_UMTIME') # Tru64
     if conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC') or \
        conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMENSEC') or \
        conf.CONFIG_SET('HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC') or \
@@ -1052,52 +818,50 @@ exit(1);
 
     # recent FreeBSD, NetBSD have creation timestamps called birthtime:
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtime',
-                               define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
+                                define='HAVE_STRUCT_STAT_ST_BIRTHTIME')
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimespec.tv_nsec',
-                               define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
+                                define='HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC')
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_birthtimensec',
-                               define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
+                                define='HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC')
 
     conf.CHECK_CODE('''
 ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);
 ''',
-               'HAVE_POSIX_FADVISE',
-               msg='Checking whether posix_fadvise is available',
-               headers='unistd.h fcntl.h')
+                'HAVE_POSIX_FADVISE',
+                msg='Checking whether posix_fadvise is available',
+                headers='unistd.h fcntl.h')
 
     for v in ['_SC_NGROUPS_MAX', '_SC_NPROC_ONLN', '_SC_NPROCESSORS_ONLN', '_SC_PAGESIZE' ]:
         conf.CHECK_CODE('''
-                       #include <unistd.h>
-                       return sysconf(%s) == -1 ? 1 : 0;
-                       ''' % v,
-                       'SYSCONF%s' % v,
-                       msg='Checking whether sysconf(%s) is available' % v)
-
-    conf.CHECK_DECLS('__NR_inotify_init', reverse=True, headers='asm/unistd.h')
+                        #include <unistd.h>
+                        return sysconf(%s) == -1 ? 1 : 0;
+                        ''' % v,
+                        'SYSCONF%s' % v,
+                        msg='Checking whether sysconf(%s) is available' % v)
 
     conf.CHECK_CODE('''
 #include <sys/syscall.h>
 #include <unistd.h>
 syscall(SYS_initgroups, 16, NULL, NULL, 0);
-                   ''',
-                   'HAVE_DARWIN_INITGROUPS',
-                   msg='Checking whether to use the Darwin-specific initgroups system call')
+                    ''',
+                    'HAVE_DARWIN_INITGROUPS',
+                    msg='Checking whether to use the Darwin-specific initgroups system call')
 
     conf.CHECK_CODE('''struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));''',
-                   'HAVE_UTIMBUF',
-                   headers='sys/types.h utime.h',
-                   msg='Checking whether struct utimbuf is available')
+                    'HAVE_UTIMBUF',
+                    headers='sys/types.h utime.h',
+                    msg='Checking whether struct utimbuf is available')
 
     if conf.CHECK_CODE('''struct sigevent s;''',
-                   'HAVE_STRUCT_SIGEVENT',
-                   headers='sys/types.h stdlib.h stddef.h signal.h',
-                   msg='Checking whether we have the struct sigevent'):
+                    'HAVE_STRUCT_SIGEVENT',
+                    headers='sys/types.h stdlib.h stddef.h signal.h',
+                    msg='Checking whether we have the struct sigevent'):
         conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sival_ptr',
-                                   define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
-                                   headers='signal.h');
+                                    define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR',
+                                    headers='signal.h');
         conf.CHECK_STRUCTURE_MEMBER('struct sigevent', 'sigev_value.sigval_ptr',
-                                   define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
-                                   headers='signal.h');
+                                    define='HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR',
+                                    headers='signal.h');
 
     if os.path.exists('/proc/sys/kernel/core_pattern'):
         conf.DEFINE('HAVE_SYS_KERNEL_PROC_CORE_PATTERN', '1')
@@ -1105,26 +869,26 @@ syscall(SYS_initgroups, 16, NULL, NULL, 0);
     if conf.CHECK_CODE('''
 #include <time.h>
 main() {
-       struct tm *tm;
-       if (sizeof(time_t) == 8) {
-               time_t max_time = 0x7fffffffffffffffll;
-               tm = gmtime(&max_time);
-               /* This should fail with 32-bit tm_year. */
-               if (tm == NULL) {
-                       /* Max time_t that works with 32-bit int tm_year in struct tm. */
-                       max_time = 67768036191676799ll;
-                       tm = gmtime(&max_time);
-                       if (tm) {
-                               exit(0);
-                       }
-               }
-       }
-       exit(1);
+        struct tm *tm;
+        if (sizeof(time_t) == 8) {
+                time_t max_time = 0x7fffffffffffffffll;
+                tm = gmtime(&max_time);
+                /* This should fail with 32-bit tm_year. */
+                if (tm == NULL) {
+                        /* Max time_t that works with 32-bit int tm_year in struct tm. */
+                        max_time = 67768036191676799ll;
+                        tm = gmtime(&max_time);
+                        if (tm) {
+                                exit(0);
+                        }
+                }
+        }
+        exit(1);
 }''',
-       '__TIME_T_MAX',
-       addmain=False,
-       execute=True,
-       msg="Checking for the maximum value of the 'time_t' type"):
+        '__TIME_T_MAX',
+        addmain=False,
+        execute=True,
+        msg="Checking for the maximum value of the 'time_t' type"):
             conf.DEFINE('TIME_T_MAX', '67768036191676799ll')
 
     conf.CHECK_CODE('''
@@ -1134,9 +898,9 @@ main() {
 #include <sys/types.h>
 main() { dev_t dev = makedev(1,2); return 0; }
 ''',
-       'HAVE_MAKEDEV',
-       addmain=False,
-       msg='Checking whether the macro for makedev is available')
+        'HAVE_MAKEDEV',
+        addmain=False,
+        msg='Checking whether the macro for makedev is available')
 
     conf.CHECK_CODE('''
 #include <stdio.h>
@@ -1144,26 +908,26 @@ main() { dev_t dev = makedev(1,2); return 0; }
 #include <signal.h>
 
 void exit_on_core(int ignored) {
-       exit(1);
+        exit(1);
 }
 
 main() {
-       char *newpath;
-       signal(SIGSEGV, exit_on_core);
-       newpath = realpath("/tmp", NULL);
-       exit((newpath != NULL) ? 0 : 1);
+        char *newpath;
+        signal(SIGSEGV, exit_on_core);
+        newpath = realpath("/tmp", NULL);
+        exit((newpath != NULL) ? 0 : 1);
 }
 ''',
-       'REALPATH_TAKES_NULL',
-       addmain=False,
-       execute=True,
-       msg='Checking whether the realpath function allows a NULL argument')
+        'REALPATH_TAKES_NULL',
+        addmain=False,
+        execute=True,
+        msg='Checking whether the realpath function allows a NULL argument')
 
     conf.CHECK_CODE('''#include "../tests/ftruncate.c"''',
-                   'HAVE_FTRUNCATE_EXTEND',
-                   msg='Checking for ftruncate extend',
-                   addmain=False,
-                   execute=True)
+                    'HAVE_FTRUNCATE_EXTEND',
+                    msg='Checking for ftruncate extend',
+                    addmain=False,
+                    execute=True)
     if os.getenv('RUN_FROM_BUILD_FARM'):
         Logs.info("enabling buildfarm hacks")
         conf.DEFINE('ENABLE_BUILD_FARM_HACKS', '1')
@@ -1171,177 +935,121 @@ main() {
     if Options.options.with_sendfile_support:
         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):
             conf.CHECK_CODE('''
-                           int tofd, fromfd;
-                           off64_t offset;
-                           size_t total;
-                           ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
-                           ''',
-                           '_HAVE_SENDFILE64',
-                           headers='sys/sendfile',
-                           msg='Checking for linux sendfile64 support')
-            conf.CHECK_CODE('''
-                           int tofd, fromfd;
-                           off_t offset;
-                           size_t total;
-                           ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
-                           ''',
-                           '_HAVE_SENDFILE',
-                           headers='sys/sendfile',
-                           msg='Checking for linux sendfile support')
+                            int tofd, fromfd;
+                            off_t offset;
+                            size_t total;
+                            ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
+                            ''',
+                            '_HAVE_SENDFILE',
+                            headers='sys/sendfile.h',
+                            msg='Checking for linux sendfile support')
 
             # Try and cope with broken Linux sendfile....
             conf.CHECK_CODE('''#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
-                           #undef _FILE_OFFSET_BITS
-                           #endif
-                           #include <sys/sendfile.h>
-                           int tofd, fromfd;
-                           off_t offset;
-                           size_t total;
-                           ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
-                           ''',
-                           '_HAVE_BROKEN_LINUX_SENDFILE',
-                           msg='Checking for broken linux sendfile support')
-            if conf.CONFIG_SET('_HAVE_SENDFILE64'):
-                conf.DEFINE('HAVE_SENDFILE64', '1')
-                conf.DEFINE('LINUX_SENDFILE_API', '1')
-                conf.DEFINE('WITH_SENDFILE', '1')
-            elif conf.CONFIG_SET('_HAVE_SENDFILE'):
+                            #undef _FILE_OFFSET_BITS
+                            #endif
+                            #include <sys/sendfile.h>
+                            int tofd, fromfd;
+                            off_t offset;
+                            size_t total;
+                            ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
+                            ''',
+                            '_HAVE_BROKEN_LINUX_SENDFILE',
+                            msg='Checking for broken linux sendfile support')
+            if conf.CONFIG_SET('_HAVE_SENDFILE'):
                 conf.DEFINE('HAVE_SENDFILE', '1')
                 conf.DEFINE('LINUX_SENDFILE_API', '1')
                 conf.DEFINE('WITH_SENDFILE', '1')
             elif conf.CONFIG_SET('_HAVE_BROKEN_LINUX_SENDFILE'):
                 conf.DEFINE('LINUX_BROKEN_SENDFILE_API', '1')
                 conf.DEFINE('WITH_SENDFILE', '1')
-       elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
+        elif (host_os.rfind('freebsd') > -1) or (host_os.rfind('dragonfly') > -1):
             conf.CHECK_CODE('''
-                           #include <sys/types.h>
-                           #include <unistd.h>
-                           #include <sys/socket.h>
-                           #include <sys/uio.h>
-                           int fromfd, tofd, ret, total=0;
-                           off_t offset, nwritten;
-                           struct sf_hdtr hdr;
-                           struct iovec hdtrl;
-                           hdr.headers = &hdtrl;
-                           hdr.hdr_cnt = 1;
-                           hdr.trailers = NULL;
-                           hdr.trl_cnt = 0;
-                           hdtrl.iov_base = NULL;
-                           hdtrl.iov_len = 0;
-                           ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
-                           ''',
-                           '_HAVE_SENDFILE',
-                           msg='Checking for freebsd sendfile support')
+                            #include <sys/types.h>
+                            #include <unistd.h>
+                            #include <sys/socket.h>
+                            #include <sys/uio.h>
+                            int fromfd, tofd, ret, total=0;
+                            off_t offset, nwritten;
+                            struct sf_hdtr hdr;
+                            struct iovec hdtrl;
+                            hdr.headers = &hdtrl;
+                            hdr.hdr_cnt = 1;
+                            hdr.trailers = NULL;
+                            hdr.trl_cnt = 0;
+                            hdtrl.iov_base = NULL;
+                            hdtrl.iov_len = 0;
+                            ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0)
+                            ''',
+                            '_HAVE_SENDFILE',
+                            msg='Checking for freebsd sendfile support')
             if conf.CONFIG_SET('_HAVE_SENDFILE'):
                 conf.DEFINE('HAVE_SENDFILE', '1')
                 conf.DEFINE('FREEBSD_SENDFILE_API', '1')
                 conf.DEFINE('WITH_SENDFILE', '1')
-       elif (host_os.rfind('hpux') > -1):
-            conf.CHECK_CODE('''
-                           #include <sys/socket.h>
-                           #include <sys/uio.h>
-                           int fromfd, tofd;
-                           size_t total=0;
-                           struct iovec hdtrl[2];
-                           ssize_t nwritten;
-                           off64_t offset;
-                           hdtrl[0].iov_base = 0;
-                           hdtrl[0].iov_len = 0;
-                           nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
-                           ''',
-                           '_HAVE_SENDFILE64',
-                           msg='Checking for hpux sendfile64 support')
+        elif (host_os.rfind('hpux') > -1):
             conf.CHECK_CODE('''
-                           #include <sys/socket.h>
-                           #include <sys/uio.h>
-                           int fromfd, tofd;
-                           size_t total=0;
-                           struct iovec hdtrl[2];
-                           ssize_t nwritten;
-                           off_t offset;
-                           hdtrl[0].iov_base = 0;
-                           hdtrl[0].iov_len = 0;
-                           nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
-                           ''',
-                           '_HAVE_SENDFILE',
-                           msg='Checking for hpux sendfile support')
-            if conf.CONFIG_SET('_HAVE_SENDFILE64'):
-                conf.DEFINE('HAVE_SENDFILE64', '1')
-                conf.DEFINE('HPUX_SENDFILE_API', '1')
-                conf.DEFINE('WITH_SENDFILE', '1')
-            elif conf.CONFIG_SET('_HAVE_SENDFILE'):
+                            #include <sys/socket.h>
+                            #include <sys/uio.h>
+                            int fromfd, tofd;
+                            size_t total=0;
+                            struct iovec hdtrl[2];
+                            ssize_t nwritten;
+                            off_t offset;
+                            hdtrl[0].iov_base = 0;
+                            hdtrl[0].iov_len = 0;
+                            nwritten = sendfile(tofd, fromfd, offset, total, &hdtrl[0], 0);
+                            ''',
+                            '_HAVE_SENDFILE',
+                            msg='Checking for hpux sendfile support')
+            if conf.CONFIG_SET('_HAVE_SENDFILE'):
                 conf.DEFINE('HAVE_SENDFILE', '1')
                 conf.DEFINE('HPUX_SENDFILE_API', '1')
                 conf.DEFINE('WITH_SENDFILE', '1')
-       elif (host_os.rfind('solaris') > -1):
+        elif (host_os.rfind('solaris') > -1):
             conf.CHECK_FUNCS_IN('sendfile', 'sendfilev')
             conf.CHECK_CODE('''
-                           #include <sys/sendfile.h>
-                           int sfvcnt;
-                           size_t xferred;
-                           struct sendfilevec vec[2];
-                           ssize_t nwritten;
-                           int tofd;
-                           sfvcnt = 2;
-                           vec[0].sfv_fd = SFV_FD_SELF;
-                           vec[0].sfv_flag = 0;
-                           vec[0].sfv_off = 0;
-                           vec[0].sfv_len = 0;
-                           vec[1].sfv_fd = 0;
-                           vec[1].sfv_flag = 0;
-                           vec[1].sfv_off = 0;
-                           vec[1].sfv_len = 0;
-                           nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
-                           ''',
-                           '_HAVE_SENDFILEV64',
-                           msg='Checking for solaris sendfilev64 support')
-            conf.CHECK_CODE('''
-                           #include <sys/sendfile.h>,
-                           int sfvcnt;
-                           size_t xferred;
-                           struct sendfilevec vec[2];
-                           ssize_t nwritten;
-                           int tofd;
-                           sfvcnt = 2;
-                           vec[0].sfv_fd = SFV_FD_SELF;
-                           vec[0].sfv_flag = 0;
-                           vec[0].sfv_off = 0;
-                           vec[0].sfv_len = 0;
-                           vec[1].sfv_fd = 0;
-                           vec[1].sfv_flag = 0;
-                           vec[1].sfv_off = 0;
-                           vec[1].sfv_len = 0;
-                           nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
-                           ''',
-                           '_HAVE_SENDFILEV',
-                           msg='Checking for solaris sendfilev support')
-            if conf.CONFIG_SET('_HAVE_SENDFILEV64'):
-                conf.DEFINE('HAVE_SENDFILEV64', '1')
-                conf.DEFINE('SOLARIS_SENDFILE_API', '1')
-                conf.DEFINE('WITH_SENDFILE', '1')
-            elif conf.CONFIG_SET('_HAVE_SENDFILEV'):
+                            #include <sys/sendfile.h>,
+                            int sfvcnt;
+                            size_t xferred;
+                            struct sendfilevec vec[2];
+                            ssize_t nwritten;
+                            int tofd;
+                            sfvcnt = 2;
+                            vec[0].sfv_fd = SFV_FD_SELF;
+                            vec[0].sfv_flag = 0;
+                            vec[0].sfv_off = 0;
+                            vec[0].sfv_len = 0;
+                            vec[1].sfv_fd = 0;
+                            vec[1].sfv_flag = 0;
+                            vec[1].sfv_off = 0;
+                            vec[1].sfv_len = 0;
+                            nwritten = sendfilev(tofd, vec, sfvcnt, &xferred);
+                            ''',
+                            '_HAVE_SENDFILEV',
+                            msg='Checking for solaris sendfilev support')
+            if conf.CONFIG_SET('_HAVE_SENDFILEV'):
                 conf.DEFINE('HAVE_SENDFILEV', '1')
                 conf.DEFINE('SOLARIS_SENDFILE_API', '1')
                 conf.DEFINE('WITH_SENDFILE', '1')
-       elif (host_os.rfind('aix') > -1):
+        elif (host_os.rfind('aix') > -1):
             conf.CHECK_CODE('''
-                           #include <sys/socket.h>
-                           int fromfd, tofd;
-                           size_t total=0;
-                           struct sf_parms hdtrl;
-                           ssize_t nwritten;
-                           off64_t offset;
-                           hdtrl.header_data = 0;
-                           hdtrl.header_length = 0;
-                           hdtrl.file_descriptor = fromfd;
-                           hdtrl.file_offset = 0;
-                           hdtrl.file_bytes = 0;
-                           hdtrl.trailer_data = 0;
-                           hdtrl.trailer_length = 0;
-                           nwritten = send_file(&tofd, &hdtrl, 0);
-                           ''',
-                           '_HAVE_SENDFILE',
-                           msg='Checking for AIX send_file support')
+                            #include <sys/socket.h>
+                            int fromfd, tofd;
+                            size_t total=0;
+                            struct sf_parms hdtrl;
+                            ssize_t nwritten;
+                            hdtrl.header_data = 0;
+                            hdtrl.header_length = 0;
+                            hdtrl.file_descriptor = fromfd;
+                            hdtrl.file_offset = 0;
+                            hdtrl.file_bytes = 0;
+                            hdtrl.trailer_data = 0;
+                            hdtrl.trailer_length = 0;
+                            nwritten = send_file(&tofd, &hdtrl, 0);
+                            ''',
+                            '_HAVE_SENDFILE',
+                            msg='Checking for AIX send_file support')
             if conf.CONFIG_SET('_HAVE_SENDFILE'):
                 conf.DEFINE('HAVE_SENDFILE', '1')
                 conf.DEFINE('AIX_SENDFILE_API', '1')
@@ -1351,17 +1059,12 @@ main() {
     conf.CHECK_CODE('''
 #include <unistd.h>
 main() {
-       char *s = getcwd(NULL,0);
+        char *s = getcwd(NULL,0);
         exit(s != NULL ?  0 : 1);
 }''', 'GETCWD_TAKES_NULL', addmain=False, execute=True,
         msg="getcwd takes a NULL argument")
 
 
-    conf.CHECK_CODE('''enum TDB_ERROR err = TDB_ERR_NESTING''',
-                   'HAVE_TDB_ERR_NESTING',
-                   headers='tdb.h',
-                   msg='Checking whether we have TDB_ERR_NESTING')
-
     # UnixWare 7.x has its getspnam in -lgen
     conf.CHECK_FUNCS_IN('getspnam', 'gen')
     conf.CHECK_FUNCS_IN('getspnam', 'security')
@@ -1549,6 +1252,35 @@ main() {
                 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);
@@ -1562,15 +1294,15 @@ main() {
 
 
     conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
-                   'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
-                   addmain=False,
-                   link=False,
-                   msg='Checking whether we can compile with __attribute__((destructor))')
+                    'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
+                    addmain=False,
+                    link=False,
+                    msg='Checking whether we can compile with __attribute__((destructor))')
 
     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')
+                    '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);
@@ -1621,7 +1353,7 @@ main() {
     # if we include the module loader in iconv
 
     default_static_modules=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
-                                      auth_sam auth_unix auth_winbind auth_wbc auth_server
+                                      auth_sam auth_unix auth_winbind auth_wbc
                                       auth_domain auth_builtin vfs_default
                                       nss_info_template idmap_tdb idmap_passdb
                                       idmap_nss''')
@@ -1629,7 +1361,7 @@ main() {
     default_shared_modules=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
                                       vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
                                       vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 
-                                      auth_script vfs_readahead vfs_xattr_tdb
+                                      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_crossrename vfs_linux_xfs_sgid
@@ -1638,32 +1370,41 @@ main() {
     if Options.options.developer:
         default_static_modules.extend(TO_LIST('pdb_ads auth_netlogond charset_weird'))
         default_shared_modules.extend(TO_LIST('perfcount_test'))
+        default_shared_modules.extend(TO_LIST('vfs_skel_opaque vfs_skel_transparent vfs_shadow_copy_test'))
+        default_shared_modules.extend(TO_LIST('auth_skel pdb_test'))
 
-    default_static_modules.extend(TO_LIST('pdb_samba4 auth_samba4 vfs_dfs_samba4'))
+    if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
+        default_static_modules.extend(TO_LIST('pdb_samba4 auth_samba4 vfs_dfs_samba4'))
 
     if Options.options.with_acl_support and conf.CONFIG_SET('HAVE_POSIX_ACLS'):
         default_static_modules.extend(TO_LIST('vfs_posixacl'))
 
     if conf.CONFIG_SET('HAVE_FREEBSD_SUNACL_H'):
-       default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
+        default_shared_modules.extend(TO_LIST('vfs_zfsacl'))
 
     if conf.CONFIG_SET('HAVE_DIRFD_DECL'):
-       default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
+        default_shared_modules.extend(TO_LIST('vfs_syncops vfs_dirsort'))
 
     if conf.CONFIG_SET('HAVE_STATFS_F_FSID'):
-       default_shared_modules.extend(TO_LIST('vfs_fileid'))
+        default_shared_modules.extend(TO_LIST('vfs_fileid'))
 
     if conf.CONFIG_SET('HAVE_AIO') and (conf.CONFIG_SET('HAVE_MSGHDR_MSG_CONTROL') or conf.CONFIG_SET('HAVE_MSGHDR_MSG_ACCTRIGHTS')):
-       default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
+        default_shared_modules.extend(TO_LIST('vfs_aio_fork'))
+
+    if conf.CONFIG_SET('HAVE_AIO') and Options.options.with_pthreadpool:
+        default_shared_modules.extend(TO_LIST('vfs_aio_pthread'))
+
+    if conf.CONFIG_SET('HAVE_AIO') and conf.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
+        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'))
 
     if conf.CONFIG_SET('DARWINOS'):
-       default_static_modules.extend(TO_LIST('charset_macosxfs'))
+        default_static_modules.extend(TO_LIST('charset_macosxfs'))
 
     if conf.CONFIG_SET('HAVE_GPFS'):
-       default_shared_modules.extend(TO_LIST('vfs_gpfs vfs_gpfs_hsm_notify'))
+        default_shared_modules.extend(TO_LIST('vfs_gpfs vfs_gpfs_hsm_notify'))
 
     explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
     explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')