summaryrefslogtreecommitdiff
blob: 86b285e56a3549a434e2f38449d4aa424a99d3c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
diff -urN cl-ncurses_0.1.original/Makefile cl-ncurses_0.1/Makefile
--- cl-ncurses_0.1.original/Makefile	2004-03-07 17:24:47.000000000 -0600
+++ cl-ncurses_0.1/Makefile	2004-03-09 01:22:45.271880072 -0600
@@ -1,8 +1,16 @@
 NAME=cl-ncurses
 SOURCES=ncurses.asd *.lisp glue.c README LICENSE Makefile
 
-all: glue.o
+CFLAGS=-fPIC -DPIC
+LDFLAGS=-shared
 
+glue.so: glue.o
+	$(LD) $(LDFLAGS) $^ -o $@
+
+.PHONY: dist clean
+
+clean:
+	-rm -f glue.so glue.o *.fasl *.x86f *~
 dist:
 	mkdir $(NAME)
 	cp $(SOURCES) $(NAME)/
diff -urN cl-ncurses_0.1.original/cl-ncurses.asd cl-ncurses_0.1/cl-ncurses.asd
--- cl-ncurses_0.1.original/cl-ncurses.asd	2004-03-07 22:36:12.000000000 -0600
+++ cl-ncurses_0.1/cl-ncurses.asd	2004-03-09 00:37:42.000000000 -0600
@@ -21,32 +21,12 @@
 ;;;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;;;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-(declaim (optimize (debug 3) (safety 3)))
-
-(in-package :asdf)
-
-(defvar *gcc* "/usr/bin/gcc")
-
-(defvar *gcc-options* '("-fPIC"))
+(defpackage #:cl-ncurses-system
+  (:use #:asdf #:common-lisp))
 
-(defmethod output-files ((o compile-op) (c c-source-file))
-  (list (make-pathname :name (component-name c)
-		       :type "so"
-		       :defaults (component-pathname c))))
-
-(defmethod perform ((o load-op) (c c-source-file))
-  (let ((loader (intern "LOAD-FOREIGN-LIBRARY" :uffi)))
-    (dolist (f (input-files o c))
-      (funcall loader f))))
-
-(defmethod perform ((o compile-op) (c c-source-file))
-  (unless (zerop (run-shell-command "~A ~A ~{~A ~}-o ~A"
-				    *gcc*
-				    (namestring (component-pathname c))
-				    *gcc-options*
-				    (namestring (car (output-files o c)))))
-    (error 'operation-error :component c :operation o)))
+(in-package #:cl-ncurses-system)
 
+(declaim (optimize (debug 3) (safety 3)))
 
 (defsystem :cl-ncurses
 	   :version "0.1.0"
@@ -76,7 +56,8 @@
 			(:file "getcchar" :depends-on ("packages"))
 			(:file "getch" :depends-on ("packages"))
 			(:file "getstr" :depends-on ("glue"))
-			(:c-source-file "glue")
+			(:file "glue-loader")
+			(:file "glue" :depends-on ("glue-loader"))
 			(:file "getyx" :depends-on ("packages" "glue"))
 			(:file "in_wch" :depends-on ("packages"))
 			(:file "in_wchstr" :depends-on ("packages"))
@@ -114,5 +95,6 @@
 			(:file "util" :depends-on ("packages"))
 			(:file "variables" :depends-on ("packages"))
 			(:file "window" :depends-on ("packages"))
-			(:file "wresize" :depends-on ("packages"))
-			))
+			(:file "wresize" :depends-on ("packages"))))
+
+;; cl-ncurses.asd ends here
diff -urN cl-ncurses_0.1.original/glue-loader.lisp cl-ncurses_0.1/glue-loader.lisp
--- cl-ncurses_0.1.original/glue-loader.lisp	1969-12-31 18:00:00.000000000 -0600
+++ cl-ncurses_0.1/glue-loader.lisp	2004-03-09 01:21:17.728188736 -0600
@@ -0,0 +1,45 @@
+;;;; -*- mode: lisp; syntax: common-lisp; indent-tabs-mode: nil; base: 10; package: CL-NCURSES -*-
+
+;;;; Author: Matthew Kennedy <mkennedy@gentoo.org>
+;;;;
+;;;; This code is adapted from clsql-uffi-loader.lisp which is part of
+;;;; CLSQL.  clsql-uffi-loader.lisp comes with the following
+;;;; copyright:
+;;;;
+;;;;     This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;;
+;;;;     CLSQL users are granted the rights to distribute and use this
+;;;;     software as governed by the terms of the Lisp Lesser GNU
+;;;;     Public License (http://opensource.franz.com/preamble.html),
+;;;;     also known as the LLGPL.
+;;;;
+
+(in-package #:cl-ncurses)
+
+(defparameter *uffi-library-path*
+  `(,(make-pathname :directory (pathname-directory *load-truename*))
+    "/usr/lib/cl-ncurses/"))
+
+(defparameter *uffi-library-filename* nil)
+
+(defvar *uffi-supporting-libraries* '("c"))
+
+(defvar *uffi-library-loaded* nil
+  "T if foreign library was able to be loaded successfully")
+
+(defun load-uffi-foreign-library (&optional force)
+  (when force (setf *uffi-library-loaded* nil))
+  (unless *uffi-library-loaded*
+    (setf *uffi-library-filename* (find-foreign-library "glue" *uffi-library-path*))
+    (unless (probe-file *uffi-library-filename*)
+      (error "Unable to find glue.so"))
+    (if (load-foreign-library *uffi-library-filename* 
+			      :module "cl-ncurses" 
+			      :supporting-libraries 
+			      *uffi-supporting-libraries*)
+	(setq *uffi-library-loaded* t)
+	(error "Unable to load helper library ~A" *uffi-library-filename*))))
+
+(load-uffi-foreign-library)
+
+;; glue-loader.lisp ends here