build: support systems without rpath
authorAndrew Tridgell <tridge@samba.org>
Sat, 20 Mar 2010 12:41:15 +0000 (23:41 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:26:58 +0000 (20:26 +1000)
buildtools/wafsamba/samba_autoconf.py
buildtools/wafsamba/samba_utils.py
lib/replace/wscript
source4/selftest/wscript

index 4ea29d4058fe5389355bf595b806e56e5047586a..e91409e0a4062d629b911a6d8b60b5a009abbcb5 100644 (file)
@@ -409,3 +409,12 @@ def CURRENT_CFLAGS(bld, target, cflags):
     ret = TO_LIST(cflags)
     ret.extend(list)
     return ret
+
+@conf
+def CHECK_RPATH_SUPPORT(conf):
+    '''see if the system supports rpath'''
+    return conf.CHECK_CODE('int x',
+                           define='HAVE_RPATH_SUPPORT',
+                           execute=True,
+                           msg='Checking for rpath support',
+                           cflags='-Wl,-rpath=.')
index 9893a86c300b6655f25262f9e6fef9de7dac2945..564b5b82e319d9620d9e6afdd20a859d002582f1 100644 (file)
@@ -62,13 +62,16 @@ def runonce(function):
 
 def set_rpath(bld):
     '''setup the default rpath'''
-    rpath = os.path.normpath('%s/%s' % (bld.env['BUILD_DIRECTORY'], LIB_PATH))
-    bld.env.append_value('RPATH', '-Wl,-rpath=%s' % rpath)
+    if bld.env.RPATH_ON_BUILD:
+        rpath = os.path.normpath('%s/%s' % (bld.env['BUILD_DIRECTORY'], LIB_PATH))
+        bld.env.append_value('RPATH', '-Wl,-rpath=%s' % rpath)
+    else:
+        os.environ['LD_LIBRARY_PATH'] = os.path.normpath('%s/../shared' % bld.srcnode.abspath(bld.env))
 Build.BuildContext.set_rpath = set_rpath
 
 def install_rpath(bld):
     '''the rpath value for installation'''
-    if bld.env['RPATH_ON_INSTALL']:
+    if bld.env.RPATH_ON_INSTALL:
         return ['-Wl,-rpath=%s/lib' % bld.env.PREFIX]
     return []
 
index fa0e40d21a4a34570d721edc63827d700bff1952..d54e18b26b3c58de90bff4769d4b12ebcc1890c6 100644 (file)
@@ -20,9 +20,12 @@ def set_options(opt):
     opt.add_option('--sbindir',
                    help=("system admin executables [PREFIX/sbin]"),
                    action="store", dest='SBINDIR', default='${PREFIX}/sbin')
-    opt.add_option('--enable-rpath',
-                   help=("Enable use of rpath for installed binaries"),
-                   action="store_true", dest='enable_rpath', default=False)
+    opt.add_option('--disable-rpath',
+                   help=("Disable use of rpath for build binaries"),
+                   action="store_true", dest='disable_rpath_build', default=False)
+    opt.add_option('--disable-rpath-install',
+                   help=("Disable use of rpath for installed binaries"),
+                   action="store_true", dest='disable_rpath_install', default=False)
     opt.add_option('--enable-developer',
                    help=("Turn on developer warnings and debugging"),
                    action="store_true", dest='developer', default=False)
@@ -71,7 +74,14 @@ def configure(conf):
     conf.env.BINDIR = Options.options.BINDIR
     conf.env.SBINDIR = Options.options.SBINDIR
 
-    conf.env.RPATH_ON_INSTALL = Options.options.enable_rpath
+    # check for rpath
+    if conf.CHECK_RPATH_SUPPORT():
+        conf.env.RPATH_ON_BUILD   = not Options.options.disable_rpath_build
+        conf.env.RPATH_ON_INSTALL = (conf.env.RPATH_ON_BUILD and
+                                     not Options.options.disable_rpath_install)
+    else:
+        conf.env.RPATH_ON_INSTALL = False
+        conf.env.RPATH_ON_BUILD   = False
 
     # we should use the PIC options in waf instead
     conf.ADD_CFLAGS('-fPIC')
index 4fea799ecf87c9cccefcd4c634de9b2c8b63aa9c..858d92a9aaa50d8f7c8aac304f436de4519bc42e 100644 (file)
@@ -67,6 +67,9 @@ def cmd_testonly(opt):
     if Options.options.VALGRIND_SERVER:
        os.environ['SAMBA_VALGRIND'] = 'xterm -n server -e ../selftest/valgrind_run A=B '
 
+    # this is needed for systems without rpath, or with rpath disabled
+    os.environ['LD_LIBRARY_PATH'] = 'bin/shared'
+
     st_done = 'st/st_done'
     if os.path.exists(st_done):
         os.unlink(st_done)