Fix Samba3 on OpenIndiana.
[samba.git] / source3 / wscript
index 9fcf173065265dec067e20f27a5bf7139d142f54..583e97af0f08b81e73067a2307db32d69456a951 100644 (file)
@@ -59,6 +59,17 @@ def set_options(opt):
     opt.SAMBA3_ADD_OPTION('syslog')
     opt.SAMBA3_ADD_OPTION('automount')
     opt.SAMBA3_ADD_OPTION('aio-support')
+    opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
+
+    opt.SAMBA3_ADD_OPTION('cluster-support')
+
+    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)
+
 
 
 def configure(conf):
@@ -180,7 +191,7 @@ main() {
                     'HAVE_KERNEL_OPLOCKS_IRIX', headers='fcntl.h',
                     msg="Checking for IRIX kernel oplock types")
 
-    # Check for krenel share modes
+    # Check for kernel share modes
     conf.CHECK_CODE('''
 #include <sys/types.h>
 #include <fcntl.h>
@@ -269,7 +280,7 @@ _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
-getgrent getgrnam getgrouplist getmntent getpagesize
+getgrent getgrnam getgrouplist getgrset getmntent getpagesize
 getproplist get_proplist_entry getpwanam getpwent_r getrlimit gettext
 glob grantpt hstrerror initgroups innetgr
 inotify_init lgetea lgetxattr listea listxattr llistea llistxattr
@@ -323,6 +334,8 @@ utimensat vsyslog _write __write __xstat
         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
     elif (host_os.rfind('openbsd') > -1):
         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
+    elif (host_os.rfind('sunos') > -1):
+        conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
     # FIXME: Add more checks here.
     else:
         Logs.warn("Unknown host_os '%s', please report this to samba-technical@samba.org" % host_os)
@@ -511,18 +524,22 @@ msg.msg_acctrightslen = sizeof(fd);
                                 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="-Werror-implicit-function-declaration")
+                    cflags=netgrent_cflags)
     conf.CHECK_CODE('getnetgrent', 'HAVE_GETNETGRENT_PROTOTYPE',
                     msg="Checking for getnetgrent prototype",
                     headers='netdb.h netgroup.h',
-                    cflags="-Werror-implicit-function-declaration")
+                    cflags=netgrent_cflags)
     conf.CHECK_CODE('endnetgrent', 'HAVE_ENDNETGRENT_PROTOTYPE',
                     msg="Checking for endnetgrent prototype",
                     headers='netdb.h netgroup.h',
-                    cflags="-Werror-implicit-function-declaration")
+                    cflags=netgrent_cflags)
 
 
     # Look for CUPS
@@ -557,7 +574,7 @@ msg.msg_acctrightslen = sizeof(fd);
 
     # Check for LDAP
     if Options.options.with_ldap:
-        conf.CHECK_HEADERS('ldap.h lber.h')
+        conf.CHECK_HEADERS('ldap.h lber.h ldap_pvt.h')
         conf.CHECK_TYPE('ber_tag_t', 'unsigned int', headers='ldap.h lber.h')
         conf.CHECK_FUNCS_IN('ber_scanf ber_sockbuf_add_io', 'lber')
         conf.CHECK_VARIABLE('LDAP_OPT_SOCKBUF', headers='ldap.h')
@@ -567,7 +584,7 @@ msg.msg_acctrightslen = sizeof(fd);
         conf.CHECK_VARIABLE('LBER_OPT_LOG_PRINT_FN',
                             define='HAVE_LBER_LOG_PRINT_FN', headers='lber.h')
 
-        conf.CHECK_FUNCS_IN('ldap_init ldap_initialize ldap_set_rebind_proc', 'ldap')
+        conf.CHECK_FUNCS_IN('ldap_init ldap_init_fd ldap_initialize ldap_set_rebind_proc', 'ldap')
         conf.CHECK_FUNCS_IN('ldap_add_result_entry', 'ldap')
 
         # Check if ldap_set_rebind_proc() takes three arguments
@@ -602,7 +619,7 @@ msg.msg_acctrightslen = sizeof(fd);
             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 com_err.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'
@@ -615,7 +632,7 @@ msg.msg_acctrightslen = sizeof(fd);
         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', 'gssapi gssapi_krb5 krb5')
+        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
@@ -788,83 +805,7 @@ return krb5_kt_resolve(context, "WRFILE:api", &keytab);
         'HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER', addmain=False,
         link=False,
         msg="Checking for KRB5_DEPRECATED define taking an identifier")
-    elif conf.env.toplevel_build:
-        # setup the right defines for a in-tree heimdal build
-        Logs.info("Using in-tree heimdal kerberos defines")
-        conf.define('HAVE_GSSAPI', 1)
-        conf.define('HAVE_GSSAPI_GSSAPI_H', 1)
-        conf.define('HAVE_AP_OPTS_USE_SUBKEY', 1)
-        conf.define('HAVE_KRB5_ADDRESSES', 1)
-        conf.define('HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK', 1)
-        conf.define('HAVE_KRB5_SET_REAL_TIME', 1)
-        conf.define('HAVE_COM_ERR_H', 1)
-        conf.define('HAVE_ADDR_TYPE_IN_KRB5_ADDRESS', 1)
-        conf.define('HAVE_GSS_DISPLAY_STATUS', 1)
-        conf.define('HAVE_LIBGSSAPI', 1)
-        conf.define('HAVE_ADDR_TYPE_IN_KRB5_ADDRESS', 1)
-        conf.define('HAVE_CHECKSUM_IN_KRB5_CHECKSUM', 1)
-        conf.define('HAVE_DECL_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE', 0)
-        conf.define('HAVE_DECL_KRB5_GET_CREDENTIALS_FOR_USER', 0)
-        conf.define('HAVE_E_DATA_POINTER_IN_KRB5_ERROR', 1)
-        conf.define('HAVE_INITIALIZE_KRB5_ERROR_TABLE', 1)
-        conf.define('HAVE_KRB5_ADDRESSES', 1)
-        conf.define('HAVE_KRB5_AUTH_CON_SETKEY', 1)
-        conf.define('HAVE_KRB5_CRYPTO', 1)
-        conf.define('HAVE_KRB5_CRYPTO_DESTROY', 1)
-        conf.define('HAVE_KRB5_CRYPTO_INIT', 1)
-        conf.define('HAVE_KRB5_C_ENCTYPE_COMPARE', 1)
-        conf.define('HAVE_KRB5_C_VERIFY_CHECKSUM', 1)
-        conf.define('HAVE_FREE_AP_REQ', 1)
-        conf.define('HAVE_KRB5_DECODE_AP_REQ', 1)
-        conf.define('HAVE_KRB5_ENCTYPES_COMPATIBLE_KEYS', 1)
-        conf.define('HAVE_KRB5_ENCTYPE_TO_STRING', 1)
-        conf.define('HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG', 1)
-        conf.define('HAVE_KRB5_FREE_ERROR_CONTENTS', 1)
-        conf.define('HAVE_KRB5_FREE_HOST_REALM', 1)
-        conf.define('HAVE_KRB5_FWD_TGT_CREDS', 1)
-        conf.define('HAVE_KRB5_GET_CREDS', 1)
-        conf.define('HAVE_KRB5_GET_CREDS_OPT_ALLOC', 1)
-        conf.define('HAVE_KRB5_GET_CREDS_OPT_SET_IMPERSONATE', 1)
-        conf.define('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES', 1)
-        conf.define('HAVE_KRB5_GET_HOST_REALM', 1)
-        conf.define('HAVE_KRB5_GET_INIT_CREDS_OPT_ALLOC', 1)
-        conf.define('HAVE_KRB5_GET_INIT_CREDS_OPT_FREE', 1)
-        conf.define('HAVE_KRB5_GET_INIT_CREDS_OPT_GET_ERROR', 1)
-        conf.define('HAVE_KRB5_GET_INIT_CREDS_OPT_SET_PAC_REQUEST', 1)
-        conf.define('HAVE_KRB5_GET_KDC_CRED', 1)
-        conf.define('HAVE_KRB5_GET_PW_SALT', 1)
-        conf.define('HAVE_KRB5_GET_RENEWED_CREDS', 1)
-        conf.define('HAVE_KRB5_KEYBLOCK_KEYVALUE', 1)
-        conf.define('HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK', 1)
-        conf.define('HAVE_KRB5_KRBHST_GET_ADDRINFO', 1)
-        conf.define('HAVE_KRB5_KRBHST_INIT', 1)
-        conf.define('HAVE_KRB5_KT_COMPARE', 1)
-        conf.define('HAVE_KRB5_KT_FREE_ENTRY', 1)
-        conf.define('HAVE_KRB5_KU_OTHER_CKSUM', 1)
-        conf.define('HAVE_KRB5_LOCATE_PLUGIN_H', 1)
-        conf.define('HAVE_KRB5_MK_REQ_EXTENDED', 1)
-        conf.define('HAVE_KRB5_PRINCIPAL_COMPARE_ANY_REALM', 1)
-        conf.define('HAVE_KRB5_PRINCIPAL_GET_COMP_STRING', 1)
-        conf.define('HAVE_KRB5_PRINCIPAL_GET_REALM', 1)
-        conf.define('HAVE_KRB5_REALM_TYPE', 1)
-        conf.define('HAVE_KRB5_SESSION_IN_CREDS', 1)
-        conf.define('HAVE_KRB5_SET_DEFAULT_IN_TKT_ETYPES', 1)
-        conf.define('HAVE_KRB5_SET_REAL_TIME', 1)
-        conf.define('HAVE_KRB5_STRING_TO_KEY', 1)
-        conf.define('HAVE_KRB5_STRING_TO_KEY_SALT', 1)
-        conf.define('HAVE_KRB5_VERIFY_CHECKSUM', 1)
-        conf.define('HAVE_LIBKRB5', 1)
-        conf.define('KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT', 1)
-        conf.define('KRB5_VERIFY_CHECKSUM_ARGS', 6)
-        conf.define('HAVE_ETYPE_IN_ENCRYPTEDDATA', 1)
-        conf.define('KRB5_PRINC_REALM_RETURNS_REALM', 1)
-        conf.define('HAVE_KRB5_PRINCIPAL_GET_REALM', 1)
-        conf.define('HAVE_KRB5_H', 1)
-        conf.define('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', 1)
-        conf.define('HAVE_AP_OPTS_USE_SUBKEY', 1)
-        conf.define('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5', 1)
-        conf.define('HAVE_ENCTYPE_ARCFOUR_HMAC', 1)
-    else:
+    elif not conf.env.toplevel_build:
         conf.SET_TARGET_TYPE('krb5', 'EMPTY')
         conf.SET_TARGET_TYPE('gssapi', 'EMPTY')
         conf.SET_TARGET_TYPE('gssapi_krb5', 'EMPTY')
@@ -1496,6 +1437,192 @@ main() {
         # For sys/quota.h and linux/quota.h
         conf.CHECK_HEADERS('sys/quota.h')
 
+
+    #
+    # checking for clustering extensions (CTDB)
+    #
+    if not Options.options.with_cluster_support:
+        have_cluster_support = False
+
+    else:
+
+        if Options.options.ctdb_dir:
+            conf.ADD_EXTRA_INCLUDES(Options.options.ctdb_dir + '/include')
+
+        srcdir = os.path.realpath(conf.srcdir)
+        if 'EXTRA_INCLUDES' in conf.env:
+            includes = ' '.join(conf.env['EXTRA_INCLUDES']).replace('#', srcdir + '/')
+        else:
+            includes = ''
+
+        have_cluster_support = True
+        ctdb_broken = ""
+
+        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_H',
+            addmain=False,
+            includes=includes,
+            msg='Checking for header ctdb.h')
+
+        if not conf.CONFIG_SET('HAVE_CTDB_H'):
+            have_cluster_support = False
+            ctdb_broken = "ctdb.h is required for cluster support"
+
+        if have_cluster_support:
+            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_PRIVATE_H',
+                addmain=False,
+                includes=includes,
+                msg='Checking for header ctdb_private.h')
+
+            if not conf.CONFIG_SET('HAVE_CTDB_PRIVATE_H'):
+                have_cluster_support = False
+                ctdb_broken = "ctdb_private.h is required for cluster 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_TRANS3_COMMIT;
+                   return 0;
+                }
+                ''',
+                'HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL',
+                addmain=False,
+                includes=includes,
+                msg='Checking for transaction support (TRANS3_COMMIT control)')
+
+            if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_TRANS3_COMMIT_DECL'):
+                have_cluster_support = False
+                ctdb_broken = "ctdb transaction support missing or too old"
+
+        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_SCHEDULE_FOR_DELETION;
+                    return 0;
+                }
+                ''',
+                'HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL',
+                addmain=False,
+                includes=includes,
+                msg='Checking for SCHEDULE_FOR_DELETION control')
+
+            if not conf.CONFIG_SET('HAVE_CTDB_CONTROL_SCHEDULE_FOR_DELETION_DECL'):
+                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)")
+
+        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)
+                {
+                    struct ctdb_control_tcp _x;
+                    return 0;
+                }
+                ''',
+                'HAVE_STRUCT_CTDB_CONTROL_TCP',
+                addmain=False,
+                includes=includes,
+                msg='Checking for ctdb ipv4 support')
+
+            if not conf.CONFIG_SET('HAVE_STRUCT_CTDB_CONTROL_TCP'):
+                have_cluster_support = False
+                ctdb_broken = "missing struct ctdb_control_tcp"
+
+        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)
+                {
+                    struct ctdb_control_tcp_addr _x;
+                    return 0;
+                }
+                ''',
+                'HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR',
+                addmain=False,
+                includes=includes,
+                msg='Checking for ctdb ipv6 support')
+
+    if have_cluster_support:
+        Logs.info("building with cluster support")
+        conf.DEFINE('CLUSTER_SUPPORT', 1);
+    else:
+        if not Options.options.with_cluster_support:
+            Logs.info("building without cluster support")
+        else:
+            Logs.warn("building without cluster support: " + ctdb_broken)
+        conf.undefine('CLUSTER_SUPPORT')
+
+
+
     conf.CHECK_CODE('__attribute__((destructor)) static void cleanup(void) { }',
                    'HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR',
                    addmain=False,
@@ -1507,6 +1634,51 @@ main() {
                    headers='sys/types.h dirent.h',
                    msg='Checking whether seekdir returns void')
 
+    if Options.options.with_profiling_data:
+        conf.DEFINE('WITH_PROFILE', 1);
+
+    PTHREAD_CFLAGS='error'
+    PTHREAD_LDFLAGS='error'
+
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthread'):
+            PTHREAD_CFLAGS='-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS'
+            PTHREAD_LDFLAGS='-lpthread'
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNCS_IN('pthread_attr_init', 'pthreads'):
+            PTHREAD_CFLAGS='-D_THREAD_SAFE'
+            PTHREAD_LDFLAGS='-lpthreads'
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNCS_IN('pthread_attr_init', 'c_r'):
+            PTHREAD_CFLAGS='-D_THREAD_SAFE -pthread'
+            PTHREAD_LDFLAGS='-pthread'
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNC('pthread_attr_init'):
+            PTHREAD_CFLAGS='-D_REENTRANT'
+            PTHREAD_LDFLAGS='-lpthread'
+    # especially for HP-UX, where the CHECK_FUNC macro fails to test for
+    # pthread_attr_init. On pthread_mutex_lock it works there...
+    if PTHREAD_LDFLAGS == 'error':
+        if conf.CHECK_FUNCS_IN('pthread_mutex_lock', 'pthread'):
+            PTHREAD_CFLAGS='-D_REENTRANT'
+            PTHREAD_LDFLAGS='-lpthread'
+
+    if PTHREAD_CFLAGS != 'error' and PTHREAD_LDFLAGS != 'error':
+        conf.ADD_CFLAGS(PTHREAD_CFLAGS)
+        conf.ADD_LDFLAGS(PTHREAD_LDFLAGS)
+        conf.CHECK_HEADERS('pthread.h')
+        conf.DEFINE('HAVE_PTHREAD', '1')
+
+    if Options.options.with_pthreadpool:
+        if conf.CONFIG_SET('HAVE_PTHREAD'):
+            conf.DEFINE('WITH_PTHREADPOOL', '1')
+        else:
+            Logs.warn("pthreadpool support cannot be enabled when pthread support was not found")
+            conf.undefine('WITH_PTHREADPOOL')
+
+    if conf.CHECK_HEADERS('gpfs_gpl.h'):
+        conf.DEFINE('HAVE_GPFS', '1')
+
     default_static_modules=TO_LIST('''pdb_smbpasswd pdb_tdbsam pdb_wbc_sam
                                       auth_sam auth_unix auth_winbind auth_wbc auth_server
                                       auth_domain auth_builtin vfs_default
@@ -1547,6 +1719,9 @@ main() {
     if conf.CONFIG_SET('DARWINOS'):
        default_shared_modules.extend(TO_LIST('charset_macosxfs'))
 
+    if conf.CONFIG_SET('HAVE_GPFS'):
+       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=',')