TODO: build: fix issue with standard libpaths introduced by cups-config and friends
[obnox/samba/samba-obnox.git] / buildtools / wafsamba / wscript
index 1a30d2fa9366ab00b09182de6aa9884f245ff6e6..cd71be56e6ec0a1cf3e50563cbf17aedc470626b 100755 (executable)
@@ -192,6 +192,33 @@ def set_options(opt):
                    help='tag release in git at the same time',
                    type='string', action='store', dest='TAG_RELEASE')
 
+#
+# Determine the standard libpath for the used compiler,
+# so we can later use that to filter out these standard
+# library paths when some tools like cups-config or
+# python-config report standard lib paths with their
+# ldflags (-L...)
+#
+def get_cc_std_libpath(cc):
+    # at least gcc and clang support this:
+    try:
+        cmd = cc + ['-print-search-dirs']
+        out = Utils.cmd_output(cmd).split('\n')
+    except ValueError:
+        # option not supported by compiler - use a standard list of directories
+        dirlist = [ '/usr/lib', '/usr/lib64' ]
+    except:
+        raise Utils.WafError('Unexpected error running "%s"' % (cmd,))
+    else:
+        dirlist = []
+        for line in out:
+            line = line.strip()
+            if line.startswith("libraries: ="):
+                dirliststr = line[len("libraries: ="):]
+                dirlist = [ os.path.normpath(x) for x in dirliststr.split(':') ]
+                break
+
+    return dirlist
 
 @wafsamba.runonce
 def configure(conf):
@@ -211,6 +238,8 @@ def configure(conf):
 
     conf.check_tool('compiler_cc')
 
+    conf.env.STANDARD_LIBPATH = get_cc_std_libpath(conf.env.CC)
+
     # we need git for 'waf dist'
     conf.find_program('git', var='GIT')