wafsamba: STANDARD_LIBPATH...
[obnox/samba/samba-obnox.git] / buildtools / wafsamba / samba_conftests.py
index 56ba7da0a53ad13abb6fd0de3419a0d7076d71fd..4d9762ccda6bc79a8ef559b0adb33dd220050836 100644 (file)
@@ -508,6 +508,35 @@ def CHECK_XSLTPROC_MANPAGES(conf):
         print "A local copy of the docbook.xsl wasn't found on your system" \
               " consider installing package like docbook-xsl"
 
+#
+# 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...)
+#
+@conf
+def CHECK_STANDARD_LIBPATH(conf):
+    # at least gcc and clang support this:
+    try:
+        cmd = conf.env.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
+
+    conf.env.STANDARD_LIBPATH = dirlist
+
 
 waf_config_c_parse_flags = config_c.parse_flags;
 def samba_config_c_parse_flags(line, uselib, env):