r9457: Reworked CLSQL file structure.
[clsql.git] / clsql-oracle.asd
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          clsql-oracle.asd
6 ;;;; Purpose:       ASDF definition file for CLSQL Oracle backend
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Aug 2002
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file is part of CLSQL.
13 ;;;;
14 ;;;; CLSQL users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
18
19 (defpackage #:clsql-oracle-system (:use #:asdf #:cl))
20 (in-package #:clsql-oracle-system)
21
22 (eval-when (:compile-toplevel :load-toplevel :execute)
23   #+common-lisp-controller (require 'uffi)
24   #-common-lisp-controller (asdf:operate 'asdf:load-op 'uffi))
25
26 (defvar *library-file-dir* (append (pathname-directory *load-truename*)
27                                    (list "db-oracle")))
28
29 (defclass clsql-oracle-source-file (c-source-file)
30   ())
31
32 (defmethod output-files ((o compile-op) (c clsql-oracle-source-file))
33   (let* ((library-file-type
34           (funcall (intern (symbol-name'#:default-foreign-library-type)
35                            (symbol-name '#:uffi))))
36          (found (some #'(lambda (dir)
37                             (probe-file (make-pathname :directory dir
38                                                        :name (component-name c)
39                                                        :type library-file-type)))
40                         '((:absolute "usr" "lib" "clsql"))))) 
41     (list (if found
42               found
43               (make-pathname :name (component-name c)
44                              :type library-file-type
45                              :directory *library-file-dir*)))))
46
47 (defmethod perform ((o load-op) (c clsql-oracle-source-file))
48   t)
49
50 (defmethod operation-done-p ((o load-op) (c clsql-oracle-source-file))
51   (and (symbol-function (intern (symbol-name '#:oracle-get-client-info)
52                                 (find-package '#:oracle)))
53        t)) 
54
55 (defmethod perform ((o compile-op) (c clsql-oracle-source-file))
56   (unless (operation-done-p o c)
57     #-(or win32 mswindows)
58     (unless (zerop (run-shell-command
59                     #-freebsd "cd ~A; make"
60                     #+freebsd "cd ~A; gmake"
61                     (namestring (make-pathname :name nil
62                                                :type nil
63                                                :directory *library-file-dir*))))
64       (error 'operation-error :component c :operation o))))
65
66 (defmethod operation-done-p ((o compile-op) (c clsql-oracle-source-file))
67   (or (and (probe-file #p"/usr/lib/clsql/oracle.so") t)
68       (let ((lib (make-pathname :defaults (component-pathname c)
69                                 :type (uffi:default-foreign-library-type))))
70         (and (probe-file lib)
71              (> (file-write-date lib) (file-write-date (component-pathname c)))))))
72
73
74 ;;; System definition
75
76 (defsystem clsql-oracle
77   :name "clsql-oracle"
78   :author "Kevin M. Rosenberg <kmr@debian.org>"
79   :maintainer "Kevin M. Rosenberg <kmr@debian.org>"
80   :licence "Lessor Lisp General Public License"
81   :description "Common Lisp SQL Oracle Driver"
82   :long-description "cl-sql-oracle package provides a database driver to the Oracle database system."
83
84   :depends-on (clsql-uffi)
85   :components
86     ((:module :db-oracle
87               :components
88               ((:file "oracle-package")
89                (:file "oracle-loader" :depends-on ("oracle-package"))
90                (:file "foreign-resources" :depends-on ("oracle-package"))
91                (:file "oracle-constants" :depends-on ("oracle-package"))
92                (:file "oracle-api" :depends-on ("oracle-constants" "oracle-loader"))
93                (:file "oracle-sql" :depends-on ("oracle-api" "foreign-resources"))
94                (:file "oracle-objects" :depends-on ("oracle-sql"))))))