1 ! Copyright (C) 2013 Björn Lindqvist
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: alien.libraries alien.libraries.finder assocs
5 combinators.short-circuit io io.encodings.utf8 io.files
6 io.files.info io.launcher kernel sequences splitting system ;
8 IN: alien.libraries.finder.linux
13 { ppc.64 "libc6,64bit" }
14 { x86.32 "libc6,x86-32" }
15 { x86.64 "libc6,x86-64" }
18 : ldconfig-cache ( -- seq )
19 "/sbin/ldconfig -p" utf8 [ lines ] with-process-reader rest
20 [ "=>" "" replace "\t " split harvest ] map ;
22 : ldconfig-filter ( -- str )
23 mach-map cpu of "libc6" or "(" ")" surround ;
25 : ldconfig-matches? ( lib this-lib this-arch -- ? )
26 [ start 0 = ] [ ldconfig-filter = ] bi* and ;
28 : ldconfig-find-soname ( lib -- seq )
29 ldconfig-cache [ first2 ldconfig-matches? ] with filter [ first ] map ;
34 "lib" ".so" surround ldconfig-find-soname [
35 { [ exists? ] [ file-info regular-file? ] } 1&&