Library extensions not hard coded any more
[clg] / tools / asdf-extensions.lisp
index b7a589b..14a4db7 100644 (file)
@@ -1,6 +1,9 @@
 (in-package :asdf)
 
-(export 'load-dso)
+(export '*dso-extension*)
+
+(defvar *dso-extension* #-darwin"so" #+darwin"dylib")
+
 
 (defun concatenate-strings (strings &optional delimiter)
   (if (not (rest strings))
@@ -27,7 +30,7 @@
 (defmethod output-files ((operation compile-op) (dso unix-dso))
   (let ((dir (component-pathname dso)))
     (list
-     (make-pathname :type "so"
+     (make-pathname :type *dso-extension*
                    :name (car (last (pathname-directory dir)))
                    :directory (butlast (pathname-directory dir))
                    :defaults dir))))
                              (module-components dso)))))
       (error 'operation-error :operation operation :component dso))))
 
+#+clisp
+(defvar *loaded-libraries* ())
 
 (defun load-dso (filename)
   #+sbcl(sb-alien:load-shared-object filename)
-  #+cmu(ext:load-foreign filename))
+  #+cmu(ext:load-foreign filename)
+  #+clisp
+  (unless (find filename *loaded-libraries* :test #'equal)
+    (ffi::foreign-library (namestring filename))
+    (push filename *loaded-libraries*)))
 
 
 (defmethod perform ((o load-op) (c unix-dso))
 
 
 (defmethod component-pathname ((lib library))
-  (make-pathname :type "so"
+  (make-pathname :type *dso-extension*
                 :name (component-name lib)
                 :directory (split-path (slot-value lib 'libdir))))
 
        system::*global-table* 
        :key #'(lambda (pathname)
                 (when pathname (unix::unix-namestring pathname)))
-       :test #'equal))
+       :test #'equal)
+  #+clisp(find (component-pathname c) *loaded-libraries* :test #'equal))
 
 (defmethod operation-done-p ((o operation) (c library))
   t)