3 (defpackage #:sb-bsd-sockets-system (:use #:asdf #:cl))
4 (in-package #:sb-bsd-sockets-system)
6 ;;; constants.lisp requires special treatment
8 (defclass constants-file (cl-source-file) ())
10 (defmethod perform ((op compile-op) (component constants-file))
11 ;; we want to generate all our temporary files in the fasl directory
12 ;; because that's where we have write permission. Can't use /tmp;
13 ;; it's insecure (these files will later be owned by root)
14 (let* ((output-file (car (output-files op component)))
15 (filename (component-pathname component))
17 (if (typep output-file 'logical-pathname)
18 (translate-logical-pathname output-file)
19 (pathname output-file)))
20 (tmp-c-source (merge-pathnames #p"foo.c" real-output-file))
21 (tmp-a-dot-out (merge-pathnames #p"a.out" real-output-file))
22 (tmp-constants (merge-pathnames #p"constants.lisp-temp"
24 (princ (list filename output-file real-output-file
25 tmp-c-source tmp-a-dot-out tmp-constants))
27 (funcall (intern "C-CONSTANTS-EXTRACT" (find-package "BSD-SOCKETS-SYSTEM"))
28 filename tmp-c-source :bsd-sockets-internal)
31 "/usr/bin/gcc -o ~S ~S" (namestring tmp-a-dot-out)
32 (namestring tmp-c-source)) 0)
33 (= (run-shell-command "~A >~A"
34 (namestring tmp-a-dot-out)
35 (namestring tmp-constants)) 0)
36 (compile-file tmp-constants :output-file output-file))))
39 ;;; we also have a shared library with some .o files in it
41 (defclass unix-dso (module) ())
42 (defun unix-name (pathname)
45 (logical-pathname (translate-logical-pathname pathname))
48 (defmethod asdf::input-files ((operation compile-op) (dso unix-dso))
49 (mapcar #'component-pathname (module-components dso)))
51 (defmethod output-files ((operation compile-op) (dso unix-dso))
52 (let ((dir (component-pathname dso)))
54 (make-pathname :type "so"
55 :name (car (last (pathname-directory dir)))
56 :directory (butlast (pathname-directory dir))
60 (defmethod perform :after ((operation compile-op) (dso unix-dso))
61 (let ((dso-name (unix-name (car (output-files operation dso)))))
64 "gcc -shared -o ~S ~{~S ~}"
68 (output-files operation c))
69 (module-components dso)))))
70 (error 'operation-error :operation operation :component dso))))
72 ;;; if this goes into the standard asdf, it could reasonably be extended
73 ;;; to allow cflags to be set somehow
74 (defmethod output-files ((op compile-op) (c c-source-file))
76 (make-pathname :type "o" :defaults
77 (component-pathname c))))
78 (defmethod perform ((op compile-op) (c c-source-file))
80 (= 0 (run-shell-command "/usr/bin/gcc -fPIC -o ~S -c ~S"
81 (unix-name (car (output-files op c)))
82 (unix-name (component-pathname c))))
83 (error 'operation-error :operation op :component c)))
85 (defmethod perform ((operation load-op) (c c-source-file))
88 (defmethod perform ((o load-op) (c unix-dso))
89 (let ((co (make-instance 'compile-op)))
90 (let ((filename (car (output-files co c))))
91 #+cmu (ext:load-foreign filename)
92 #+sbcl (sb-alien:load-1-foreign filename))))
94 (defsystem bsd-sockets
96 :components ((:file "defpackage" :depends-on ("rt"))
97 (:file "split" :depends-on ("defpackage"))
98 (:file "array-data" :depends-on ("defpackage"))
100 :components ((:c-source-file "undefs")
101 (:c-source-file "get-h-errno")))
102 (:file "malloc" :depends-on ("defpackage"))
103 (:file "foreign-glue" :depends-on ("defpackage" "malloc"))
104 (:constants-file "constants"
105 :pathname "constants.lisp"
107 ("def-to-lisp" "defpackage" "foreign-glue"))
109 :depends-on ("constants" "array-data"))
111 (:file "sockopt" :depends-on ("sockets"))
112 (:file "inet" :depends-on ("sockets" "split" "constants" ))
113 (:file "unix" :depends-on ("sockets" "split" "constants" ))
114 (:file "name-service" :depends-on ("sockets" "constants" "alien"))
115 (:file "misc" :depends-on ("sockets" "constants"))
118 (:file "def-to-lisp")
119 (:file "tests" :depends-on ("inet" "sockopt" "rt"))
121 (:static-file "NEWS")
122 (:static-file "INSTALL")
123 (:static-file "README")
124 (:static-file "index" :pathname "index.html")
125 (:static-file "doc" :pathname "doc.lisp")
126 (:static-file "TODO")))