(let ((value (get-environment-variable "MITSCHEME_INF_DIRECTORY")))
(if value
(pathname-as-directory value)
- (system-library-directory-pathname)))))
+ (or (%find-library-directory pathname)
+ (system-library-directory-pathname))))))
+
+(define (%find-library-directory pathname)
+ (let ((dir (pathname-directory pathname)))
+ (or (and (pair? dir)
+ (eq? 'RELATIVE (car dir))
+ (pair? (cdr dir))
+ (string? (cadr dir))
+ (let ((libdir (system-library-directory-pathname (cadr dir))))
+ (and libdir
+ (pathname-new-directory libdir
+ (except-last-pair
+ (pathname-directory libdir)))))))))
\f
(define-integrable (dbg-block/layout-first-offset block)
(let ((layout (dbg-block/layout block)))
(%find-library-directory)))
(define (with-system-library-directories directories thunk)
+
(define (existing-directory directory)
(let ((dirpath (pathname-as-directory (merge-pathnames directory))))
(if (file-directory? dirpath)
"find" "directory" "no such directory"
'with-system-library-directories
directories))))
+
(fluid-let ((library-directory-path
- (append library-directory-path
- (map existing-directory directories))))
+ (append (map existing-directory directories)
+ library-directory-path)))
(thunk)))
(define (%find-library-directory)