waf: support building libraries with a directory prefix
authorAndrew Tridgell <tridge@samba.org>
Thu, 17 Feb 2011 03:42:19 +0000 (14:42 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 18 Feb 2011 04:09:47 +0000 (15:09 +1100)
SAMBA_LIBRARY('libsmb/smbclient') can now be built, which
distinguishes it from the binary 'smbclient'

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

buildtools/wafsamba/samba_abi.py
buildtools/wafsamba/samba_utils.py
buildtools/wafsamba/wafsamba.py

index bd074f8f275cc3fb96d31b3808e1abf9f7b8af47..ebd52103179d12a1659f834e6b53030a79d1d8d2 100644 (file)
@@ -197,6 +197,8 @@ def ABI_VSCRIPT(bld, libname, abi_directory, version, vscript, abi_match=None):
     else:
         source = ''
 
+    libname = os.path.basename(libname)
+    version = os.path.basename(version)
     libname = libname.replace("-", "_").replace("+","_").upper()
     version = version.replace("-", "_").replace("+","_").upper()
 
index b1ddc5a99eb894808a8354b025c1ae34ce3d40c1..54ceba910369b775c49e7bf6a1590f1791312c61 100644 (file)
@@ -560,6 +560,13 @@ def map_shlib_extension(ctx, name, python=False):
     return root1+ext2
 Build.BuildContext.map_shlib_extension = map_shlib_extension
 
+def apply_pattern(filename, pattern):
+    '''apply a filename pattern to a filename that may have a directory component'''
+    dirname = os.path.dirname(filename)
+    if not dirname:
+        return pattern % filename
+    basename = os.path.basename(filename)
+    return os.path.join(dirname, pattern % basename)
 
 def make_libname(ctx, name, nolibprefix=False, version=None, python=False):
     """make a library filename
@@ -569,9 +576,9 @@ def make_libname(ctx, name, nolibprefix=False, version=None, python=False):
               python     : if we should use python module name conventions"""
 
     if python:
-        libname = ctx.env.pyext_PATTERN % name
+        libname = apply_pattern(name, ctx.env.pyext_PATTERN)
     else:
-        libname = ctx.env.shlib_PATTERN % name
+        libname = apply_pattern(name, ctx.env.shlib_PATTERN)
     if nolibprefix and libname[0:3] == 'lib':
         libname = libname[3:]
     if version:
index 83972def10ff8103560f0a237415828e1a08be4f..4c9bf053a157c46f7af0eb33f1633fac7cd2af97 100644 (file)
@@ -217,11 +217,11 @@ def SAMBA_LIBRARY(bld, libname, source,
             vscript = "%s.vscript" % libname
             bld.ABI_VSCRIPT(libname, abi_directory, version, vscript,
                             abi_match)
-            fullname = bld.env.shlib_PATTERN % bundled_name
+            fullname = apply_pattern(bundled_name, bld.env.shlib_PATTERN)
             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')
+                instname = apply_pattern(bundled_name + '.inst', bld.env.shlib_PATTERN)
                 bld.add_manual_dependency(bld.path.find_or_declare(instname), bld.path.find_or_declare(vscript))
             vscript = os.path.join(bld.path.abspath(bld.env), vscript)