s3: Remove header==NULL code from db_ctdb_marshall_record
[kai/samba.git] / source3 / wscript
index cc940537ea692f8a81e01ca616da3b1250fc65e1..9a1cd684fd73e2cb9319b5d230194993663d7d4d 100644 (file)
@@ -24,7 +24,7 @@ def set_options(opt):
 
     opt.SAMBA3_ADD_OPTION('winbind')
     opt.SAMBA3_ADD_OPTION('swat')
-    opt.SAMBA3_ADD_OPTION('ads')
+    opt.SAMBA3_ADD_OPTION('ads', default=None) # None means autodetection
     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")
@@ -41,9 +41,10 @@ def set_options(opt):
     opt.SAMBA3_ADD_OPTION('syslog')
     opt.SAMBA3_ADD_OPTION('automount')
     opt.SAMBA3_ADD_OPTION('aio-support')
+    opt.SAMBA3_ADD_OPTION('dmapi', default=False, help="build with DMAPI support")
     opt.SAMBA3_ADD_OPTION('profiling-data', default=False)
 
-    opt.SAMBA3_ADD_OPTION('cluster-support')
+    opt.SAMBA3_ADD_OPTION('cluster-support', default=None)
 
     opt.add_option('--with-ctdb-dir',
                    help=("Directory under which ctdb is installed"),
@@ -160,7 +161,70 @@ main() {
 main() {
         exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
 }''', 'HAVE_KERNEL_SHARE_MODES', addmain=False, execute=True,
-        msg="Checking for krenel share modes")
+        msg="Checking for kernel share modes")
+
+    # check for DMAPI libs
+    Logs.info("Checking for DMAPI library existence")
+    conf.env['dmapi_lib'] = ''
+    samba_dmapi_lib = ''
+    if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dm'):
+        samba_dmapi_lib = 'dm'
+    else:
+        if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'jfsdm'):
+            samba_dmapi_lib = 'jfsdm'
+        else:
+            if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'dmapi'):
+                samba_dmapi_lib = 'dmapi'
+            else:
+                if conf.CHECK_FUNCS_IN('dm_get_eventlist', 'xdsm'):
+                    samba_dmapi_lib = 'xdsm'
+    # only bother to test headers and compilation when a candidate
+    # library has been found
+    if Options.options.with_dmapi == True and samba_dmapi_lib == '':
+        conf.fatal('DMAPI support requested, but no suitable DMAPI library found')
+    else:
+        conf.CHECK_HEADERS('sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h dmapi.h')
+        conf.CHECK_CODE('''
+#include <time.h>      /* needed by Tru64 */
+#include <sys/types.h> /* needed by AIX */
+#ifdef HAVE_XFS_DMAPI_H
+#include <xfs/dmapi.h>
+#elif defined(HAVE_SYS_DMI_H)
+#include <sys/dmi.h>
+#elif defined(HAVE_SYS_JFSDMAPI_H)
+#include <sys/jfsdmapi.h>
+#elif defined(HAVE_SYS_DMAPI_H)
+#include <sys/dmapi.h>
+#elif defined(HAVE_DMAPI_H)
+#include <dmapi.h>
+#endif
+
+/* This link test is designed to fail on IRI 6.4, but should
+ * succeed on Linux, IRIX 6.5 and AIX.
+ */
+int main(int argc, char **argv)
+{
+       char * version;
+       dm_eventset_t events;
+       /* This doesn't take an argument on IRIX 6.4. */
+       dm_init_service(&version);
+       /* IRIX 6.4 expects events to be a pointer. */
+       DMEV_ISSET(DM_EVENT_READ, events);
+
+       return 0;
+}
+''',
+        'USE_DMAPI',
+        addmain=False,
+        execute=False,
+        lib=samba_dmapi_lib,
+        msg='Checking whether DMAPI lib '+samba_dmapi_lib+' can be used')
+
+        if conf.CONFIG_SET('USE_DMAPI'):
+            conf.env['dmapi_lib'] = samba_dmapi_lib
+        else:
+            if Options.options.with_dmapi == True:
+                conf.fatal('DMAPI support requested but not found');
 
     # Check for various members of the stat structure
     conf.CHECK_STRUCTURE_MEMBER('struct stat', 'st_blocks', define='HAVE_STAT_ST_BLOCKS',
@@ -566,55 +630,61 @@ msg.msg_acctrightslen = sizeof(fd);
         conf.SET_TARGET_TYPE('ldap', 'EMPTY')
         conf.SET_TARGET_TYPE('lber', 'EMPTY')
 
-    if Options.options.with_ads:
-        use_ads=True
+    if Options.options.with_ads == False:
+        use_ads = False
+        use_ads_krb5 = False
+        use_ads_ldap = False
+    else:
+        use_ads = True
+        use_ads_krb5 = True
+        use_ads_ldap = True
         if not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC_MD5') and \
            not conf.CONFIG_SET('HAVE_ENCTYPE_ARCFOUR_HMAC'):
             Logs.warn("arcfour-hmac-md5 encryption type not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_MK_REQ_EXTENDED'):
             Logs.warn("krb5_mk_req_extended not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_GET_HOST_REALM'):
             Logs.warn("krb5_get_host_realm not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_FREE_HOST_REALM'):
             Logs.warn("krb5_free_host_realm not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_FWD_TGT_CREDS'):
             Logs.warn("krb5_fwd_tgt_creds found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = 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
+            use_ads_krb5 = 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
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_GET_RENEWED_CREDS'):
             Logs.warn("krb5_get_renewed_creds not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = 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
+            use_ads_krb5 = 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
+            use_ads_krb5 = 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")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_GET_PERMITTED_ENCTYPES') and \
            not conf.CONFIG_SET('HAVE_KRB5_GET_DEFAULT_IN_TKT_ETYPES'):
             Logs.warn("no GET_ENCTYPES_FUNCTIONS detected")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_KT_FREE_ENTRY') and \
            not conf.CONFIG_SET('HAVE_KRB5_FREE_KEYTAB_ENTRY_CONTENTS'):
             Logs.warn("no KT_FREE_FUNCTION detected")
-            use_ads=False
+            use_ads_krb5 = False
         if not conf.CONFIG_SET('HAVE_KRB5_C_VERIFY_CHECKSUM'):
             Logs.warn("krb5_c_verify_checksum_compare not found in -lkrb5")
-            use_ads=False
+            use_ads_krb5 = False
 
         # We don't actually use
         # gsskrb5_extract_authz_data_from_sec_context, but it is a
@@ -624,23 +694,43 @@ msg.msg_acctrightslen = sizeof(fd);
             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
+            use_ads_krb5 = 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
+            use_ads_krb5 = False
 
-        if use_ads:
-            conf.DEFINE('WITH_ADS', '1')
+        if use_ads_krb5:
             conf.DEFINE('HAVE_KRB5', '1')
-            if conf.CONFIG_SET('HAVE_LDAP'):
-                conf.env['HAVE_ADS'] = '1'
+            conf.env['HAVE_KRB5'] = '1'
         else:
-            Logs.warn("krb5 libs don't have all features required for Active Directory support")
             conf.undefine('HAVE_KRB5_H')
             conf.undefine('HAVE_GSSAPI_H')
             conf.undefine('HAVE_GSSAPI_GSSAPI_GENERIC_H')
             conf.undefine('HAVE_GSSAPI_GSSAPI_H')
+            use_ads = False
+
+        if not conf.CONFIG_SET('HAVE_LDAP'):
+            use_ads = False
+            use_ads_ldap = False
+
+    if use_ads:
+        conf.DEFINE('WITH_ADS', '1')
+        conf.env['HAVE_ADS'] = '1'
+        Logs.info("Building with Active Directory support.")
+    elif Options.options.with_ads == False:
+        Logs.info("Building without Active Directory support (--without-ads).")
+    else:
+        if not use_ads_krb5:
+            Logs.warn("Active Directory support not available: krb5 libs don't have all required features")
+        if not use_ads_ldap:
+            Logs.warn("Active Directory support not available: LDAP support ist not available.")
+        if Options.options.with_ads:
+            conf.fatal("Active Directory support not found. Use --without-ads for building without Active Directory support.")
+        else:
+            # this is the auto-mode case
+            Logs.warn("Building without Active Directory support.")
+
 
     if Options.options.with_utmp:
         conf.env.with_utmp = True
@@ -1288,7 +1378,9 @@ main() {
     #
     # checking for clustering extensions (CTDB)
     #
-    if not Options.options.with_cluster_support:
+    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
 
     else:
@@ -1302,9 +1394,12 @@ main() {
         else:
             includes = ''
 
-       if not conf.env.USING_SYSTEM_TDB:
+        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'
+
         have_cluster_support = True
         ctdb_broken = ""
 
@@ -1358,6 +1453,28 @@ main() {
                 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"
+                #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_PROTOCOL_H',
+                addmain=False,
+                includes=includes,
+                msg='Checking for header ctdb_protocol.h')
+
         if have_cluster_support:
             conf.CHECK_CODE('''
                 #define NO_CONFIG_H
@@ -1494,14 +1611,16 @@ main() {
         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")
+        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.warn("building without cluster support: " + ctdb_broken)
+            Logs.info("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,