wafsamba: fill PRIVATE_NAME() logic again
[obnox/samba/samba-obnox.git] / buildtools / wafsamba / samba_bundled.py
index 5926ae2d6eb40a7fd31970b03e7d9c5cb9f9d8bc..515590fb01468a1d9218705d8644e661487f205d 100644 (file)
@@ -7,11 +7,25 @@ from samba_utils import *
 def PRIVATE_NAME(bld, name, private_extension, private_library):
     '''possibly rename a library to include a bundled extension'''
 
+    if not private_library:
+        return name
+
     # we now use the same private name for libraries as the public name.
     # see http://git.samba.org/?p=tridge/junkcode.git;a=tree;f=shlib for a
     # demonstration that this is the right thing to do
     # also see http://lists.samba.org/archive/samba-technical/2011-January/075816.html
-    return name
+    if private_extension:
+        return name
+
+    extension = bld.env.PRIVATE_EXTENSION
+
+    if extension and name.startswith('%s' % extension):
+        return name
+
+    if extension and name.endswith('%s' % extension):
+        return name
+
+    return "%s-%s" % (name, extension)
 
 
 def target_in_list(target, lst, default):
@@ -70,14 +84,23 @@ def minimum_library_version(conf, libname, default):
 
 @conf
 def LIB_MAY_BE_BUNDLED(conf, libname):
-    return ('NONE' not in conf.env.BUNDLED_LIBS and
-            '!%s' % libname not in conf.env.BUNDLED_LIBS)
-
+    if libname in conf.env.BUNDLED_LIBS:
+        return True
+    if '!%s' % libname in conf.env.BUNDLED_LIBS:
+        return False
+    if 'NONE' in conf.env.BUNDLED_LIBS:
+        return False
+    return True
 
 @conf
 def LIB_MUST_BE_BUNDLED(conf, libname):
-    return ('ALL' in conf.env.BUNDLED_LIBS or
-            libname in conf.env.BUNDLED_LIBS)
+    if libname in conf.env.BUNDLED_LIBS:
+        return True
+    if '!%s' % libname in conf.env.BUNDLED_LIBS:
+        return False
+    if 'ALL' in conf.env.BUNDLED_LIBS:
+        return True
+    return False
 
 @conf
 def LIB_MUST_BE_PRIVATE(conf, libname):
@@ -111,9 +134,9 @@ def CHECK_BUNDLED_SYSTEM_PKG(conf, libname, minversion='0.0.0',
 @runonce
 @conf
 def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
-                         checkfunctions=None, headers=None,
+                         checkfunctions=None, headers=None, checkcode=None,
                          onlyif=None, implied_deps=None,
-                         require_headers=True, pkg=None):
+                         require_headers=True, pkg=None, set_target=True):
     '''check if a library is available as a system library.
     this first tries via pkg-config, then if that fails
     tries by testing for a specified function in the specified lib
@@ -124,7 +147,7 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
     if found in conf.env:
         return conf.env[found]
 
-    def check_functions_headers():
+    def check_functions_headers_code():
         '''helper function for CHECK_BUNDLED_SYSTEM'''
         if require_headers and headers and not conf.CHECK_HEADERS(headers, lib=libname):
             return False
@@ -133,6 +156,14 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
                                      empty_decl=False, set_target=False)
             if not ok:
                 return False
+        if checkcode is not None:
+            define='CHECK_BUNDLED_SYSTEM_%s' % libname.upper()
+            ok = conf.CHECK_CODE(checkcode, lib=libname,
+                                 headers=headers, local_include=False,
+                                 msg=msg, define=define)
+            conf.CONFIG_RESET(define)
+            if not ok:
+                return False
         return True
 
 
@@ -162,18 +193,20 @@ def CHECK_BUNDLED_SYSTEM(conf, libname, minversion='0.0.0',
     if (conf.check_cfg(package=pkg,
                       args='"%s >= %s" --cflags --libs' % (pkg, minversion),
                       msg=msg, uselib_store=uselib_store) and
-        check_functions_headers()):
-        conf.SET_TARGET_TYPE(libname, 'SYSLIB')
+        check_functions_headers_code()):
+        if set_target:
+            conf.SET_TARGET_TYPE(libname, 'SYSLIB')
         conf.env[found] = True
         if implied_deps:
             conf.SET_SYSLIB_DEPS(libname, implied_deps)
         return True
     if checkfunctions is not None:
-        if check_functions_headers():
+        if check_functions_headers_code():
             conf.env[found] = True
             if implied_deps:
                 conf.SET_SYSLIB_DEPS(libname, implied_deps)
-            conf.SET_TARGET_TYPE(libname, 'SYSLIB')
+            if set_target:
+                conf.SET_TARGET_TYPE(libname, 'SYSLIB')
             return True
     conf.env[found] = False
     if not conf.LIB_MAY_BE_BUNDLED(libname):