2 (eval-when (:compile-toplevel :load-toplevel :execute)
4 (defpackage #:sb-bsd-sockets-system (:use #:asdf #:sb-grovel #:cl))
5 (in-package #:sb-bsd-sockets-system)
7 ;;; we also have a shared library with some .o files in it
9 (defclass unix-dso (module) ())
10 (defun unix-name (pathname)
13 (logical-pathname (translate-logical-pathname pathname))
16 (defmethod asdf::input-files ((operation compile-op) (dso unix-dso))
17 (mapcar #'component-pathname (module-components dso)))
19 (defmethod output-files ((operation compile-op) (dso unix-dso))
20 (let ((dir (component-pathname dso)))
22 (make-pathname :type "so"
23 :name (car (last (pathname-directory dir)))
24 :directory (butlast (pathname-directory dir))
28 (defmethod perform :after ((operation compile-op) (dso unix-dso))
29 (let ((dso-name (unix-name (car (output-files operation dso)))))
32 #+sunos "gcc -shared -lresolv -lsocket -lnsl -o ~S ~{~S ~}"
33 #-sunos "gcc -shared -o ~S ~{~S ~} "
37 (output-files operation c))
38 (module-components dso)))))
39 (error 'operation-error :operation operation :component dso))))
41 ;;; if this goes into the standard asdf, it could reasonably be extended
42 ;;; to allow cflags to be set somehow
43 (defmethod output-files ((op compile-op) (c c-source-file))
45 (make-pathname :type "o" :defaults
46 (component-pathname c))))
47 (defmethod perform ((op compile-op) (c c-source-file))
49 (= 0 (run-shell-command "gcc -fPIC -o ~S -c ~S"
50 (unix-name (car (output-files op c)))
51 (unix-name (component-pathname c))))
52 (error 'operation-error :operation op :component c)))
54 (defmethod perform ((operation load-op) (c c-source-file))
57 (defmethod perform ((o load-op) (c unix-dso))
58 (let ((co (make-instance 'compile-op)))
59 (let ((filename (car (output-files co c))))
60 #+cmu (ext:load-foreign filename)
61 #+sbcl (sb-alien:load-1-foreign filename))))
63 (defsystem sb-bsd-sockets
65 :depends-on (sb-grovel)
66 :components ((:file "defpackage")
67 (:file "split" :depends-on ("defpackage"))
68 (:file "array-data" :depends-on ("defpackage"))
70 :components ((:c-source-file "undefs")
71 (:c-source-file "get-h-errno")))
72 (:file "malloc" :depends-on ("defpackage"))
73 (:file "foreign-glue" :depends-on ("defpackage" "malloc"))
74 (sb-grovel:grovel-constants-file
76 :package :sockint :pathname "constants.lisp"
77 :depends-on ("def-to-lisp" "defpackage" "foreign-glue"))
79 :depends-on ("constants" "array-data"))
81 (:file "sockopt" :depends-on ("sockets"))
82 (:file "inet" :depends-on ("sockets" "split" "constants" ))
83 (:file "local" :depends-on ("sockets" "split" "constants" ))
84 (:file "name-service" :depends-on ("sockets" "constants" "alien"))
85 (:file "misc" :depends-on ("sockets" "constants"))
90 ;; (:static-file "INSTALL")
91 (:static-file "README")
92 (:static-file "index" :pathname "index.html")
93 (:static-file "doc" :pathname "doc.lisp")
94 (:static-file "TODO")))
96 (defmethod perform :after ((o load-op) (c (eql (find-system :sb-bsd-sockets))))
97 (provide 'sb-bsd-sockets))
99 (defmethod perform ((o test-op) (c (eql (find-system :sb-bsd-sockets))))
100 (operate 'load-op 'sb-bsd-sockets-tests)
101 (operate 'test-op 'sb-bsd-sockets-tests))
103 (defsystem sb-bsd-sockets-tests
104 :depends-on (sb-rt sb-bsd-sockets)
105 :components ((:file "tests")))
107 (defmethod perform ((o test-op) (c (eql (find-system :sb-bsd-sockets-tests))))
108 (or (funcall (intern "DO-TESTS" (find-package "SB-RT")))
109 (error "test-op failed")))