TODO: build: fix issue with standard libpaths introduced by cups-config and friends
[obnox/samba/samba-obnox.git] / source3 / wscript
index 4f182bf748124a459669da6d4b0103d2a24cff12..bb57db533816f15fd8278f9a3fe504069a001109 100644 (file)
@@ -52,13 +52,6 @@ def set_options(opt):
     opt.SAMBA3_ADD_OPTION('fake-kaserver',
                           help=("Include AFS fake-kaserver support"), default=False)
 
-    opt.add_option('--with-ctdb-dir',
-                   help=("Directory under which ctdb is installed"),
-                   action="store", dest='ctdb_dir', default=None)
-    opt.add_option('--enable-old-ctdb',
-                  help=("enable building against (too) old version of ctdb (default=false)"),
-                  action="store_true", dest='enable_old_ctdb', default=False)
-
     opt.add_option('--with-libcephfs',
                    help=("Directory under which libcephfs is installed"),
                    action="store", dest='libcephfs_dir', default=None)
@@ -84,7 +77,7 @@ def configure(conf):
         conf.ADD_LDFLAGS("-Wl,--export-dynamic", testflags=True)
 
     conf.CHECK_HEADERS('execinfo.h libexc.h libunwind.h netdb.h')
-    conf.CHECK_HEADERS('linux/falloc.h')
+    conf.CHECK_HEADERS('linux/falloc.h linux/ioctl.h')
 
     conf.CHECK_FUNCS('getcwd fchown chmod fchmod mknod')
     conf.CHECK_FUNCS('strtol strchr strupr chflags')
@@ -349,12 +342,28 @@ int main(int argc, char **argv)
 
     # Check if the compiler will optimize out functions
     conf.CHECK_CODE('''
-if (0) {
-    this_function_does_not_exist();
-} else {
-    return 1;
+#include <sys/types.h>
+size_t __unsafe_string_function_usage_here_size_t__(void);
+#define CHECK_STRING_SIZE(d, len) (sizeof(d) != (len) && sizeof(d) != sizeof(char *))
+static size_t push_string_check_fn(void *dest, const char *src, size_t dest_len) {
+       return 0;
+}
+
+#define push_string_check(dest, src, dest_len) \
+    (CHECK_STRING_SIZE(dest, dest_len) \
+    ? __unsafe_string_function_usage_here_size_t__()   \
+    : push_string_check_fn(dest, src, dest_len))
+
+int main(int argc, char **argv) {
+    char outbuf[1024];
+    char *p = outbuf;
+    const char *foo = "bar";
+    p += 31 + push_string_check(p + 31, foo, sizeof(outbuf) - (p + 31 - outbuf));
+    return 0;
 }''', 'HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS',
-        msg="Checking if the compiler will optimize out functions")
+            addmain=False,
+            add_headers=False,
+            msg="Checking if the compiler will optimize out functions")
 
     # Check if the compiler supports the LL suffix on long long integers
     # AIX needs this
@@ -542,6 +551,7 @@ return acl_get_perm_np(permset_d, perm);
         conf.DEFINE('HAVE_NO_AIO', '1')
 
     if host_os.rfind('linux') > -1:
+       conf.CHECK_FUNCS('eventfd')
        conf.CHECK_FUNCS_IN('io_submit', 'aio')
        conf.CHECK_CODE('''
 struct io_event ioev;
@@ -1451,304 +1461,16 @@ main() {
             conf.DEFINE('WITH_QUOTAS', '1')
 
     #
-    # checking for clustering extensions (CTDB)
+    # cluster support (CTDB)
     #
-    if Options.options.with_cluster_support == False:
-        # configure is called with --without-cluster-support,
-        # so don't check for and build w/o ctdb support.
-        have_cluster_support = False
-
+    if not Options.options.with_cluster_support:
+        Logs.info("building without cluster support (--without-cluster-support)")
+        conf.env.with_ctdb = False
     else:
-
-        have_cluster_support = True
-        ctdb_broken = ""
-        CTDB_CFLAGS = ""
-
-        srcdir = os.path.realpath(conf.srcdir)
-        if 'EXTRA_INCLUDES' in conf.env:
-            includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/')
-        else:
-            includes = ''
-
-        if Options.options.ctdb_dir:
-            CTDB_INCLUDE = Options.options.ctdb_dir + '/include'
-        else:
-            CTDB_INCLUDE = conf.srcdir + '/ctdb/include'
-        includes = includes + ' ' + CTDB_INCLUDE
-
-        if not conf.env.USING_SYSTEM_TDB:
-            includes = includes + ' ' + srcdir + '/lib/tdb/include'
-
-        if not conf.env.USING_SYSTEM_TALLOC:
-            includes = includes + ' ' + srcdir + '/lib/talloc'
-
-        ok = conf.CHECK_CODE('''
-            #define NO_CONFIG_H
-            #include "replace.h"
-            #include "system/wait.h"
-            #include "system/network.h"
-            #define private #error __USED_RESERVED_WORD_private__
-            #include <talloc.h>
-            #include <tdb.h>
-            #include <ctdb.h>
-
-            int main(void)
-            {
-                return 0;
-            }
-            ''',
-            'HAVE_CTDB_CHECK_CODE',
-            addmain=False,
-            includes=includes,
-            msg='Checking for header ctdb.h')
-        if ok:
-            CTDB_CFLAGS += ' -DHAVE_CTDB_H=1'
-        else:
-            have_cluster_support = False
-            ctdb_broken = "ctdb.h is required for cluster support"
-
-        conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
-        if have_cluster_support:
-            ok = conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #define private #error __USED_RESERVED_WORD_private__
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                    return 0;
-                }
-                ''',
-                'HAVE_CTDB_CHECK_CODE',
-                addmain=False,
-                includes=includes,
-                msg='Checking for header ctdb_private.h')
-            if ok:
-                CTDB_CFLAGS += ' -DHAVE_CTDB_PRIVATE_H=1'
-            else:
-                have_cluster_support = False
-                ctdb_broken = "ctdb_private.h is required for cluster support"
-
-        conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
-        if have_cluster_support:
-            ok = conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #define private #error __USED_RESERVED_WORD_private__
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_protocol.h>
-
-                int main(void)
-                {
-                    return 0;
-                }
-                ''',
-                'HAVE_CTDB_CHECK_CODE',
-                addmain=False,
-                includes=includes,
-                msg='Checking for header ctdb_protocol.h')
-            if ok:
-                CTDB_CFLAGS += ' -DHAVE_CTDB_PROTOCOL_H=1'
-
-        conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
-        if have_cluster_support:
-            ok = conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                   int i = (int)CTDB_CONTROL_TRANS3_COMMIT;
-                   return 0;
-                }
-                ''',
-                'HAVE_CTDB_CHECK_CODE',
-                addmain=False,
-                includes=includes,
-                msg='Checking for transaction support (TRANS3_COMMIT control)')
-            if ok:
-                CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL=1'
-            else:
-                have_cluster_support = False
-                ctdb_broken = "ctdb transaction support missing or too old"
-
-        conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
-        if have_cluster_support:
-            ok = conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                    int i = (int)CTDB_CONTROL_SCHEDULE_FOR_DELETION;
-                    return 0;
-                }
-                ''',
-                'HAVE_CTDB_CHECK_CODE',
-                addmain=False,
-                includes=includes,
-                msg='Checking for SCHEDULE_FOR_DELETION control')
-            if ok:
-                CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL=1'
-            else:
-                if not Options.options.enable_old_ctdb:
-                    have_cluster_support = False
-                    ctdb_broken = "SCHEDULE_FOR_DELETION control missing"
-                else:
-                    Logs.warn("ignoring missing SCHEDULE_FOR_DELETION control (--enable-old-ctdb)")
-
-        conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
-        if have_cluster_support:
-            ok = 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>
-
-               int main(void)
-               {
-                   int i = (int)CTDB_WANT_READONLY;
-                   return 0;
-               }
-               ''',
-               'HAVE_CTDB_CHECK_CODE',
-               addmain=False,
-               includes=includes,
-               msg='Checking for CTDB readonly records support')
-            if ok:
-                CTDB_CFLAGS += ' -DHAVE_CTDB_WANT_READONLY_DECL=1'
-            else:
-                if not Options.options.enable_old_ctdb:
-                    have_cluster_support = False
-                    ctdb_broken = "support for CTDB readonly records missing"
-                else:
-                    Logs.warn("ignoring missing READONLY support (--enable-old-ctdb)")
-
-        conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
-        if have_cluster_support:
-            ok = conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                    struct ctdb_control_tcp _x;
-                    return 0;
-                }
-                ''',
-                'HAVE_CTDB_CHECK_CODE',
-                addmain=False,
-                includes=includes,
-                msg='Checking for ctdb ipv4 support')
-            if ok:
-                CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP=1'
-            else:
-                have_cluster_support = False
-                ctdb_broken = "missing struct ctdb_control_tcp"
-
-        conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
-        if have_cluster_support:
-            ok = conf.CHECK_CODE('''
-                #define NO_CONFIG_H
-                #include "replace.h"
-                #include "system/wait.h"
-                #include "system/network.h"
-                #include <talloc.h>
-                #include <tdb.h>
-                #include <ctdb.h>
-                #include <ctdb_private.h>
-
-                int main(void)
-                {
-                    struct ctdb_control_tcp_addr _x;
-                    return 0;
-                }
-                ''',
-                'HAVE_CTDB_CHECK_CODE',
-                addmain=False,
-                includes=includes,
-                msg='Checking for ctdb ipv6 support')
-            if ok:
-                CTDB_CFLAGS += ' -DHAVE_STRUCT_CTDB_CONTROL_TCP_ADDR=1'
-
-        conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
-        if have_cluster_support:
-            ok = 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_CHECK_CODE',
-                addmain=False,
-                includes=includes,
-                msg='Checking for CHECK_SRVIDS control')
-            if ok:
-                CTDB_CFLAGS += ' -DHAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL=1'
-            else:
-                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)")
-
-    conf.CONFIG_RESET('HAVE_CTDB_CHECK_CODE')
-    conf.undefine('HAVE_CTDB_CHECK_CODE')
-    if have_cluster_support:
         Logs.info("building with cluster support")
-        conf.env['CTDB_CFLAGS'] = CTDB_CFLAGS
-        conf.env['CTDB_INCLUDE'] = CTDB_INCLUDE
-    else:
-        if Options.options.with_cluster_support == False:
-            Logs.info("building without cluster support (--without-cluster-support)")
-        elif Options.options.with_cluster_support == True:
-            Logs.error("Cluster support not available: " + ctdb_broken)
-            conf.fatal("Cluster support not found, but --with-cluster-support was specified")
-        else:
-            Logs.info("building without cluster support: " + ctdb_broken)
-        conf.env['CTDB_CFLAGS'] = ''
-
+        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',