s3-waf: finally make SO_PEERCRED configure check work with stricter CFLAGS.
[mat/samba.git] / source3 / wscript
index d88faa2104494adb99b09ed7eb656bd790f6b2df..1f4e7c37cfb058975c5f1fac1c4bd00886cd0881 100644 (file)
@@ -15,12 +15,14 @@ import build.charset
 import samba_utils, samba_version
 import samba3
 
+Options.default_prefix = '/usr/local/samba'
+
 def set_options(opt):
     if not os.getenv('TOPLEVEL_BUILD'):
         opt.BUILTIN_DEFAULT('NONE')
         opt.PRIVATE_EXTENSION_DEFAULT('s3')
         opt.RECURSE('../lib/replace')
-        opt.RECURSE('build')
+        opt.RECURSE('../dynconfig')
         opt.RECURSE('selftest')
         opt.RECURSE('../lib/nss_wrapper')
         opt.RECURSE('../lib/socket_wrapper')
@@ -90,8 +92,29 @@ def configure(conf):
         conf.env['build_swat'] = True
 
     if not conf.env.toplevel_build:
+
         conf.RECURSE('../lib/replace')
-        conf.RECURSE('build')
+
+        conf.find_program('python', var='PYTHON', mandatory=True)
+        conf.find_program('perl', var='PERL', mandatory=True)
+        conf.find_program('xsltproc', var='XSLTPROC')
+
+        # enable tool to build python extensions
+        conf.check_tool('python')
+        conf.check_python_version((2,4,2))
+        conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
+
+        if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
+            # Mac OSX needs to have this and it's also needed that the python is compiled with this
+            # otherwise you face errors about common symbols
+            if not conf.CHECK_SHLIB_W_PYTHON("Checking if -fno-common is needed"):
+                conf.ADD_CFLAGS('-fno-common')
+            if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
+                conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
+        if int(conf.env['PYTHON_VERSION'][0]) >= 3:
+           raise Utils.WafError('Python version 3.x is not supported by Samba yet')
+
+        conf.RECURSE('../dynconfig')
         conf.RECURSE('../lib/ccan')
         conf.RECURSE('../lib/tdb_compat')
         conf.RECURSE('../lib/talloc')
@@ -102,6 +125,7 @@ def configure(conf):
         conf.RECURSE('../lib/zlib')
         conf.RECURSE('../libcli/smbreadline')
         conf.RECURSE('../lib/util')
+        conf.RECURSE('../lib/util/charset')
 
         conf.ADD_EXTRA_INCLUDES('''#source3 #source3/include #lib/replace #lib''')
         if not conf.env.USING_SYSTEM_TDB:
@@ -308,7 +332,6 @@ utimensat vsyslog _write __write __xstat
 
     # FIXME: these should be tests for features, but the old build system just
     # checks for OSes.
-    import sys
     host_os = sys.platform
     Logs.info("building on %s" % host_os)
 
@@ -329,7 +352,7 @@ utimensat vsyslog _write __write __xstat
         conf.ADD_CFLAGS('-fno-common')
     elif (host_os.rfind('freebsd') > -1):
         if conf.CHECK_HEADERS('sunacl.h'):
-            conf.define('HAVE_FREEBSD_SUNACL_H', '1')
+            conf.DEFINE('HAVE_FREEBSD_SUNACL_H', '1')
             conf.CHECK_FUNCS_IN('acl', 'sunacl')
         conf.DEFINE('STAT_ST_BLOCKSIZE', '512')
     elif (host_os.rfind('netbsd') > -1):
@@ -419,13 +442,12 @@ return acl_get_perm_np(permset_d, perm);
     conf.CHECK_DECLS('readahead', headers='fcntl.h', always=True)
 
     conf.CHECK_CODE('''
-               #include <sys/types.h>
-               #include <sys/socket.h>],
                struct ucred cred;
                socklen_t cred_len;
                int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);''',
                'HAVE_PEERCRED',
-               msg="Checking whether we can use SO_PEERCRED to get socket credentials")
+               msg="Checking whether we can use SO_PEERCRED to get socket credentials",
+               headers='sys/types.h sys/socket.h')
 
     conf.CHECK_CODE('''
                #if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
@@ -628,7 +650,7 @@ msg.msg_acctrightslen = sizeof(fd);
 
         conf.CHECK_FUNCS_IN('_et_list', 'com_err')
         conf.CHECK_FUNCS_IN('krb5_encrypt_data', 'k5crypto')
-        conf.CHECK_FUNCS_IN('crypto', 'des_set_key')
+       conf.CHECK_FUNCS_IN('des_set_key','crypto')
         conf.CHECK_FUNCS_IN('copy_Authenticator', 'asn1')
         conf.CHECK_FUNCS_IN('roken_getaddrinfo_hostspec', 'roken')
         if conf.CHECK_FUNCS_IN('gss_display_status', 'gssapi') or \
@@ -1691,6 +1713,9 @@ main() {
     if conf.CHECK_HEADERS('gpfs_gpl.h'):
         conf.DEFINE('HAVE_GPFS', '1')
 
+    # Note that all charset 'modules' must actually be static, due to dependency loop issues 
+    # if we include the module loader in iconv
+
     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
@@ -1699,16 +1724,19 @@ main() {
 
     default_shared_modules=TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
                                       vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
-                                      vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850
-                                      charset_CP437 auth_script vfs_readahead vfs_xattr_tdb
+                                      vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 
+                                      auth_script vfs_readahead vfs_xattr_tdb
                                       vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
                                       vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly
                                       vfs_crossrename vfs_linux_xfs_sgid
                                       vfs_time_audit idmap_autorid''')
 
     if Options.options.developer:
-        default_static_modules.extend(TO_LIST('pdb_ads auth_netlogond'))
-        default_shared_modules.extend(TO_LIST('charset_weird perfcount_test'))
+        default_static_modules.extend(TO_LIST('pdb_ads auth_netlogond charset_weird'))
+        default_shared_modules.extend(TO_LIST('perfcount_test'))
+
+    if Options.options.developer or not conf.CONFIG_SET('HAVE_NATIVE_ICONV'):
+        default_static_modules.extend(TO_LIST('charset_CP850 charset_CP437'))
 
     if conf.env.toplevel_build:
         default_static_modules.extend(TO_LIST('pdb_samba4 auth_samba4'))
@@ -1732,7 +1760,7 @@ main() {
         default_static_modules.extend(TO_LIST('pdb_ldap idmap_ldap'))
 
     if conf.CONFIG_SET('DARWINOS'):
-       default_shared_modules.extend(TO_LIST('charset_macosxfs'))
+       default_static_modules.extend(TO_LIST('charset_macosxfs'))
 
     if conf.CONFIG_SET('HAVE_GPFS'):
        default_shared_modules.extend(TO_LIST('vfs_gpfs vfs_gpfs_hsm_notify'))
@@ -1795,6 +1823,12 @@ main() {
                 conf.DEFINE('%s_init' % entry, 'init_samba_module')
                 conf.env[shared_env].append('%s' % entry)
 
+    if not os.getenv('TOPLEVEL_BUILD'):
+        # we don't want PYTHONDIR in config.h, as otherwise changing
+        # --prefix causes a complete rebuild
+        del(conf.env.defines['PYTHONDIR'])
+        del(conf.env.defines['PYTHONARCHDIR'])
+
     conf.SAMBA_CONFIG_H('include/config.h')
 
 def ctags(ctx):