2014-04-28 04:41:31 -04:00
|
|
|
! Copyright (C) 2013 Björn Lindqvist, Doug Coleman.
|
2013-11-16 14:58:37 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license
|
2014-04-28 04:41:31 -04:00
|
|
|
USING: alien.libraries alien.libraries.finder arrays assocs
|
2013-11-16 19:33:17 -05:00
|
|
|
combinators.short-circuit io io.encodings.utf8 io.files
|
2014-04-28 04:41:31 -04:00
|
|
|
io.files.info io.launcher kernel sequences sets splitting system
|
|
|
|
unicode.categories ;
|
2013-11-16 14:58:37 -05:00
|
|
|
IN: alien.libraries.finder.linux
|
|
|
|
|
|
|
|
<PRIVATE
|
|
|
|
|
|
|
|
CONSTANT: mach-map {
|
2014-04-28 04:41:31 -04:00
|
|
|
{ ppc.64 { "libc6" "64bit" } }
|
|
|
|
{ x86.32 { "libc6" "x32" } }
|
|
|
|
{ x86.64 { "libc6" "x86-64" } }
|
2013-11-16 14:58:37 -05:00
|
|
|
}
|
|
|
|
|
2014-04-28 04:41:31 -04:00
|
|
|
: parse-ldconfig-lines ( string -- triple )
|
|
|
|
[
|
|
|
|
"=>" split1 [ [ blank? ] trim ] bi@
|
|
|
|
[ " " split1 [ "()" in? ] trim "," split ] dip 3array
|
|
|
|
] map ;
|
|
|
|
|
|
|
|
: load-ldconfig-cache ( -- seq )
|
|
|
|
"/sbin/ldconfig -p" utf8 [ lines ] with-process-reader
|
|
|
|
rest parse-ldconfig-lines ;
|
2013-11-16 14:58:37 -05:00
|
|
|
|
2014-04-28 04:41:31 -04:00
|
|
|
: ldconfig-arch ( -- str )
|
|
|
|
mach-map cpu of { "libc6" } or ;
|
2013-11-16 14:58:37 -05:00
|
|
|
|
2014-04-28 04:41:31 -04:00
|
|
|
: ldconfig-matches? ( lib triple -- ? )
|
|
|
|
{ [ first head? ] [ nip second ldconfig-arch subset? ] } 2&& ;
|
2013-11-16 14:58:37 -05:00
|
|
|
|
|
|
|
: ldconfig-find-soname ( lib -- seq )
|
2014-04-28 04:41:31 -04:00
|
|
|
load-ldconfig-cache [ ldconfig-matches? ] with filter [ third ] map ;
|
2013-11-16 14:58:37 -05:00
|
|
|
|
|
|
|
PRIVATE>
|
|
|
|
|
2014-06-07 23:48:09 -04:00
|
|
|
M: linux find-library*
|
2013-11-16 19:09:21 -05:00
|
|
|
"lib" ".so" surround ldconfig-find-soname [
|
|
|
|
{ [ exists? ] [ file-info regular-file? ] } 1&&
|
|
|
|
] map-find nip ;
|