chiark / gitweb /
User data mechanism protected by locking
[clg] / tools / asdf-extensions.lisp
index 93be2d353f813a313bc6fb7188de130dc82f7b56..576c8f82b4616610c8c834b76c3565af130c3fdc 100644 (file)
@@ -1,20 +1,16 @@
 (in-package :asdf)
 
-(export 'load-dso)
+(export '*dso-extension*)
+
+(defparameter *dso-extension* #-darwin"so" #+darwin"dylib")
 
-(defun concatenate-strings (strings &optional delimiter)
-  (if (not (rest strings))
-      (first strings)
-    (concatenate
-     'string
-     (first strings)
-     (if delimiter (string delimiter) "")
-     (concatenate-strings (rest strings) delimiter))))
 
 ;;; The following code is more or less copied frm sb-bsd-sockets.asd,
 ;;; but extended to allow flags to be set in a general way
 
-(defclass unix-dso (module) ())
+(defclass unix-dso (module)
+  ((ldflags :initform nil :initarg :ldflags)))
+
 (defun unix-name (pathname)
   (namestring 
    (typecase pathname
@@ -27,7 +23,7 @@ (defmethod input-files ((operation compile-op) (dso unix-dso))
 (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))))
@@ -38,12 +34,13 @@ (defmethod perform :after ((operation compile-op) (dso unix-dso))
     (unless (zerop
             (run-shell-command
              "gcc ~A -o ~S ~{~S ~}"
-             (concatenate 'string
-;;                        (sb-ext:posix-getenv "EXTRA_LDFLAGS")
-;;                        " "
-                          #+sunos "-shared -lresolv -lsocket -lnsl"
-                          #+darwin "-bundle"
-                          #-(or darwin sunos) "-shared")
+             (clg-utils:concatenate-strings
+              (cons
+               #+sunos "-shared -lresolv -lsocket -lnsl"
+               #+darwin "-bundle"
+               #-(or darwin sunos) "-shared"
+               (slot-value dso 'ldflags))
+              #\sp)
              dso-name
              (mapcar #'unix-name
                      (mapcan (lambda (c)
@@ -84,7 +81,7 @@ (defmethod output-files ((op compile-op) (c c-source-file))
 (defmethod perform ((op compile-op) (c c-source-file))
   (unless
       (= 0 (run-shell-command "gcc ~A -o ~S -c ~S"
-           (concatenate-strings
+           (clg-utils:concatenate-strings
             (append
              (list "-fPIC")
              (when (slot-value c 'optimization)
@@ -109,7 +106,8 @@ (defmethod perform ((operation load-op) (c c-source-file))
 ;;; Shared libraries
 
 (defclass library (component) 
-  ((libdir :initarg :libdir)))
+  ((libdir :initarg :libdir)
+   (libname :initarg :libname :initform nil)))
 
 
 (defun split-path (path)
@@ -125,8 +123,8 @@ (defun split-path (path)
 
 
 (defmethod component-pathname ((lib library))
-  (make-pathname :type "so"
-                :name (component-name lib)
+  (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))