build: for unbundled libraries install devel link too
[samba.git] / buildtools / wafsamba / samba_install.py
index 2fbf5da84336e92af7fd7004e2a649a2c6f799ce..74730dd3b26839447a52c6089e845329850819a9 100644 (file)
@@ -7,6 +7,8 @@ import Options
 from TaskGen import feature, before, after
 from samba_utils import *
 
+O755 = 493
+
 @feature('install_bin')
 @after('apply_core')
 @before('apply_link')
@@ -41,7 +43,7 @@ def install_binary(self):
     # tell waf to install the right binary
     bld.install_as(os.path.join(install_path, orig_target),
                    os.path.join(self.path.abspath(bld.env), self.target),
-                   chmod=0755)
+                   chmod=O755)
 
 
 
@@ -80,6 +82,8 @@ def install_library(self):
 
     t.env.append_value('LINKFLAGS', install_ldflags)
 
+    dev_link     = None
+
     if self.samba_realname:
         install_name = self.samba_realname
         install_link = None
@@ -89,6 +93,9 @@ def install_library(self):
         install_name = 'lib%s.so.%s' % (self.target, self.vnum)
         install_link = 'lib%s.so.%s' % (self.target, vnum_base)
         inst_name    = 'lib%s.so' % t.target
+        if self.target == self.name:
+            # only generate the dev link for non-bundled libs
+            dev_link     = 'lib%s.so' % self.target
     else:
         install_name = 'lib%s.so' % self.target
         install_link = None
@@ -101,6 +108,9 @@ def install_library(self):
         # and the symlink if needed
         bld.symlink_as(os.path.join(install_path, install_link),
                        install_name)
+    if dev_link:
+        bld.symlink_as(os.path.join(install_path, dev_link),
+                       install_name)
 
 
 
@@ -115,7 +125,7 @@ def symlink_lib(self):
     if self.target.endswith('.inst'):
         return
 
-    blddir = Utils.g_module.blddir
+    blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
     libpath = self.link_task.outputs[0].abspath(self.env)
 
     # calculat the link target and put it in the environment
@@ -130,9 +140,9 @@ def symlink_lib(self):
 
     link_target = os.path.join(blddir, link_target)
 
-    libpath = os_path_relpath(libpath, os.path.dirname(link_target))
-
     if os.path.lexists(link_target):
+        if os.path.islink(link_target) and os.readlink(link_target) == libpath:
+            return
         os.unlink(link_target)
     os.symlink(libpath, link_target)
 
@@ -145,12 +155,12 @@ def symlink_bin(self):
     if self.target.endswith('.inst'):
         return
 
-    blddir = Utils.g_module.blddir
+    blddir = os.path.dirname(self.bld.srcnode.abspath(self.bld.env))
     binpath = self.link_task.outputs[0].abspath(self.env)
-    bldpath = os.path.join(blddir, self.target)
-
-    binpath = os_path_relpath(binpath, os.path.dirname(bldpath))
+    bldpath = os.path.join(self.bld.env.BUILD_DIRECTORY, self.link_task.outputs[0].name)
 
     if os.path.lexists(bldpath):
+        if os.path.islink(bldpath) and os.readlink(bldpath) == binpath:
+            return
         os.unlink(bldpath)
     os.symlink(binpath, bldpath)