mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-03 05:20:16 +02:00
Libtool support for find-and-link-dynamic-module
This commit is contained in:
parent
c718cb0702
commit
ebd79f623f
2 changed files with 55 additions and 17 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
1997-11-28 Tim Pierce <twp@skepsis.com>
|
||||||
|
|
||||||
|
* boot-9.scm (find-and-link-dynamic-module): If a .la file
|
||||||
|
(libtool support file) is found in a module directory, attempt to
|
||||||
|
extract the shared library name from that file. If the .la file
|
||||||
|
does not exist, try to link against a .so file. Libtool-generated
|
||||||
|
compiled modules should load more cleanly in Guile now.
|
||||||
|
(try-using-libtool-name, try-using-sharlib-name): New functions.
|
||||||
|
|
||||||
Sun Nov 9 06:10:59 1997 Gary Houston <ghouston@actrix.gen.nz>
|
Sun Nov 9 06:10:59 1997 Gary Houston <ghouston@actrix.gen.nz>
|
||||||
|
|
||||||
* boot-9.scm (set-batch-mode?!, batch-mode?): initialize more
|
* boot-9.scm (set-batch-mode?!, batch-mode?): initialize more
|
||||||
|
|
|
@ -2008,29 +2008,58 @@
|
||||||
#\_))
|
#\_))
|
||||||
(string->list mod-name)))
|
(string->list mod-name)))
|
||||||
'_module))
|
'_module))
|
||||||
(let ((libname
|
|
||||||
|
;; Put the subdirectory for this module in the car of SUBDIR-AND-LIBNAME,
|
||||||
|
;; and the `libname' (the name of the module prepended by `lib') in the cdr
|
||||||
|
;; field. For example, if MODULE-NAME is the list (inet tcp-ip udp), then
|
||||||
|
;; SUBDIR-AND-LIBNAME will be the pair ("inet/tcp-ip" . "libudp").
|
||||||
|
(let ((subdir-and-libname
|
||||||
(let loop ((dirs "")
|
(let loop ((dirs "")
|
||||||
(syms module-name))
|
(syms module-name))
|
||||||
(cond
|
(if (null? (cdr syms))
|
||||||
((null? (cdr syms))
|
(cons dirs (string-append "lib" (car syms)))
|
||||||
(string-append dirs "lib" (car syms) ".so"))
|
(loop (string-append dirs (car syms) "/") (cdr syms)))))
|
||||||
(else
|
|
||||||
(loop (string-append dirs (car syms) "/") (cdr syms))))))
|
|
||||||
(init (make-init-name (apply string-append
|
(init (make-init-name (apply string-append
|
||||||
(map (lambda (s)
|
(map (lambda (s)
|
||||||
(string-append "_" s))
|
(string-append "_" s))
|
||||||
module-name)))))
|
module-name)))))
|
||||||
;; (pk 'libname libname 'init init)
|
(let ((subdir (car subdir-and-libname))
|
||||||
(or-map
|
(libname (cdr subdir-and-libname)))
|
||||||
(lambda (dir)
|
|
||||||
(let ((full (in-vicinity dir libname)))
|
;; Now look in each dir in %LOAD-PATH for `subdir/libfoo.la'. If that
|
||||||
;; (pk 'trying full)
|
;; file exists, fetch the dlname from that file and attempt to link
|
||||||
(if (file-exists? full)
|
;; against it. If `subdir/libfoo.la' does not exist, or does not seem
|
||||||
(begin
|
;; to name any shared library, look for `subdir/libfoo.so' instead and
|
||||||
(link-dynamic-module full init)
|
;; link against that.
|
||||||
#t)
|
(let check-dirs ((dir-list %load-path))
|
||||||
#f)))
|
(if (null? dir-list)
|
||||||
%load-path)))
|
#f
|
||||||
|
(let* ((dir (in-vicinity (car dir-list) subdir))
|
||||||
|
(sharlib-full
|
||||||
|
(or (try-using-libtool-name dir libname)
|
||||||
|
(try-using-sharlib-name dir libname))))
|
||||||
|
(if (and sharlib-full (file-exists? sharlib-full))
|
||||||
|
(link-dynamic-module sharlib-full init)
|
||||||
|
(check-dirs (cdr dir-list)))))))))
|
||||||
|
|
||||||
|
(define (try-using-libtool-name libdir libname)
|
||||||
|
;; FIXME: is `use-modules' legal inside `define'?
|
||||||
|
(use-modules (ice-9 regex))
|
||||||
|
(let ((libtool-filename (in-vicinity libdir
|
||||||
|
(string-append libname ".la"))))
|
||||||
|
(and (file-exists? libtool-filename)
|
||||||
|
(let ((dlname-pattern (make-regexp "^dlname='(.*)'")))
|
||||||
|
(with-input-from-file libtool-filename
|
||||||
|
(lambda ()
|
||||||
|
(let loop ((ln (read-line)))
|
||||||
|
(cond ((eof-object? ln) #f)
|
||||||
|
((regexp-exec dlname-pattern ln)
|
||||||
|
=> (lambda (match)
|
||||||
|
(in-vicinity libdir (match:substring match 1))))
|
||||||
|
(else (loop (read-line)))))))))))
|
||||||
|
|
||||||
|
(define (try-using-sharlib-name libdir libname)
|
||||||
|
(in-vicinity libdir (string-append libname ".so")))
|
||||||
|
|
||||||
(define (link-dynamic-module filename initname)
|
(define (link-dynamic-module filename initname)
|
||||||
(let ((dynobj (dynamic-link filename)))
|
(let ((dynobj (dynamic-link filename)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue