3 (defun concatenate-strings (strings &optional delimiter)
4 (if (not (rest strings))
9 (if delimiter (string delimiter) "")
10 (concatenate-strings (rest strings) delimiter))))
12 ;;; The following code is more or less copied frm sb-bsd-sockets.asd,
13 ;;; but extended to allow flags set in a general way
15 (defclass unix-dso (module) ())
16 (defun unix-name (pathname)
19 (logical-pathname (translate-logical-pathname pathname))
22 (defmethod asdf::input-files ((operation compile-op) (dso unix-dso))
23 (mapcar #'component-pathname (module-components dso)))
25 (defmethod output-files ((operation compile-op) (dso unix-dso))
26 (let ((dir (component-pathname dso)))
28 (make-pathname :type "so"
29 :name (car (last (pathname-directory dir)))
30 :directory (butlast (pathname-directory dir))
34 (defmethod perform :after ((operation compile-op) (dso unix-dso))
35 (let ((dso-name (unix-name (car (output-files operation dso)))))
38 "gcc ~A -o ~S ~{~S ~}"
40 ;; (sb-ext:posix-getenv "EXTRA_LDFLAGS")
42 #+sunos "-shared -lresolv -lsocket -lnsl"
44 #-(or darwin sunos) "-shared")
48 (output-files operation c))
49 (module-components dso)))))
50 (error 'operation-error :operation operation :component dso))))
52 (defmethod perform ((o load-op) (c unix-dso))
53 (let ((co (make-instance 'compile-op)))
54 (let ((filename (car (output-files co c))))
55 #+cmu (ext:load-foreign filename)
56 #+sbcl (sb-alien:load-shared-object filename))))
60 (defclass c-source-file (source-file)
61 ((cflags :initform nil :initarg :cflags)
62 (optimization :initform 2 :initarg :optimization)
63 (definitions :initform nil :initarg :definitions)
64 (include-paths :initform nil :initarg :include-paths)))
67 (defmethod output-files ((op compile-op) (c c-source-file))
69 (make-pathname :type "o" :defaults
70 (component-pathname c))))
73 (defmethod perform ((op compile-op) (c c-source-file))
75 (= 0 (run-shell-command "gcc ~A -o ~S -c ~S"
79 (when (slot-value c 'optimization)
80 (list (format nil "-O~A" (slot-value c 'optimization))))
82 for symbol in (slot-value c 'definitions)
83 collect (format nil "-D~A" symbol))
85 for path in (slot-value c 'include-paths)
86 collect (format nil "-I~A" path))
87 (slot-value c 'cflags))
89 (unix-name (car (output-files op c)))
90 (unix-name (component-pathname c))))
91 (error 'operation-error :operation op :component c)))
94 (defmethod perform ((operation load-op) (c c-source-file))