libgpo: apply some const.
[kai/samba-autobuild/.git] / source3 / wscript
index 566adfbbb6e247f5da40f005433cd852bf997a9c..c6b2421c45b70c310edd89ddaacc6fb810b9ca5f 100644 (file)
@@ -11,7 +11,7 @@ import build.charset
 import samba_utils, samba_version
 import samba3
 
-Options.default_prefix = '/usr/local/samba'
+default_prefix = Options.default_prefix = '/usr/local/samba'
 
 def set_options(opt):
 
@@ -42,7 +42,6 @@ def set_options(opt):
     opt.SAMBA3_ADD_OPTION('cups', with_name="enable", without_name="disable")
     opt.SAMBA3_ADD_OPTION('iprint', with_name="enable", without_name="disable")
     opt.SAMBA3_ADD_OPTION('pam')
-    opt.SAMBA3_ADD_OPTION('pam_smbpass')
     opt.SAMBA3_ADD_OPTION('quotas')
     opt.SAMBA3_ADD_OPTION('sendfile-support')
     opt.SAMBA3_ADD_OPTION('utmp')
@@ -53,13 +52,12 @@ def set_options(opt):
     opt.SAMBA3_ADD_OPTION('dnsupdate')
     opt.SAMBA3_ADD_OPTION('syslog')
     opt.SAMBA3_ADD_OPTION('automount')
-    opt.SAMBA3_ADD_OPTION('aio-support')
     opt.SAMBA3_ADD_OPTION('dmapi', default=None) # None means autodetection
     opt.SAMBA3_ADD_OPTION('fam', default=None) # None means autodetection
     opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
     opt.SAMBA3_ADD_OPTION('libarchive', default=None)
 
-    opt.SAMBA3_ADD_OPTION('cluster-support', default=None)
+    opt.SAMBA3_ADD_OPTION('cluster-support', default=False)
 
     opt.SAMBA3_ADD_OPTION('regedit', default=None)
 
@@ -71,6 +69,7 @@ def set_options(opt):
                    action="store", dest='libcephfs_dir', default=None)
 
     opt.SAMBA3_ADD_OPTION('glusterfs', with_name="enable", without_name="disable", default=True)
+    opt.SAMBA3_ADD_OPTION('cephfs', with_name="enable", without_name="disable", default=True)
 
     opt.add_option('--enable-vxfs',
                   help=("enable support for VxFS (default=no)"),
@@ -112,7 +111,7 @@ def configure(conf):
     conf.CHECK_FUNCS('getpwnam', headers='sys/types.h pwd.h')
     conf.CHECK_FUNCS('fdopendir')
     conf.CHECK_FUNCS('fstatat')
-    conf.CHECK_FUNCS('getpwent_r setenv strcasecmp fcvt fcvtl')
+    conf.CHECK_FUNCS('getpwent_r setenv clearenv strcasecmp fcvt fcvtl')
     conf.CHECK_FUNCS('syslog vsyslog timegm setlocale')
     conf.CHECK_FUNCS_IN('nanosleep', 'rt')
     conf.CHECK_FUNCS('lutimes futimes utimensat futimens')
@@ -137,10 +136,13 @@ long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
         headers='fcntl.h'):
         conf.CHECK_DECLS('splice', reverse=True, headers='fcntl.h')
 
-    # Check for inotify support
-    conf.CHECK_HEADERS('sys/inotify.h')
-    if "HAVE_SYS_INOTIFY_H" in conf.env:
-        conf.DEFINE('HAVE_INOTIFY', 1)
+    # Check for inotify support (Skip if we are SunOS)
+    #NOTE: illumos provides sys/inotify.h but is not an exact match for linux
+    host_os = sys.platform
+    if host_os.rfind('sunos') == -1:
+        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
     conf.CHECK_CODE('''
@@ -206,6 +208,7 @@ main() {
 
     if samba_fam_libs is not None:
         conf.DEFINE('SAMBA_FAM_LIBS', samba_fam_libs)
+        conf.DEFINE('HAVE_FAM', 1)
     else:
         if Options.options.with_fam == True:
             conf.fatal('FAM support requested, but no suitable FAM library found')
@@ -214,14 +217,14 @@ main() {
 
     # check for libarchive (tar command in smbclient)
     # None means autodetect, True/False means enable/disable
-    conf.env['archive_lib'] = ''
+    conf.SET_TARGET_TYPE('archive', 'EMPTY')
     if Options.options.with_libarchive is not False:
         libarchive_mandatory = Options.options.with_libarchive == True
         Logs.info("Checking for libarchive existence")
-        if conf.CHECK_BUNDLED_SYSTEM('libarchive', minversion='3.1.2'):
-            conf.env['archive_lib'] = 'libarchive'
+        if conf.CHECK_HEADERS('archive.h') and conf.CHECK_LIB('archive', shlib=True):
+            conf.CHECK_FUNCS_IN('archive_read_support_filter_all archive_read_free', 'archive')
         elif libarchive_mandatory:
-            conf.fatal('libarchive support requested, but no suitable pkgconfig found')
+            conf.fatal('libarchive support requested, but not found')
 
     # check for DMAPI libs
     if Options.options.with_dmapi == False:
@@ -377,7 +380,7 @@ int main(int argc, char **argv) {
                     msg="Checking for LL suffix on long long integers")
 
     conf.CHECK_FUNCS('''
-_acl __acl atexit 
+_acl __acl atexit
  _chdir __chdir chflags chmod _close __close _closedir
 __closedir crypt16 devnm dirfd
 DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
@@ -455,12 +458,12 @@ utimensat vsyslog _write __write __xstat
 
     if Options.options.with_acl_support:
         if (host_os.rfind('hpux') > -1):
-               Logs.info('Using HPUX ACLs')
+                Logs.info('Using HPUX ACLs')
                 conf.DEFINE('HAVE_HPUX_ACLS',1)
                 conf.DEFINE('POSIX_ACL_NEEDS_MASK',1)
                 default_static_modules.extend(TO_LIST('vfs_hpuxacl'))
-       elif (host_os.rfind('aix') > -1):
-               Logs.info('Using AIX ACLs')
+        elif (host_os.rfind('aix') > -1):
+                Logs.info('Using AIX ACLs')
                 conf.DEFINE('HAVE_AIX_ACLS',1)
                 default_static_modules.extend(TO_LIST('vfs_aixacl vfs_aixacl2'))
         elif (host_os.rfind('darwin') > -1):
@@ -544,34 +547,13 @@ return acl_get_perm_np(permset_d, perm);
     conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
 
     conf.CHECK_CODE('int fd = openat(AT_FDCWD, ".", O_RDONLY);',
-               'HAVE_OPENAT',
-               msg='Checking for openat',
-               headers='fcntl.h')
-
-    if Options.options.with_aio_support:
-        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')
-        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')
-            conf.CHECK_CODE('struct aiocb a; return aio_write(&a);', 'HAVE_AIO_WRITE', msg='Checking for aio_write', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('struct aiocb a; return aio_fsync(1, &a);', 'HAVE_AIO_FSYNC', msg='Checking for aio_fsync', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('struct aiocb a; return aio_return(&a);', 'HAVE_AIO_RETURN', msg='Checking for aio_return', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('struct aiocb a; return aio_error(&a);', 'HAVE_AIO_ERROR', msg='Checking for aio_error', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('struct aiocb a; return aio_cancel(1, &a);', 'HAVE_AIO_CANCEL', msg='Checking for aio_cancel', headers='aio.h', lib='aio rt')
-            conf.CHECK_CODE('const struct aiocb * const a[1]; struct timespec t; return aio_suspend(&a, 1, &t);', 'HAVE_AIO_SUSPEND', msg='Checking for aio_suspend', headers='aio.h', lib='aio rt')
-        if not conf.CONFIG_SET('HAVE_AIO'):
-            conf.DEFINE('HAVE_NO_AIO', '1')
-    else:
-        conf.DEFINE('HAVE_NO_AIO', '1')
+                'HAVE_OPENAT',
+                msg='Checking for openat',
+                headers='fcntl.h')
 
     if host_os.rfind('linux') > -1:
-       conf.CHECK_FUNCS_IN('io_submit', 'aio')
-       conf.CHECK_CODE('''
+        conf.CHECK_FUNCS_IN('io_submit', 'aio')
+        conf.CHECK_CODE('''
 struct io_event ioev;
 struct iocb *ioc;
 io_context_t ctx;
@@ -587,10 +569,10 @@ 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')
+            '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')
 
     conf.CHECK_CODE('''
 struct msghdr msg;
@@ -966,9 +948,6 @@ int i; i = PAM_RADIO_TYPE;
             conf.DEFINE('WITH_PAM', 1)
             conf.DEFINE('WITH_PAM_MODULES', 1)
 
-    if Options.options.with_pam_smbpass:
-        conf.env.with_pam_smbpass = True
-
     seteuid = False
 
 #
@@ -1111,6 +1090,66 @@ syscall(SYS_setgroups32, 0, NULL);
                 execute=True,
                 msg='Checking whether fcntl locking is available')
 
+    conf.CHECK_CODE('''
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#define DATA "ofdtest.fcntl"
+
+int main() {
+        struct flock lck = {
+           .l_whence = SEEK_SET,
+           .l_type = F_WRLCK,
+           .l_start = 0,
+           .l_len = 1,
+           .l_pid = 0,
+        };
+        int ret;
+        int fd1;
+        int fd2;
+        char *testdir = getenv("TESTDIR");
+
+        if (testdir) {
+           if (chdir(testdir) != 0) {
+              goto err;
+           }
+        }
+
+        unlink(DATA);
+        fd1 = open(DATA, O_RDWR|O_CREAT|O_EXCL, 0600);
+        fd2 = open(DATA, O_RDWR);
+        if (fd1 == -1 || fd2 == -1) {
+           goto err;
+        }
+        ret = fcntl(fd1,F_OFD_SETLKW,&lck);
+        if (ret == -1) {
+          goto err;
+        }
+        ret = fcntl(fd2,F_OFD_SETLK,&lck);
+        if (ret != -1) {
+          goto err;
+        }
+        if (errno != EAGAIN) {
+          goto err;
+        }
+        ret = fcntl(fd2,F_OFD_GETLK,&lck);
+        if (ret == -1) {
+          goto err;
+        }
+        unlink(DATA);
+        exit(0);
+err:
+        unlink(DATA);
+        exit(1);
+}''',
+            'HAVE_OFD_LOCKS',
+            addmain=False,
+            execute=True,
+            msg="Checking whether fcntl lock supports open file description locks")
+
 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
     if not conf.CHECK_CODE('''
 #define _XOPEN_SOURCE 600
@@ -1309,7 +1348,7 @@ main() {
                             hdr.trl_cnt = 0;
                             hdtrl.iov_base = (void *)0;
                             hdtrl.iov_len = 0;
-                           ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
+                            ret = sendfile(fromfd, tofd, offset, &nwritten, &hdr, 0);
                             ''',
                             '_HAVE_SENDFILE',
                             msg='Checking for darwin sendfile support')
@@ -1400,6 +1439,7 @@ main() {
     conf.CHECK_FUNCS_IN('getspnam', 'security')
     conf.CHECK_FUNCS_IN('getspnam', 'sec')
 
+    legacy_quota_libs = ''
     if Options.options.with_quotas:
         # For quotas on Veritas VxFS filesystems
         conf.CHECK_HEADERS('sys/fs/vx_quota.h')
@@ -1426,7 +1466,7 @@ main() {
                 msg='for XFS QUOTA in <sys/quota.h>',
                 execute=False,
                 local_include=False)
-        
+
         # For IRIX like dqb_isoftlimit instead of dqb_fsoftlimit in struc dqblk
         conf.CHECK_STRUCTURE_MEMBER('struct dqblk', 'dqb_fsoftlimit', define='HAVE_DQB_FSOFTLIMIT',
                                 headers='sys/quota.h')
@@ -1466,7 +1506,7 @@ main() {
 
         conf.CHECK_CODE('''
                      clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
-''', 
+''',
                         headers="rpc/rpc.h rpc/types.h rpcsvc/rquota.h rpc/nettype.h rpc/xdr.h", 
                         define='HAVE_NFS_QUOTAS',
                         msg='for NFS QUOTAS',
@@ -1480,6 +1520,29 @@ main() {
             conf.DEFINE('HAVE_SYS_QUOTAS', '1')
             conf.DEFINE('WITH_QUOTAS', '1')
 
+        #
+        # check if Legacy quota code can be brought in
+        # if standard interfaces are not supported
+        #
+        if not conf.CONFIG_SET('WITH_QUOTAS'):
+            if host_os.rfind('sunos5') > -1:
+                conf.DEFINE('SUNOS5', '1')
+                legacy_quota_libs = 'nsl'
+            conf.CHECK_CODE('''
+            #define WITH_QUOTAS 1
+            #define AUTOCONF_TEST 1
+            #include "../tests/oldquotas.c"
+            ''',
+                            cflags=conf.env['WERROR_CFLAGS'],
+                            define='WITH_QUOTAS',
+                            lib=legacy_quota_libs,
+                            msg='Checking whether legacy quota code can be used',
+                            execute=False,
+                            addmain=False)
+            if not conf.CONFIG_SET('WITH_QUOTAS'):
+                legacy_quota_libs = ''
+    conf.env['legacy_quota_libs'] = legacy_quota_libs
+
     #
     # cluster support (CTDB)
     #
@@ -1488,15 +1551,8 @@ main() {
         conf.env.with_ctdb = False
     else:
         Logs.info("building with cluster support")
-        conf.env['CTDB_CFLAGS'] = '-DCLUSTER_SUPPORT=1'
-        conf.env['CTDB_INCLUDE'] = conf.srcdir + '/ctdb/include'
         conf.env.with_ctdb = True
-
-    conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
-                    'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
-                    addmain=False,
-                    link=False,
-                    msg='Checking whether we can compile with __attribute__((destructor))')
+        conf.DEFINE('CLUSTER_SUPPORT', 1)
 
     conf.CHECK_CODE('void seekdir(DIR *d, long loc) { return; }',
                     'SEEKDIR_RETURNS_VOID',
@@ -1515,16 +1571,22 @@ main() {
             conf.undefine('WITH_PTHREADPOOL')
 
     if (conf.CHECK_HEADERS('linux/ioctl.h sys/ioctl.h linux/fs.h') and
-       conf.CHECK_DECLS('FS_IOC_GETFLAGS FS_COMPR_FL', headers='linux/fs.h')):
-           conf.DEFINE('HAVE_LINUX_IOCTL', '1')
+        conf.CHECK_DECLS('FS_IOC_GETFLAGS FS_COMPR_FL', headers='linux/fs.h')):
+            conf.DEFINE('HAVE_LINUX_IOCTL', '1')
 
     conf.env['CCFLAGS_CEPHFS'] = "-D_FILE_OFFSET_BITS=64"
     if Options.options.libcephfs_dir:
         conf.env['CPPPATH_CEPHFS'] = Options.options.libcephfs_dir + '/include'
         conf.env['LIBPATH_CEPHFS'] = Options.options.libcephfs_dir + '/lib'
 
-    if conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and conf.CHECK_LIB('cephfs'):
-        conf.DEFINE('HAVE_CEPH', '1')
+    if conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and conf.CHECK_LIB('cephfs', shlib=True) and Options.options.with_cephfs:
+        if Options.options.with_acl_support:
+            conf.DEFINE('HAVE_CEPH', '1')
+            if conf.CHECK_FUNCS_IN('ceph_statx', 'cephfs', headers='cephfs/libcephfs.h'):
+                conf.DEFINE('HAVE_CEPH_STATX', '1')
+        else:
+            Logs.warn("ceph support disabled due to --without-acl-support")
+            conf.undefine('HAVE_CEPH')
 
     if Options.options.with_glusterfs:
         conf.CHECK_CFG(package='glusterfs-api', args='"glusterfs-api >= 4" --cflags --libs',
@@ -1533,16 +1595,19 @@ main() {
         conf.CHECK_LIB('gfapi', shlib=True)
 
         if conf.CONFIG_SET('HAVE_API_GLFS_H'):
-            conf.DEFINE('HAVE_GLUSTERFS', '1')
+            if Options.options.with_acl_support:
+                 conf.DEFINE('HAVE_GLUSTERFS', '1')
+            else:
+                Logs.warn("GlusterFS support disabled due to --without-acl-support")
+                conf.undefine('HAVE_GLUSTERFS')
         else:
-            conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
             conf.undefine('HAVE_GLUSTERFS')
     else:
         conf.SET_TARGET_TYPE('gfapi', 'EMPTY')
         conf.undefine('HAVE_GLUSTERFS')
 
     if Options.options.enable_vxfs:
-       conf.DEFINE('HAVE_VXFS', '1')
+        conf.DEFINE('HAVE_VXFS', '1')
 
     if conf.CHECK_CFG(package='dbus-1', args='--cflags --libs',
                       msg='Checking for dbus', uselib_store="DBUS-1"):
@@ -1582,7 +1647,7 @@ main() {
         versions = ['1.0', '0.16', '0.14']
         for version in versions:
             testlib = 'tracker-sparql-' + version
-            if conf.check_cfg(package=testlib,
+            if conf.CHECK_CFG(package=testlib,
                               args='--cflags --libs',
                               mandatory=False):
                 conf.SET_TARGET_TYPE(testlib, 'SYSLIB')
@@ -1594,6 +1659,7 @@ main() {
         if not conf.env.with_spotlight:
             conf.fatal("Spotlight support requested but tracker-sparql library missing")
         Logs.info("building with Spotlight support")
+        default_static_modules.extend(TO_LIST('rpc_mdssvc_module'))
 
     forced_static_modules.extend(TO_LIST('auth_domain auth_builtin auth_sam auth_winbind'))
     default_static_modules.extend(TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
@@ -1607,10 +1673,10 @@ main() {
                                       vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
                                       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_preopen vfs_catia
                                       vfs_media_harmony vfs_unityed_media vfs_fruit vfs_shell_snap
                                       vfs_commit vfs_worm vfs_crossrename vfs_linux_xfs_sgid
-                                      vfs_time_audit
+                                      vfs_time_audit vfs_offline
                                   '''))
     default_shared_modules.extend(TO_LIST('auth_script idmap_tdb2 idmap_script'))
     # these have broken dependencies
@@ -1621,10 +1687,10 @@ main() {
         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_shared_modules.extend(TO_LIST('vfs_fake_dfq'))
 
     if Options.options.enable_selftest or Options.options.developer:
-       default_shared_modules.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr'))
-        
+        default_shared_modules.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr'))
 
     if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
         default_static_modules.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
@@ -1644,9 +1710,6 @@ main() {
     if Options.options.with_pthreadpool:
         default_shared_modules.extend(TO_LIST('vfs_aio_pthread'))
 
-    if conf.CONFIG_SET('HAVE_AIO'):
-        default_shared_modules.extend(TO_LIST('vfs_aio_posix'))
-
     if conf.CONFIG_SET('HAVE_LINUX_KERNEL_AIO'):
         default_shared_modules.extend(TO_LIST('vfs_aio_linux'))
 
@@ -1661,7 +1724,7 @@ main() {
 
     if (conf.CONFIG_SET('HAVE_LINUX_IOCTL')
       and conf.CONFIG_SET('HAVE_BASENAME') and conf.CONFIG_SET('HAVE_DIRNAME')):
-       default_shared_modules.extend(TO_LIST('vfs_btrfs'))
+        default_shared_modules.extend(TO_LIST('vfs_btrfs'))
 
     if conf.CONFIG_SET("HAVE_CEPH"):
         default_shared_modules.extend(TO_LIST('vfs_ceph'))
@@ -1673,7 +1736,7 @@ main() {
         default_shared_modules.extend(TO_LIST('vfs_vxfs'))
 
     if conf.CONFIG_SET('HAVE_DBUS'):
-       default_shared_modules.extend(TO_LIST('vfs_snapper'))
+        default_shared_modules.extend(TO_LIST('vfs_snapper'))
 
     explicit_shared_modules = TO_LIST(Options.options.shared_modules, delimiter=',')
     explicit_static_modules = TO_LIST(Options.options.static_modules, delimiter=',')
@@ -1760,7 +1823,7 @@ main() {
     static_list = {}
     shared_list = {}
 
-    prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount']
+    prefixes = ['vfs', 'pdb', 'auth', 'nss_info', 'charset', 'idmap', 'gpext', 'perfcount', 'rpc']
     conf.env['MODULE_PREFIXES'] = prefixes
     for p in prefixes:
         for m in final_static_modules: