build: honor existing LD_LIBRARY_PATH settings when adding shared lib paths
authorAndrew Tridgell <tridge@samba.org>
Thu, 25 Mar 2010 03:20:45 +0000 (14:20 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:27:06 +0000 (20:27 +1000)
buildtools/wafsamba/samba_utils.py
source4/selftest/wscript

index b0a6b1c2a755780d09f2fa7f31d3afe88632655c..814a5771a4cb5997a706d75d8aefdc21640f1f02 100644 (file)
@@ -60,6 +60,17 @@ def runonce(function):
     return wrapper
 
 
+def ADD_LD_LIBRARY_PATH(path):
+    '''add something to LD_LIBRARY_PATH'''
+    if 'LD_LIBRARY_PATH' in os.environ:
+        oldpath = os.environ['LD_LIBRARY_PATH']
+    else:
+        oldpath = ''
+    newpath = oldpath.split(':')
+    if not path in newpath:
+        newpath.append(path)
+        os.environ['LD_LIBRARY_PATH'] = ':'.join(newpath)
+
 def install_rpath(bld):
     '''the rpath value for installation'''
     bld.env['RPATH'] = []
@@ -76,7 +87,7 @@ def build_rpath(bld):
     bld.env['RPATH_ST'] = []
     if bld.env.RPATH_ON_BUILD:
         return ['-Wl,-rpath=%s' % rpath]
-    os.environ['LD_LIBRARY_PATH'] = rpath
+    ADD_LD_LIBRARY_PATH(rpath)
     return []
 
 
index 31a64cfe113d26633e6d8a658703b51dd501dd7f..6c48b8f65b2b9f8b92bd58ce8fdbbe80a06ab896 100644 (file)
@@ -1,7 +1,7 @@
 # selftest main code.
 
 import Scripting, os, Options, Utils, Environment, optparse, sys
-from samba_utils import RUN_COMMAND
+from samba_utils import RUN_COMMAND, ADD_LD_LIBRARY_PATH
 
 def set_options(opt):
     opt.ADD_COMMAND('test', cmd_test)
@@ -73,7 +73,7 @@ def cmd_testonly(opt):
     env.SELFTEST_PREFIX = Options.options.SELFTEST_PREFIX
 
     # this is needed for systems without rpath, or with rpath disabled
-    os.environ['LD_LIBRARY_PATH'] = 'bin/shared'
+    ADD_LD_LIBRARY_PATH('bin/shared')
 
     st_done = os.path.join(env.SELFTEST_PREFIX, 'st_done')
     if os.path.exists(st_done):