wafsamba: fix ordering problems with lib-provided and internal RPATHs
[obnox/samba/samba-obnox.git] / buildtools / wafsamba / samba_conftests.py
index ec98ba0d7eea550aa95aee37aa8d9f8283b1db43..f94b0b7ca8ce628dcec3cdc725d59b05ae5a0c3b 100644 (file)
@@ -4,6 +4,7 @@
 import os, shutil, re
 import Build, Configure, Utils
 from Configure import conf
+import config_c
 from samba_utils import *
 
 
@@ -506,3 +507,37 @@ def CHECK_XSLTPROC_MANPAGES(conf):
     if not conf.CONFIG_SET('XSLTPROC_MANPAGES'):
         print "A local copy of the docbook.xsl wasn't found on your system" \
               " consider installing package like docbook-xsl"
+
+
+waf_config_c_parse_flags = config_c.parse_flags;
+def samba_config_c_parse_flags(line, uselib, env):
+    waf_config_c_parse_flags(line, uselib, env)
+
+    try:
+        linkflags = env['LINKFLAGS_' + uselib]
+    except KeyError:
+        linkflags = []
+    for x in linkflags:
+        #
+        # NOTE on special treatment of -Wl,-R and -Wl,-rpath:
+        #
+        # It is important to not put a library provided RPATH
+        # into the LINKFLAGS but in the RPATH instead, since
+        # the provided LINKFLAGS get prepended to our own internal
+        # RPATH later, and hence can potentially lead to linking
+        # in too old versions of our internal libs.
+        #
+        if x.startswith('-Wl,-R,'):
+            rpath = x[7:]
+        elif x.startswith('-Wl,-R'):
+            rpath = x[6:]
+        elif x.startswith('-Wl,-rpath,'):
+            rpath = x[11:]
+        else:
+            continue
+
+        env.append_value('RPATH_' + uselib, rpath)
+        linkflags.remove(x)
+
+    return
+config_c.parse_flags = samba_config_c_parse_flags