/[lgtk]/lgtk/lgtk.asd
ViewVC logotype

Contents of /lgtk/lgtk.asd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (show annotations)
Thu Apr 28 18:10:32 2005 UTC (8 years, 11 months ago) by mmommer
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +9 -4 lines
Added support for multiple libraries, in particular glade.
Patch by Sean Champ.
1 ;;;; -*- Mode: Lisp; Synatx: ANSI-Common-Lisp; Base: 10 -*-
2
3 ;; (c) October 2003 by Mario S. Mommer <mommer@well-of-wyrd.net>
4 ;;
5 ;; This code comes under the terms of the modified BSD license ("sans
6 ;; advertising clause"). See the file COPYING for details.
7
8 (defpackage #:lgtk-asd
9 (:use :cl :asdf #+cmu :ext #+sbcl :sb-ext #+sbcl :sb-alien))
10
11 (in-package :lgtk-asd)
12
13 (defvar *ccompiler* "cc")
14
15
16 ;; list of library/module names to provide to pkgconfig
17 (defparameter *pkgconfig-modules* '("gtk+-2.0" "libglade-2.0"))
18
19
20 ;; Split a string at whitespace.
21 (defun splitatspc (str)
22 (labels ((whitespace-p (c)
23 (find c '(#\Space #\Tab #\Newline))))
24 (let* ((posnew -1)
25 (posold 0)
26 (buf (cons nil nil))
27 (ptr buf))
28 (loop while (and posnew (< posnew (length str))) do
29 (setf posold (+ 1 posnew))
30 (setf posnew (position-if #'whitespace-p str
31 :start posold))
32 (let ((item (subseq str posold posnew)))
33 (when (< 0 (length item))
34 (setf (cdr ptr) (list item))
35 (setf ptr (cdr ptr)))))
36
37 (cdr buf))))
38
39 (defun pkg-config-lib-string ()
40 #+sbcl (run-program "pkg-config" (list* "--libs" *pkgconfig-modules*)
41 :search t
42 :output :stream)
43 #+cmu (ext:run-program "pkg-config" (list* "--libs" *pkgconfig-modules*)
44 :output :stream))
45
46 ;; Get the list of libraries.
47 (defun get-gtk-libs-list ()
48 (let ((prc (pkg-config-lib-string)))
49 (if (not prc)
50 (error "Could not run #\"pkg-config!")
51 (let ((str (process-output prc))
52 (ecode (process-exit-code prc)))
53 (if (not (eql ecode 0))
54 (error "Could not find gtk+-2.0")
55 (remove-if ;; Remove options which do not specify a lib
56 #'(lambda (x)
57 (not (equalp (subseq x 0 2) "-l"))) ;; equalp is case
58 ;; insenitive.
59 (splitatspc (read-line str))))))))
60
61
62 (defun pkg-config-cflags-string ()
63 #+sbcl (run-program "pkg-config" (list* "--cflags" *pkgconfig-modules*)
64 :search t
65 :output :stream)
66 #+cmu (ext:run-program "pkg-config" (list* "--cflags" *pkgconfig-modules*)
67 :output :stream))
68
69 (defun get-gtk-cflags ()
70 (let ((prc (pkg-config-cflags-string)))
71 (if (not prc)
72 (error "Could not run #\"pckg-config!")
73 (let ((str (process-output prc))
74 (ecode (process-exit-code prc)))
75 (if (not (eql ecode 0))
76 (error "Could not find gtk+-2.0")
77 (read-line str))))))
78
79 (defparameter *gtklibs* (get-gtk-libs-list))
80 (defparameter *gtkcflags* (get-gtk-cflags))
81 (defvar *source-dir* nil)
82
83 (defclass gtk-libs-handle (c-source-file) ())
84
85 (defmethod output-files ((o operation) (c c-source-file))
86 (list (make-pathname :name (component-name c)
87 :type "o"
88 :defaults (component-pathname c))))
89
90 (defmethod perform ((o compile-op) (c gtk-libs-handle))
91 (unless (zerop (run-shell-command "~A ~A -c -o ~A ~A"
92 *ccompiler*
93 (namestring (component-pathname c))
94 (namestring (car (output-files o c)))
95 *gtkcflags*))
96 (error 'operation-error :component c :operation o)))
97
98 (defmethod perform ((o load-op) (c gtk-libs-handle))
99 (setf *source-dir* (pathname-directory (component-pathname c)))
100 (load-foreign (namestring (car (output-files o c)))
101 :libraries *gtklibs*))
102
103 (defsystem lgtk
104 :name "lgtk"
105 :version "0.0.0"
106 :maintainer "Mario S. Mommer <mommer@well-of-wyrd.net>"
107 :licence "BSD sans advertising clause (see file COPYING for details)"
108 :description "GTK+ 2 interface"
109 :long-description "A common-lisp interface for the GTK+2.0, 2.2... toolkit"
110
111 :components
112 ((:module :src
113 :components
114 ((:file "port")
115 (:file "nexus" :depends-on ("port"))
116 (:file "widgets" :depends-on ("nexus"))
117 (:file "dynaslot" :depends-on ("bindings" "nexus" "port"))
118 (:file "enums" :depends-on ("bindings"))
119 (:file "bindings" :depends-on ("port"))
120
121
122 (:gtk-libs-handle "wrappers")
123
124
125 (:file "gtkpackage" :depends-on ("widgets" "nexus"
126 "enums" "bindings"
127 "dynaslot"))
128
129 (:file "gtkenums" :depends-on ("gtkpackage" "enums"))
130 (:file "gtkclasshierarchy" :depends-on ("gtkpackage"))
131 (:file "gtkbindings" :depends-on ("gtkenums"
132 "gtkclasshierarchy"
133 "wrappers"))
134 (:file "gtknexus" :depends-on ("gtkbindings"))
135 (:file "gtklisp" :depends-on ("gtknexus"))
136
137 (:file "lgtk-utils" :depends-on ("gtklisp"))))))
138
139 ;; On 2003.12.10, load-foreign was put in deathrow by the sbcl
140 ;; developers. The following comment was made by Krystof_ and is
141 ;; probably going to help minimize the impact: "cmucl's load-foreign
142 ;; on linux runs ld -G -o /tmp/RANDOM --whole-archive file1.a file2.o
143 ;; file3.so --no-whole-archive -lfoo -lbar"

  ViewVC Help
Powered by ViewVC 1.1.5