r8936: merged classic-tests into tests
[clsql.git] / clsql-mysql.asd
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          clsql-mysql.asd
6 ;;;; Purpose:       ASDF definition file for CLSQL MySQL backend
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Aug 2002
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
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-mysql-system (:use #:asdf #:cl))
20 (in-package #:clsql-mysql-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-mysql")))
28
29 (defclass clsql-mysql-source-file (c-source-file)
30   ())
31
32 (defmethod output-files ((o compile-op) (c clsql-mysql-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-mysql-source-file))
48   nil) ;;; library will be loaded by a loader file
49
50 (defmethod operation-done-p ((o load-op) (c clsql-mysql-source-file))
51   nil) 
52
53 (defmethod perform ((o compile-op) (c clsql-mysql-source-file))
54   (unless (zerop (run-shell-command
55                   "cd ~A; make"
56                   (namestring (make-pathname :name nil
57                                              :type nil
58                                              :directory *library-file-dir*))))
59     (error 'operation-error :component c :operation o)))
60
61 (defmethod operation-done-p ((o compile-op) (c clsql-mysql-source-file))
62   (let ((lib (make-pathname :defaults (component-pathname c)
63                             :type (uffi:default-foreign-library-type))))
64     (and (probe-file lib)
65          (> (file-write-date lib) (file-write-date (component-pathname c))))))
66
67 ;;; System definition
68
69 #+(or allegro lispworks cmu sbcl openmcl mcl scl)
70 (defsystem :clsql-mysql
71   :name "cl-sql-mysql"
72   :author "Kevin M. Rosenberg <kmr@debian.org>"
73   :maintainer "Kevin M. Rosenberg <kmr@debian.org>"
74   :licence "Lessor Lisp General Public License"
75   :description "Common Lisp SQL MySQL Driver"
76   :long-description "cl-sql-mysql package provides a database driver to the MySQL database system."
77
78   :depends-on (uffi clsql-base clsql-uffi)
79   :components
80   ((:module :db-mysql
81             :components
82             ((:clsql-mysql-source-file "mysql")
83              (:file "mysql-package")
84              (:file "mysql-loader" :depends-on ("mysql-package" "mysql"))
85              (:file "mysql-client-info" :depends-on ("mysql-loader"))
86              (:file "mysql-api" :depends-on ("mysql-client-info"))
87              (:file "mysql-sql" :depends-on ("mysql-api"))))))