TODO wafsamba: fix treatment of rpath-linkflags
authorMichael Adam <obnox@samba.org>
Mon, 22 Dec 2014 09:38:37 +0000 (10:38 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 22 Dec 2014 09:51:24 +0000 (10:51 +0100)
buildtools/wafsamba/samba_conftests.py

index f94b0b7ca8ce628dcec3cdc725d59b05ae5a0c3b..56ba7da0a53ad13abb6fd0de3419a0d7076d71fd 100644 (file)
@@ -511,13 +511,18 @@ def CHECK_XSLTPROC_MANPAGES(conf):
 
 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)
+    #
+    # We do a special treatment of the rpath components
+    # in the linkflags line, because currently the upstream
+    # parse_flags function is incomplete with respect to
+    # treatment of the rpath. The remainder of the linkflags
+    # line is later passed to the original funcion.
+    #
+    lst1 = shlex.split(line)
+    lst2 = []
+    while lst1:
+        x = lst1.pop(0)
 
-    try:
-        linkflags = env['LINKFLAGS_' + uselib]
-    except KeyError:
-        linkflags = []
-    for x in linkflags:
         #
         # NOTE on special treatment of -Wl,-R and -Wl,-rpath:
         #
@@ -527,17 +532,28 @@ def samba_config_c_parse_flags(line, uselib, env):
         # RPATH later, and hence can potentially lead to linking
         # in too old versions of our internal libs.
         #
-        if x.startswith('-Wl,-R,'):
+        if x == '-Wl,-rpath' or x == '-Wl,-R':
+            linkflags.remove(x)
+            x = lst1.pop(0)
+            if x.startswith('-Wl,'):
+                rpath = x[4:]
+            else:
+                rpath = x
+        elif x.startswith('-Wl,-R,'):
             rpath = x[7:]
         elif x.startswith('-Wl,-R'):
             rpath = x[6:]
         elif x.startswith('-Wl,-rpath,'):
             rpath = x[11:]
         else:
+            lst2.append(x)
             continue
 
         env.append_value('RPATH_' + uselib, rpath)
-        linkflags.remove(x)
+
+    line2 = ' '.join(lst2)
+    waf_config_c_parse_flags(line2, uselib, env)
 
     return
+
 config_c.parse_flags = samba_config_c_parse_flags