3 (defpackage #:sb-posix-system (:use #:asdf #:cl #:sb-grovel))
4 (in-package #:sb-posix-system)
7 ;;; we also have a shared library with some .o files in it
9 ;;; FIXME: we share this with SB-BSD-SOCKETS. This should either (a)
10 ;;; be part of ASDF itself, or (b) be in a shared file that we can
11 ;;; LOAD at this point.
12 (defclass unix-dso (module) ())
13 (defun unix-name (pathname)
16 (logical-pathname (translate-logical-pathname pathname))
19 (defmethod asdf::input-files ((operation compile-op) (dso unix-dso))
20 (mapcar #'component-pathname (module-components dso)))
22 (defmethod output-files ((operation compile-op) (dso unix-dso))
23 (let ((dir (component-pathname dso)))
25 (make-pathname :type "so"
26 :name (car (last (pathname-directory dir)))
27 :directory (butlast (pathname-directory dir))
31 (defmethod perform :after ((operation compile-op) (dso unix-dso))
32 (let ((dso-name (unix-name (car (output-files operation dso)))))
35 "gcc ~A -o ~S ~{~S ~}"
36 (if (sb-ext:posix-getenv "LDFLAGS")
37 (sb-ext:posix-getenv "LDFLAGS")
38 #+sunos "-shared -lresolv -lsocket -lnsl"
40 #-(or darwin sunos) "-shared")
44 (output-files operation c))
45 (module-components dso)))))
46 (error 'operation-error :operation operation :component dso))))
48 ;;; if this goes into the standard asdf, it could reasonably be extended
49 ;;; to allow cflags to be set somehow
50 (defmethod output-files ((op compile-op) (c c-source-file))
52 (make-pathname :type "o" :defaults
53 (component-pathname c))))
54 (defmethod perform ((op compile-op) (c c-source-file))
56 (= 0 (run-shell-command "gcc ~A -o ~S -c ~S"
57 (if (sb-ext:posix-getenv "CFLAGS")
58 (sb-ext:posix-getenv "CFLAGS")
60 (unix-name (car (output-files op c)))
61 (unix-name (component-pathname c))))
62 (error 'operation-error :operation op :component c)))
64 (defmethod perform ((operation load-op) (c c-source-file))
67 (defmethod perform ((o load-op) (c unix-dso))
68 (let ((co (make-instance 'compile-op)))
69 (let ((filename (car (output-files co c))))
70 #+cmu (ext:load-foreign filename)
71 #+sbcl (sb-alien:load-1-foreign filename))))
75 :depends-on (sb-grovel)
76 :components ((:file "defpackage")
77 (:file "designator" :depends-on ("defpackage"))
79 :components ((:c-source-file "stat-macros")))
80 (:file "macros" :depends-on ("designator"))
81 (sb-grovel:grovel-constants-file
83 :package :sb-posix :depends-on ("defpackage"))
84 (:file "interface" :depends-on ("constants" "macros" "designator" "alien"))))
86 (defsystem sb-posix-tests
88 :components ((:file "posix-tests")))
90 (defmethod perform :after ((o load-op) (c (eql (find-system :sb-posix))))
93 (defmethod perform ((o test-op) (c (eql (find-system :sb-posix))))
94 (operate 'load-op 'sb-posix-tests)
95 (operate 'test-op 'sb-posix-tests))
97 (defmethod perform ((o test-op) (c (eql (find-system :sb-posix-tests))))
98 (or (funcall (intern "DO-TESTS" (find-package "SB-RT")))
99 (error "test-op failed")))