+;;; Shared libraries
+
+(defclass library (component)
+ ((libdir :initarg :libdir :initform nil)
+ (libname :initarg :libname :initform nil)))
+
+
+(defun split-path (path)
+ (labels ((split (path)
+ (unless (zerop (length path))
+ (let ((slash (position #\/ path)))
+ (if slash
+ (cons (subseq path 0 slash) (split (subseq path (1+ slash))))
+ (list path))))))
+ (if (and (not (zerop (length path))) (char= (char path 0) #\/))
+ (cons :absolute (split (subseq path 1)))
+ (cons :relative (split path)))))
+
+
+(defmethod component-pathname ((lib library))
+ (make-pathname :type *dso-extension*
+ :name (or (slot-value lib 'libname) (component-name lib))
+ :directory (split-path (slot-value lib 'libdir))))
+
+(defmethod perform ((o load-op) (c library))
+ (load-shared-object (component-pathname c)))
+
+(defmethod perform ((operation operation) (c library))
+ nil)
+
+(defmethod operation-done-p ((o load-op) (c library))
+ (let ((namestring (ensure-namestring (component-pathname c))))
+ #+sbcl(find namestring sb-alien::*shared-objects* :key #'sb-alien::shared-object-file :test #'equal)
+ #+cmu(rassoc namestring system::*global-table* :test #'equal)
+ #+clisp(find namestring *loaded-libraries* :test #'equal)))
+
+(defmethod operation-done-p ((o operation) (c library))
+ t)