lib: Remove StrnCpy
[samba.git] / source3 / wscript
index 6d2d94bae872c7bbccbc70505885697ae6c76c66..458e46bce3f9bce2b7604525a82f3dfe369d966c 100644 (file)
@@ -1,20 +1,23 @@
 #!/usr/bin/env python
 
-srcdir=".."
+srcdir = ".."
 
 import sys, os
 from optparse import SUPPRESS_HELP
-sys.path.insert(0, srcdir+"/buildtools/wafsamba")
+sys.path.insert(0, srcdir + "/buildtools/wafsamba")
 sys.path.insert(0, "source3")
-import wafsamba, Options, Logs, Utils, Scripting
+
+from waflib import Options, Logs, Errors
+import wafsamba
 import build.charset
-import samba_utils, samba_version
+from wafsamba import samba_utils
+from samba_utils import TO_LIST
 import samba3
-import bison, flex
+from waflib.Tools import bison, flex
 
 default_prefix = Options.default_prefix = '/usr/local/samba'
 
-def set_options(opt):
+def options(opt):
 
     opt.add_option('--with-static-modules',
                    help=("Comma-separated list of names of modules to statically link in. "+
@@ -55,7 +58,7 @@ def set_options(opt):
     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('libarchive', default=True)
 
     opt.SAMBA3_ADD_OPTION('cluster-support', default=False)
 
@@ -78,8 +81,6 @@ def set_options(opt):
     opt.SAMBA3_ADD_OPTION('spotlight', with_name="enable", without_name="disable", default=False)
 
 def configure(conf):
-    from samba_utils import TO_LIST
-
     default_static_modules = []
     default_shared_modules = []
     required_static_modules = []
@@ -94,9 +95,11 @@ def configure(conf):
         conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
 
     # We crash without vfs_default
-    required_static_modules.extend(TO_LIST('vfs_default'))
+    # and vfs_not_implemented provides helper function
+    # for other modules
+    required_static_modules.extend(TO_LIST('vfs_default vfs_not_implemented'))
 
-    conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
+    conf.CHECK_HEADERS('netdb.h')
     conf.CHECK_HEADERS('linux/falloc.h linux/ioctl.h')
 
     conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
@@ -167,11 +170,6 @@ main() {
 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
         msg="Checking for Linux kernel oplocks")
 
-    # Check for IRIX kernel oplock types
-    conf.CHECK_CODE('oplock_stat_t t; t.os_state = OP_REVOKE; t.os_dev = 1; t.os_ino = 1;',
-                    'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
-                    msg="Checking for IRIX kernel oplock types")
-
     # Check for kernel share modes
     conf.CHECK_CODE('''
 #include <sys/types.h>
@@ -218,12 +216,20 @@ main() {
     # None means autodetect, True/False means enable/disable
     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_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 not found')
+        else:
+            conf.fatal("libarchive support not found. "
+                       "Try installing libarchive-dev or libarchive-devel. "
+                       "Otherwise, use --without-libarchive to "
+                       "build without libarchive support. "
+                       "libarchive support is required for the smbclient "
+                       "tar-file mode")
+    elif conf.CONFIG_GET('ENABLE_SELFTEST'):
+        raise Errors.WafError('libarchive library required for '
+                             '--enable-selftest')
+
 
     # check for DMAPI libs
     if Options.options.with_dmapi == False:
@@ -386,7 +392,7 @@ DNSServiceRegister _dup __dup _dup2 __dup2 endmntent execl
 _facl __facl _fchdir
 __fchdir fchmod fchown _fcntl __fcntl fcvt fcvtl fdatasync
 _fork __fork fseeko
-fsetxattr _fstat __fstat fsync
+_fstat __fstat fsync
 futimens futimes __fxstat getauthuid
 getcwd _getcwd __getcwd getdents __getdents getdirentries
 getgrent getgrnam getgrouplist getgrset getmntent getpagesize
@@ -592,28 +598,7 @@ msg.msg_accrightslen = sizeof(fd);
                                 headers='unistd.h sys/types.h dirent.h',
                                 define='HAVE_DIRENT_D_OFF')
 
-    conf.CHECK_FUNCS('setnetgrent getnetgrent endnetgrent')
-    if conf.CHECK_CFLAGS('-Werror-implicit-function-declaration'):
-        netgrent_cflags = '-Werror-implicit-function-declaration'
-    else:
-        netgrent_cflags = ''
-    conf.CHECK_CODE('setnetgrent("foo")', 'HAVE_SETNETGRENT_PROTOTYPE',
-                    msg="Checking for setnetgrent prototype",
-                    headers='netdb.h netgroup.h',
-                    cflags=netgrent_cflags)
-    conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
-                    msg="Checking for getnetgrent prototype",
-                    headers='netdb.h netgroup.h',
-                    cflags=netgrent_cflags)
-    conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
-                    msg="Checking for endnetgrent prototype",
-                    headers='netdb.h netgroup.h',
-                    cflags=netgrent_cflags)
-
-    if (conf.CONFIG_SET('HAVE_YP_GET_DEFAULT_DOMAIN') and
-        conf.CONFIG_SET('HAVE_SETNETGRENT') and
-        conf.CONFIG_SET('HAVE_ENDNETGRENT') and
-        conf.CONFIG_SET('HAVE_GETNETGRENT')):
+    if (conf.CONFIG_SET('HAVE_YP_GET_DEFAULT_DOMAIN')):
            conf.DEFINE('HAVE_NETGROUP', '1')
 
     # Look for CUPS
@@ -977,23 +962,23 @@ syscall(SYS_setgroups32, 0, NULL);
         if (conf.CONFIG_SET('USE_LINUX_32BIT_SYSCALLS')):
             seteuid = conf.CHECK_CODE('''
                                 #define AUTOCONF_TEST 1
-                                #define USE_LINUX_THREAD_CREDENTIALS 1
+                                #define HAVE_LINUX_THREAD_CREDENTIALS 1
                                 #define USE_LINUX_32BIT_SYSCALLS 1
                                 #include "../lib/util/setid.c"
                                 #include "./lib/util_sec.c"
                                 ''',
-                                'USE_LINUX_THREAD_CREDENTIALS',
+                                'HAVE_LINUX_THREAD_CREDENTIALS',
                                 addmain=False,
                                 execute=True,
                                 msg="Checking whether we can use Linux thread-specific credentials with 32-bit system calls")
         else:
             seteuid = conf.CHECK_CODE('''
                                 #define AUTOCONF_TEST 1
-                                #define USE_LINUX_THREAD_CREDENTIALS 1
+                                #define HAVE_LINUX_THREAD_CREDENTIALS 1
                                 #include "../lib/util/setid.c"
                                 #include "./lib/util_sec.c"
                                 ''',
-                                'USE_LINUX_THREAD_CREDENTIALS',
+                                'HAVE_LINUX_THREAD_CREDENTIALS',
                                 addmain=False,
                                 execute=True,
                                 msg="Checking whether we can use Linux thread-specific credentials")
@@ -1047,7 +1032,7 @@ syscall(SYS_setgroups32, 0, NULL);
             Logs.warn("--with-dnsupdate=yes but gssapi support not sufficient")
         else:
             conf.DEFINE('WITH_DNS_UPDATES', 1)
-    conf.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h')
+    # 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'):
             conf.DEFINE('VALGRIND', '1')
@@ -1452,7 +1437,7 @@ main() {
                                         headers='rpcsvc/rquota.h',
                                         lib='tirpc')
 
-            # Required fucntion for NFS quote support
+            # Required function for NFS quote support
             conf.CHECK_CODE('''
                             clnt_create("", RQUOTAPROG, RQUOTAVERS, "udp");
                             ''',
@@ -1518,6 +1503,11 @@ main() {
                 legacy_quota_libs = ''
     conf.env['legacy_quota_libs'] = legacy_quota_libs
 
+    conf.CHECK_CODE('(void)unshare(CLONE_FS);',
+                    headers='sched.h',
+                    define='HAVE_UNSHARE_CLONE_FS',
+                    msg='for Linux unshare(CLONE_FS)')
+
     #
     # cluster support (CTDB)
     #
@@ -1542,16 +1532,18 @@ main() {
         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"
+    conf.env['CFLAGS_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'
         conf.env['LIBPATH_CEPH-COMMON'] = Options.options.libcephfs_dir + '/lib/ceph'
+    else:
+        conf.env['LIBPATH_CEPH-COMMON'] = Options.options.LIBDIR + '/ceph'
 
     if (Options.options.with_cephfs and
         conf.CHECK_HEADERS('cephfs/libcephfs.h', False, False, 'cephfs') and
-        conf.CHECK_LIB('cephfs', shlib=True) and
-        conf.CHECK_LIB('ceph-common', shlib=True)):
+        conf.CHECK_LIB('cephfs', shlib=True)):
+        conf.CHECK_LIB('ceph-common', shlib=True)
         if Options.options.with_acl_support:
             conf.DEFINE('HAVE_CEPH', '1')
             if conf.CHECK_FUNCS_IN('ceph_statx', 'cephfs ceph-common',
@@ -1626,16 +1618,16 @@ main() {
     if Options.options.with_spotlight:
 
         Logs.info("Requested Spotlight support, checking for bison")
-        bison.detect(conf)
+        bison.configure(conf)
         if not conf.env['BISON']:
             conf.fatal("Spotlight support requested but bison missing")
         conf.CHECK_COMMAND('%s --version | head -n1' % conf.env['BISON'], msg='Using bison version', define=None, on_target=False)
         Logs.info("Requested Spotlight support, checking for flex")
-        flex.detect(conf)
+        flex.configure(conf)
         if not conf.env['FLEX']:
             conf.fatal("Spotlight support requested but flex missing")
         conf.CHECK_COMMAND('%s --version' % conf.env['FLEX'], msg='Using flex version', define=None, on_target=False)
-        versions = ['1.0', '0.16', '0.14']
+        versions = ['2.0', '1.0', '0.16', '0.14']
         for version in versions:
             testlib = 'tracker-sparql-' + version
             if conf.CHECK_CFG(package=testlib,
@@ -1686,6 +1678,7 @@ main() {
     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_error_inject'))
+        default_shared_modules.extend(TO_LIST('vfs_delay_inject'))
 
     if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
         default_static_modules.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4'))
@@ -1777,13 +1770,13 @@ main() {
         if m.startswith('!'):
             m = m[1:]
             if m in required_static_modules:
-                raise Utils.WafError('These modules are REQUIRED as static modules: %s' %
+                raise Errors.WafError('These modules are REQUIRED as static modules: %s' %
                                      ' '.join(required_static_modules))
             if m in final_static_modules:
                 final_static_modules.remove(m)
             continue
         if m in forced_shared_modules:
-            raise Utils.WafError('These modules MUST be configured as shared modules: %s' %
+            raise Errors.WafError('These modules MUST be configured as shared modules: %s' %
                                  ' '.join(forced_shared_modules))
         if m in final_shared_modules:
             final_shared_modules.remove(m)
@@ -1798,10 +1791,10 @@ main() {
                 final_shared_modules.remove(m)
             continue
         if m in required_static_modules:
-            raise Utils.WafError('These modules are REQUIRED as static modules: %s' %
+            raise Errors.WafError('These modules are REQUIRED as static modules: %s' %
                                  ' '.join(required_static_modules))
         if m in forced_static_modules:
-            raise Utils.WafError('These module MUST be configured as static modules: %s' %
+            raise Errors.WafError('These module MUST be configured as static modules: %s' %
                                  ' '.join(forced_static_modules))
         if m in final_static_modules:
             final_static_modules.remove(m)