figure out name of shared module by looking at libtool's .la file

This commit is contained in:
eknauel 2004-01-27 10:21:11 +00:00
parent cdf71124b7
commit aae320b868
1 changed files with 54 additions and 6 deletions

View File

@ -2,13 +2,61 @@
(load-package 'dynamic-externals)
(open 'dynamic-externals)
(open 'external-calls)
(open 'configure)
(run '(let ((initializer-name "scsh_yp_main")
(module-file (string-append "@yplibdir@/" @yphost@
"/libscshyp" "@sharedmoduleext@")))
(dynamic-load module-file)
(call-external (get-external initializer-name))))
(open 'configure)
(open 'signals)
(run
'(define (normalize-la-entry key val)
(let ((left-quotes-rx (rx (: bos #\')))
(right-quotes-rx (rx (: #\' eos)))
(kill-matches
(lambda (rx str)
(regexp-substitute/global #f rx str 'pre 'post))))
(cons (string->symbol key)
(kill-matches left-quotes-rx
(kill-matches right-quotes-rx val))))))
(run
'(define add-la-entry
(let ((splitter (infix-splitter (rx #\=)))
(comment-rx (rx (: bos #\#))))
(lambda (line alist)
(cond
((and (not (regexp-search? comment-rx line))
(string-index line #\=))
(let ((lst (splitter line)))
(if (= 2 (length lst))
(cons (apply normalize-la-entry lst) alist)
(error "Could not read la entry" line list))))
(else alist))))))
(run
'(define (read-libtool-la file-name)
(call-with-input-file
file-name
(lambda (port)
(let lp ((line (read-line port)) (alist '()))
(if (eof-object? line)
alist
(lp (read-line port) (add-la-entry line alist))))))))
(run '(let* ((lib-dir (string-append "@yplibdir@/" @yphost@))
(la-file-name (string-append lib-dir "/libscshyp.la"))
(initializer-name "scsh_yp_main"))
(let ((la-alist (read-libtool-la la-file-name)))
(cond
((assoc 'dlname la-alist)
=> (lambda (p)
(dynamic-load (string-append lib-dir "/" (cdr p)))
(call-external (get-external initializer-name))))
(else
(error "Could not figure out libscshyp's name" la-file-name))))))
(config)
(load "@ypschemedir@/yp-interfaces.scm")
(load "@ypschemedir@/yp-packages.scm")
(user)
;;; Local Variables:
;;; mode:scheme
;;; End: