]> gitweb.factorcode.org Git - factor.git/commitdiff
alien.libraries.finder.linux: search LD_LIBRARY_PATH if specified.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 13 Oct 2020 17:02:10 +0000 (10:02 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 13 Oct 2020 17:02:10 +0000 (10:02 -0700)
basis/alien/libraries/finder/linux/linux.factor

index 8111b8562252ce416738b9981e7ab77bc94ec5ea..7af0f71c8a250a54236fb839addc5d47a12f1196 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2013 Björn Lindqvist, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license
 USING: alien.libraries.finder arrays assocs
-combinators.short-circuit io io.encodings.utf8 io.files
-io.files.info io.launcher kernel sequences sets splitting system
+combinators.short-circuit environment fry io io.encodings.utf8
+io.launcher kernel locals make sequences sets splitting system
 unicode ;
 IN: alien.libraries.finder.linux
 
@@ -40,8 +40,20 @@ CONSTANT: mach-map {
 : ldconfig-matches? ( lib triple -- ? )
     { [ name-matches? ] [ arch-matches? ] } 2&& ;
 
+: find-ldconfig ( name -- path/f )
+    "lib" prepend load-ldconfig-cache
+    [ ldconfig-matches? ] with find nip ?last ;
+
+:: find-ld ( name -- path/f )
+    "LD_LIBRARY_PATH" os-env [
+        [
+            "ld" , "-t" , ":" split [ "-L" , , ] each
+            "-o" , "/dev/null" , "-l" name append ,
+        ] { } make utf8 [ lines ] with-process-reader* 2drop
+        "lib" name append '[ _ swap subseq? ] find nip
+    ] [ f ] if* ;
+
 PRIVATE>
 
 M: linux find-library*
-    "lib" prepend load-ldconfig-cache
-    [ ldconfig-matches? ] with find nip ?last ;
+    { [ find-ldconfig ] [ find-ld ] } 1|| ;