waf: Rename some BUNDLED_ functios to PRIVATE_.
[nivanova/samba-autobuild/.git] / buildtools / wafsamba / wafsamba.py
index 3da1e1439a65a652dc11998f5a6b3afd2486e227..eb0c3696cb8c7dc76f520c3156a4ba039ceacafc 100644 (file)
@@ -26,6 +26,7 @@ import irixcc
 import generic_cc
 import samba_dist
 import samba_wildcard
+import stale_files
 
 # some systems have broken threading in python
 if os.environ.get('WAF_NOTHREADS') == '1':
@@ -36,7 +37,7 @@ LIB_PATH="shared"
 os.putenv('PYTHONUNBUFFERED', '1')
 
 
-if Constants.HEXVERSION < 0x105016:
+if Constants.HEXVERSION < 0x105019:
     Logs.error('''
 Please use the version of waf that comes with Samba, not
 a system installed version. See http://wiki.samba.org/index.php/Waf
@@ -106,15 +107,17 @@ def SAMBA_LIBRARY(bld, libname, source,
                   vars=None,
                   install_path=None,
                   install=True,
-                  needs_python=False,
+                  pyembed=False,
+                  pyext=False,
                   target_type='LIBRARY',
                   bundled_extension=True,
                   link_name=None,
                   abi_file=None,
                   abi_match=None,
                   hide_symbols=False,
-                  is_bundled=False,
                   manpages=None,
+                  private_library=False,
+                  grouping_library=False,
                   enabled=True):
     '''define a Samba library'''
 
@@ -148,8 +151,8 @@ def SAMBA_LIBRARY(bld, libname, source,
                         group          = group,
                         autoproto      = autoproto,
                         depends_on     = depends_on,
-                        needs_python   = needs_python,
                         hide_symbols   = hide_symbols,
+                        pyext          = pyext or (target_type == "PYTHON"),
                         local_include  = local_include)
 
     if BUILTIN_LIBRARY(bld, libname):
@@ -163,18 +166,27 @@ def SAMBA_LIBRARY(bld, libname, source,
     deps = TO_LIST(deps)
     deps.append(obj_target)
 
-    if target_type == 'PYTHON' or realname or not is_bundled:
+    realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
+    link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
+
+    # we don't want any public libraries without version numbers
+    if not private_library and vnum is None and target_type != 'PYTHON' and not realname:
+        raise Utils.WafError("public library '%s' must have a vnum" % libname)
+
+    if target_type == 'PYTHON' or realname or not private_library:
         # Sanitize the library name
         bundled_name = libname.lower().replace('_', '-')
         while bundled_name.startswith("lib"):
             bundled_name = bundled_name[3:]
     else:
-        bundled_name = BUNDLED_NAME(bld, libname, bundled_extension)
+        bundled_name = PRIVATE_NAME(bld, libname, bundled_extension, private_library)
 
     features = 'cc cshlib symlink_lib install_lib'
     if target_type == 'PYTHON':
         features += ' pyext'
-    elif needs_python:
+    if pyext or pyembed:
+        # 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:
         features += ' abi_check'
@@ -187,7 +199,6 @@ def SAMBA_LIBRARY(bld, libname, source,
         features        = features,
         source          = [],
         target          = bundled_name,
-        samba_cflags    = CURRENT_CFLAGS(bld, libname, cflags),
         depends_on      = depends_on,
         samba_deps      = deps,
         samba_includes  = includes,
@@ -200,7 +211,8 @@ def SAMBA_LIBRARY(bld, libname, source,
         samba_install   = install,
         abi_file        = abi_file,
         abi_match       = abi_match,
-        is_bundled      = is_bundled
+        private_library = private_library,
+        grouping_library=grouping_library
         )
 
     if realname and not link_name:
@@ -236,7 +248,7 @@ def SAMBA_BINARY(bld, binname, source,
                  manpages=None,
                  local_include=True,
                  subsystem_name=None,
-                 needs_python=False,
+                 pyembed=False,
                  vars=None,
                  install=True,
                  install_path=None,
@@ -251,7 +263,7 @@ def SAMBA_BINARY(bld, binname, source,
         return
 
     features = 'cc cprogram symlink_bin install_bin'
-    if needs_python:
+    if pyembed:
         features += ' pyembed'
 
     obj_target = binname + '.objlist'
@@ -270,9 +282,9 @@ def SAMBA_BINARY(bld, binname, source,
                         group          = group,
                         autoproto      = autoproto,
                         subsystem_name = subsystem_name,
-                        needs_python   = needs_python,
                         local_include  = local_include,
                         use_hostcc     = use_hostcc,
+                        pyext          = pyembed,
                         use_global_deps= use_global_deps)
 
     bld.SET_BUILD_GROUP(group)
@@ -285,7 +297,6 @@ def SAMBA_BINARY(bld, binname, source,
         features       = features,
         source         = [],
         target         = binname,
-        samba_cflags   = CURRENT_CFLAGS(bld, binname, cflags),
         samba_deps     = deps,
         samba_includes = includes,
         local_include  = local_include,
@@ -322,7 +333,9 @@ def SAMBA_MODULE(bld, modname, source,
                  internal_module=True,
                  local_include=True,
                  vars=None,
-                 enabled=True):
+                 enabled=True,
+                 pyembed=True,
+                 ):
     '''define a Samba module.'''
 
     source = bld.EXPAND_VARIABLES(source, vars=vars)
@@ -348,36 +361,70 @@ def SAMBA_MODULE(bld, modname, source,
         SET_TARGET_TYPE(bld, modname, 'DISABLED')
         return
 
-    modnames = [modname] + TO_LIST(aliases)
-    for modname in modnames:
-        obj_target = modname + '.objlist'
-
-        realname = modname
-        if subsystem is not None:
-            deps += ' ' + subsystem
-            while realname.startswith("lib"+subsystem+"_"):
-                realname = realname[len("lib"+subsystem+"_"):]
-            while realname.startswith(subsystem+"_"):
-                realname = realname[len(subsystem+"_"):]
-
-        realname = bld.env.shlib_PATTERN % realname
-        while realname.startswith("lib"):
-            realname = realname[len("lib"):]
-
-        build_link_name = "modules/%s/%s" % (subsystem, realname)
+    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=samba_init_module" % init_function
 
-        bld.SAMBA_LIBRARY(modname,
+        basename = modname + '-base'
+        bld.SAMBA_LIBRARY(basename,
                           source,
                           deps=deps,
                           cflags=cflags,
-                          realname = realname,
                           autoproto = autoproto,
                           local_include=local_include,
                           vars=vars,
-                          link_name=build_link_name,
-                          install_path="${MODULESDIR}/%s" % subsystem
+                          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
+    if subsystem is not None:
+        deps += ' ' + subsystem
+        while realname.startswith("lib"+subsystem+"_"):
+            realname = realname[len("lib"+subsystem+"_"):]
+        while realname.startswith(subsystem+"_"):
+            realname = realname[len(subsystem+"_"):]
+
+    realname = bld.make_libname(realname)
+    while realname.startswith("lib"):
+        realname = realname[len("lib"):]
+
+    build_link_name = "modules/%s/%s" % (subsystem, realname)
+
+    if init_function:
+        cflags += " -D%s=samba_init_module" % init_function
+
+    bld.SAMBA_LIBRARY(modname,
+                      source,
+                      deps=deps,
+                      cflags=cflags,
+                      realname = realname,
+                      autoproto = autoproto,
+                      local_include=local_include,
+                      vars=vars,
+                      link_name=build_link_name,
+                      install_path="${MODULESDIR}/%s" % subsystem,
+                      pyembed=pyembed,
+                      )
+
+
 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
 
 
@@ -403,7 +450,7 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
                     use_global_deps=True,
                     vars=None,
                     hide_symbols=False,
-                    needs_python=False):
+                    pyext=False):
     '''define a Samba subsystem'''
 
     if not enabled:
@@ -426,7 +473,7 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
     bld.SET_BUILD_GROUP(group)
 
     features = 'cc'
-    if needs_python:
+    if pyext:
         features += ' pyext'
 
     t = bld(
@@ -573,7 +620,7 @@ def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
 
 
-def install_file(bld, destdir, file, chmod=0644, flat=False,
+def install_file(bld, destdir, file, chmod=MODE_644, flat=False,
                  python_fixup=False, destname=None, base_name=None):
     '''install a file'''
     destdir = bld.EXPAND_VARIABLES(destdir)
@@ -601,7 +648,7 @@ def install_file(bld, destdir, file, chmod=0644, flat=False,
     bld.install_as(dest, file, chmod=chmod)
 
 
-def INSTALL_FILES(bld, destdir, files, chmod=0644, flat=False,
+def INSTALL_FILES(bld, destdir, files, chmod=MODE_644, flat=False,
                   python_fixup=False, destname=None, base_name=None):
     '''install a set of files'''
     for f in TO_LIST(files):
@@ -611,7 +658,7 @@ def INSTALL_FILES(bld, destdir, files, chmod=0644, flat=False,
 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
 
 
-def INSTALL_WILDCARD(bld, destdir, pattern, chmod=0644, flat=False,
+def INSTALL_WILDCARD(bld, destdir, pattern, chmod=MODE_644, flat=False,
                      python_fixup=False, exclude=None, trim_path=None):
     '''install a set of files matching a wildcard pattern'''
     files=TO_LIST(bld.path.ant_glob(pattern))