src/wscript
changeset 600 fd944dbf33c6
parent 537 e8a4183dfe00
child 603 f607815f38f9
--- a/src/wscript	Fri May 11 10:37:01 2007 -0400
+++ b/src/wscript	Sun May 13 12:46:18 2007 +0100
@@ -1,13 +1,43 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
+import Params
+
+all_modules = [
+    'core',
+    'common',
+    'simulator',
+    'node',
+    'internet-node',
+    'devices/p2p',
+    'applications',
+    ]
+
+
 def set_options(opt):
     opt.sub_options('simulator')
+    opt.add_option('--disable-rpath',
+                   help=("Don't link programs with rpath"),
+                   action="store_true", default=False,
+                   dest='disable_rpath')
+
 
 def configure(conf):
     conf.sub_config('core')
     conf.sub_config('simulator')
 
+    conf.env['DISABLE_RPATH'] = Params.g_options.disable_rpath
+
+
 def build(bld):
-    bld.add_subdirs('core common simulator')
-    bld.add_subdirs('node internet-node devices applications')
 
+    ## Add a global RPATH pointing to each module, so that programs can find the libs
+    ## Note: this is slightly evil; we get away because our programs
+    ## and libs are not supposed to be installed system wide.
+    env = bld.env_of_name('default')
+    if not env['DISABLE_RPATH']:
+        for module in all_modules:
+            node = bld.m_curdirnode.find_build(module)
+            env.append_value('RPATH', '-Wl,--rpath=%s' % (node.abspath(env),))
+    
+    bld.add_subdirs(all_modules)
+