waf: allows libraries to be marked as private_library=True
[abartlet/samba.git/.git] / buildtools / wafsamba / wafsamba.py
index 02bb96657431a456c25afe98239102be868de272..42f006eaf0e93154b40fac35df1ccd6db8e9bd69 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':
@@ -115,6 +116,7 @@ def SAMBA_LIBRARY(bld, libname, source,
                   hide_symbols=False,
                   is_bundled=False,
                   manpages=None,
+                  private_library=False,
                   enabled=True):
     '''define a Samba library'''
 
@@ -148,8 +150,8 @@ def SAMBA_LIBRARY(bld, libname, source,
                         group          = group,
                         autoproto      = autoproto,
                         depends_on     = depends_on,
-                        pyembed        = pyembed,
                         hide_symbols   = hide_symbols,
+                        pyext          = (target_type == "PYTHON"),
                         local_include  = local_include)
 
     if BUILTIN_LIBRARY(bld, libname):
@@ -163,13 +165,25 @@ def SAMBA_LIBRARY(bld, libname, source,
     deps = TO_LIST(deps)
     deps.append(obj_target)
 
+    realname = bld.map_shlib_extension(realname, python=(target_type=='PYTHON'))
+    link_name = bld.map_shlib_extension(link_name, python=(target_type=='PYTHON'))
+
+    if private_library:
+        # private libraries always get the 'bundling' treatment with respect
+        # to the library name suffix
+        is_bundled = True
+
+    # 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 is_bundled:
         # 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 = BUNDLED_NAME(bld, libname, bundled_extension, private_library)
 
     features = 'cc cshlib symlink_lib install_lib'
     if target_type == 'PYTHON':
@@ -187,7 +201,7 @@ def SAMBA_LIBRARY(bld, libname, source,
         features        = features,
         source          = [],
         target          = bundled_name,
-        samba_cflags    = CURRENT_CFLAGS(bld, libname, cflags),
+        samba_cflags    = CURRENT_LDFLAGS(bld, libname, cflags),
         depends_on      = depends_on,
         samba_deps      = deps,
         samba_includes  = includes,
@@ -270,9 +284,9 @@ def SAMBA_BINARY(bld, binname, source,
                         group          = group,
                         autoproto      = autoproto,
                         subsystem_name = subsystem_name,
-                        pyembed        = pyembed,
                         local_include  = local_include,
                         use_hostcc     = use_hostcc,
+                        pyext          = pyembed,
                         use_global_deps= use_global_deps)
 
     bld.SET_BUILD_GROUP(group)
@@ -285,7 +299,7 @@ def SAMBA_BINARY(bld, binname, source,
         features       = features,
         source         = [],
         target         = binname,
-        samba_cflags   = CURRENT_CFLAGS(bld, binname, cflags),
+        samba_cflags   = CURRENT_LDFLAGS(bld, binname, cflags),
         samba_deps     = deps,
         samba_includes = includes,
         local_include  = local_include,
@@ -322,7 +336,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)
@@ -360,7 +376,7 @@ def SAMBA_MODULE(bld, modname, source,
             while realname.startswith(subsystem+"_"):
                 realname = realname[len(subsystem+"_"):]
 
-        realname = bld.env.shlib_PATTERN % realname
+        realname = bld.make_libname(realname)
         while realname.startswith("lib"):
             realname = realname[len("lib"):]
 
@@ -378,7 +394,8 @@ def SAMBA_MODULE(bld, modname, source,
                           local_include=local_include,
                           vars=vars,
                           link_name=build_link_name,
-                          install_path="${MODULESDIR}/%s" % subsystem
+                          install_path="${MODULESDIR}/%s" % subsystem,
+                          pyembed=pyembed,
                           )
 
 Build.BuildContext.SAMBA_MODULE = SAMBA_MODULE
@@ -406,7 +423,7 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
                     use_global_deps=True,
                     vars=None,
                     hide_symbols=False,
-                    pyembed=False):
+                    pyext=False):
     '''define a Samba subsystem'''
 
     if not enabled:
@@ -429,8 +446,8 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
     bld.SET_BUILD_GROUP(group)
 
     features = 'cc'
-    if pyembed:
-        features += ' pyembed'
+    if pyext:
+        features += ' pyext'
 
     t = bld(
         features       = features,