wafsamba: change the default value for SAMBA_MODULE of pyembed to False
[metze/samba/wip.git] / buildtools / wafsamba / wafsamba.py
index 54e5bbebc8a1d7d5e65373fd738e934459bfd7ff..7758affc49648c76a67ad796caf84d7ad93a4bb7 100644 (file)
@@ -23,11 +23,13 @@ import samba_conftests
 import samba_abi
 import tru64cc
 import irixcc
+import hpuxcc
 import generic_cc
 import samba_dist
 import samba_wildcard
 import stale_files
 import symbols
+import pkgconfig
 
 # some systems have broken threading in python
 if os.environ.get('WAF_NOTHREADS') == '1':
@@ -55,6 +57,7 @@ def SAMBA_BUILD_ENV(conf):
     '''create the samba build environment'''
     conf.env.BUILD_DIRECTORY = conf.blddir
     mkdir_p(os.path.join(conf.blddir, LIB_PATH))
+    mkdir_p(os.path.join(conf.blddir, LIB_PATH, "private"))
     mkdir_p(os.path.join(conf.blddir, "modules"))
     mkdir_p(os.path.join(conf.blddir, 'python/samba/dcerpc'))
     # this allows all of the bin/shared and bin/python targets
@@ -100,6 +103,7 @@ def SAMBA_LIBRARY(bld, libname, source,
                   vnum=None,
                   soname=None,
                   cflags='',
+                  ldflags='',
                   external_library=False,
                   realname=None,
                   autoproto=None,
@@ -114,7 +118,7 @@ def SAMBA_LIBRARY(bld, libname, source,
                   target_type='LIBRARY',
                   bundled_extension=True,
                   link_name=None,
-                  abi_file=None,
+                  abi_directory=None,
                   abi_match=None,
                   hide_symbols=False,
                   manpages=None,
@@ -185,11 +189,7 @@ def SAMBA_LIBRARY(bld, libname, source,
     else:
         bundled_name = PRIVATE_NAME(bld, libname, bundled_extension, private_library)
 
-    if private_library:
-        if vnum:
-            Logs.error("vnum is invalid for private libraries")
-            sys.exit(1)
-        vnum = Utils.g_module.VERSION
+    ldflags = TO_LIST(ldflags)
 
     features = 'cc cshlib symlink_lib install_lib'
     if target_type == 'PYTHON':
@@ -198,11 +198,27 @@ def SAMBA_LIBRARY(bld, libname, source,
         # this is quite strange. we should add pyext feature for pyext
         # but that breaks the build. This may be a bug in the waf python tool
         features += ' pyembed'
-    if abi_file:
+
+    if abi_directory:
         features += ' abi_check'
 
-    if abi_file:
-        abi_file = os.path.join(bld.curdir, abi_file)
+    if bld.env.HAVE_LD_VERSION_SCRIPT:
+        vscript = "%s.vscript" % libname
+        if private_library:
+            version = "%s_%s" % (Utils.g_module.APPNAME, Utils.g_module.VERSION)
+        elif vnum:
+            version = "%s_%s" % (libname, vnum)
+        else:
+            version = None
+        if version:
+            bld.ABI_VSCRIPT(libname, abi_directory, version, vscript)
+            ldflags.append("-Wl,--version-script=%s/%s" % (bld.path.abspath(bld.env), vscript))
+            fullname = bld.env.shlib_PATTERN % bundled_name
+            bld.add_manual_dependency(bld.path.find_or_declare(fullname), bld.path.find_or_declare(vscript))
+            if Options.is_install:
+                # also make the .inst file depend on the vscript
+                instname = bld.env.shlib_PATTERN % (bundled_name + '.inst')
+                bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
 
     bld.SET_BUILD_GROUP(group)
     t = bld(
@@ -210,6 +226,7 @@ def SAMBA_LIBRARY(bld, libname, source,
         source          = [],
         target          = bundled_name,
         depends_on      = depends_on,
+        ldflags                = ldflags,
         samba_deps      = deps,
         samba_includes  = includes,
         local_include   = local_include,
@@ -220,7 +237,7 @@ def SAMBA_LIBRARY(bld, libname, source,
         name            = libname,
         samba_realname  = realname,
         samba_install   = install,
-        abi_file        = abi_file,
+        abi_directory   = "%s/%s" % (bld.path.abspath(), abi_directory),
         abi_match       = abi_match,
         private_library = private_library,
         grouping_library=grouping_library
@@ -339,13 +356,12 @@ def SAMBA_MODULE(bld, modname, source,
                  module_init_name='samba_init_module',
                  autoproto=None,
                  autoproto_extra_source='',
-                 aliases=None,
                  cflags='',
                  internal_module=True,
                  local_include=True,
                  vars=None,
                  enabled=True,
-                 pyembed=True,
+                 pyembed=False,
                  ):
     '''define a Samba module.'''
 
@@ -368,37 +384,6 @@ def SAMBA_MODULE(bld, modname, source,
         SET_TARGET_TYPE(bld, modname, 'DISABLED')
         return
 
-    if aliases is not None:
-        # if we have aliases, then create a private base library, and a set
-        # of modules on top of that library
-        if init_function:
-            cflags += " -D%s=%s" % (init_function, module_init_name)
-
-        basename = modname + '-base'
-        bld.SAMBA_LIBRARY(basename,
-                          source,
-                          deps=deps,
-                          cflags=cflags,
-                          autoproto = autoproto,
-                          local_include=local_include,
-                          vars=vars,
-                          pyembed=pyembed,
-                          private_library=True
-                          )
-
-        aliases = TO_LIST(aliases)
-        aliases.append(modname)
-
-        for alias in aliases:
-            bld.SAMBA_MODULE(alias,
-                             source=[],
-                             internal_module=False,
-                             subsystem=subsystem,
-                             init_function=init_function,
-                             deps=basename)
-        return
-
-
     obj_target = modname + '.objlist'
 
     realname = modname
@@ -534,6 +519,8 @@ def SAMBA_GENERATOR(bld, name, rule, source='', target='',
         on_results=True,
         before='cc',
         ext_out='.c',
+        samba_type='GENERATOR',
+        vars = [rule],
         name=name)
 
     if always:
@@ -554,6 +541,7 @@ def SETUP_BUILD_GROUPS(bld):
     bld.env['USING_BUILD_GROUPS'] = True
     bld.add_group('setup')
     bld.add_group('build_compiler_source')
+    bld.add_group('vscripts')
     bld.add_group('base_libraries')
     bld.add_group('generators')
     bld.add_group('compiler_prototypes')
@@ -596,7 +584,7 @@ def ENABLE_TIMESTAMP_DEPENDENCIES(conf):
 
 
 
-t = Task.simple_task_type('copy_script', 'rm -f ${LINK_TARGET} && ln -s ${SRC[0].abspath(env)} ${LINK_TARGET}',
+t = Task.simple_task_type('copy_script', 'rm -f "${LINK_TARGET}" && ln -s "${SRC[0].abspath(env)}" ${LINK_TARGET}',
                           shell=True, color='PINK', ext_in='.bin')
 t.quiet = True
 
@@ -851,62 +839,6 @@ def PUBLIC_HEADERS(bld, public_headers, header_path=None):
 Build.BuildContext.PUBLIC_HEADERS = PUBLIC_HEADERS
 
 
-def subst_at_vars(task):
-    '''substiture @VAR@ style variables in a file'''
-    src = task.inputs[0].srcpath(task.env)
-    tgt = task.outputs[0].bldpath(task.env)
-
-    f = open(src, 'r')
-    s = f.read()
-    f.close()
-    # split on the vars
-    a = re.split('(@\w+@)', s)
-    out = []
-    done_var = {}
-    back_sub = [ ('PREFIX', '${prefix}'), ('EXEC_PREFIX', '${exec_prefix}')]
-    for v in a:
-        if re.match('@\w+@', v):
-            vname = v[1:-1]
-            if not vname in task.env and vname.upper() in task.env:
-                vname = vname.upper()
-            if not vname in task.env:
-                Logs.error("Unknown substitution %s in %s" % (v, task.name))
-                sys.exit(1)
-            v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
-            # now we back substitute the allowed pc vars
-            for (b, m) in back_sub:
-                s = task.env[b]
-                if s == v[0:len(s)]:
-                    if not b in done_var:
-                        # we don't want to substitute the first usage
-                        done_var[b] = True
-                    else:
-                        v = m + v[len(s):]
-                    break
-        out.append(v)
-    contents = ''.join(out)
-    f = open(tgt, 'w')
-    s = f.write(contents)
-    f.close()
-    return 0
-
-
-def PKG_CONFIG_FILES(bld, pc_files, vnum=None):
-    '''install some pkg_config pc files'''
-    dest = '${PKGCONFIGDIR}'
-    dest = bld.EXPAND_VARIABLES(dest)
-    for f in TO_LIST(pc_files):
-        base=os.path.basename(f)
-        t = bld.SAMBA_GENERATOR('PKGCONFIG_%s' % base,
-                                rule=subst_at_vars,
-                                source=f+'.in',
-                                target=f)
-        if vnum:
-            t.env.PACKAGE_VERSION = vnum
-        INSTALL_FILES(bld, dest, f, flat=True, destname=base)
-Build.BuildContext.PKG_CONFIG_FILES = PKG_CONFIG_FILES
-
-
 def MANPAGES(bld, manpages):
     '''build and install manual pages'''
     bld.env.MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'