-
Notifications
You must be signed in to change notification settings - Fork 5
/
ele-bdb.asd
110 lines (93 loc) · 3.49 KB
/
ele-bdb.asd
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
;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;
;;; elephant.asd -- ASDF system definition for elephant
;;;
;;; Initial version 8/26/2004 by Ben Lee
;;; <[email protected]>
;;;
;;; part of
;;;
;;; Elephant: an object-oriented database for Common Lisp
;;;
;;; Copyright (c) 2004 by Andrew Blumberg and Ben Lee
;;; <[email protected]> <[email protected]>
;;;
;;; Elephant 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-user)
;; Forward def
(defpackage elephant-system
(:use :cl :asdf)
(:export :elephant-c-source :compiler-options :foreign-libraries-to-load-first :get-config-option))
(defpackage ele-bdb-system
(:use :cl :asdf :elephant-system))
(in-package :ele-bdb-system)
;;
;; Compile bdb lib and load libraries
;;
#+(or windows mswindows win32)
(defun path-for-cygwin (path)
"DOS pathname -> cygwin pathname. Replace backslashes with slashes and drive letter with directory.
e.g. \"C:\\dir\\\" -> \"/cygdrive/C/dir/\" "
(let* ((result (namestring path))
(colon-pos (position #\: result))
(drive-letter (char result (1- colon-pos))))
(setf (char result (1- colon-pos)) #\/)
(setf (char result colon-pos) drive-letter)
(setf result (concatenate 'string "/cygdrive" result))
(substitute #\/ #\\ result)))
;; Forward def
(defclass elephant-c-source (c-source-file) ())
(defclass bdb-c-source (elephant-c-source) ())
(defmethod compiler-options ((compiler (eql :gcc)) (c bdb-c-source) &key &allow-other-keys)
(append (library-directories c)
(call-next-method)
#-(or linux) (list (format nil "-l~A" (get-db-name c)))))
(defun get-db-name (c)
(subseq (pathname-name
(make-pathname :defaults (get-config-option :berkeley-db-lib c)) )
3))
(defmethod compiler-options ((compiler (eql :cygwin)) (c bdb-c-source) &key &allow-other-keys)
(append (library-directories c)
(list "-ldb45")
(call-next-method)))
(defun library-directories (c)
(let ((include (make-pathname :defaults (get-config-option :berkeley-db-include-dir c)))
(lib (make-pathname :defaults (get-config-option :berkeley-db-lib-dir c))))
#+(or windows mswindows win32)
(list (format nil "-L'~A'" (path-for-cygwin lib))
(format nil "-I'~A'" (path-for-cygwin include)))
#-(or windows mswindows win32)
(list (format nil "-L~A" lib) (format nil "-I~A" include))))
(defmethod foreign-libraries-to-load-first ((c bdb-c-source))
(remove-if #'(lambda (x) (null (car x)))
(list (cons (get-config-option :pthread-lib c) "pthread")
(cons (get-config-option :berkeley-db-lib c)
(get-config-option :berkeley-db-lib c)))))
;;
;; System definition
;;
(defsystem ele-bdb
:name "elephant"
:author "Ben Lee <[email protected]>"
:version "0.6.0"
:maintainer "Ben Lee <[email protected]>"
:licence "LLGPL"
:description "Object database for Common Lisp"
:long-description "An object-oriented database based on Berkeley DB, for CMUCL/SBCL, OpenMCL, and Allegro."
:components
((:module :src
:components
((:module :db-bdb
:components
((:file "package")
(:bdb-c-source "libberkeley-db")
(:file "berkeley-constants")
(:file "berkeley-db")
(:file "bdb-controller")
(:file "bdb-slots")
(:file "bdb-collections")
(:file "bdb-transactions"))
:serial t))))
:depends-on (:uffi :elephant))