r8998: conditionalize shell command for windows
[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   #-(or win32 mswindows)
55   (unless (zerop (run-shell-command
56                   "cd ~A; make"
57                   (namestring (make-pathname :name nil
58                                              :type nil
59                                              :directory *library-file-dir*))))
60     (error 'operation-error :component c :operation o)))
61
62 (defmethod operation-done-p ((o compile-op) (c clsql-mysql-source-file))
63   (let ((lib (make-pathname :defaults (component-pathname c)
64                             :type (uffi:default-foreign-library-type))))
65     (and (probe-file lib)
66          (> (file-write-date lib) (file-write-date (component-pathname c))))))
67
68 ;;; System definition
69
70 #+(or allegro lispworks cmu sbcl openmcl mcl scl)
71 (defsystem :clsql-mysql
72   :name "cl-sql-mysql"
73   :author "Kevin M. Rosenberg <kmr@debian.org>"
74   :maintainer "Kevin M. Rosenberg <kmr@debian.org>"
75   :licence "Lessor Lisp General Public License"
76   :description "Common Lisp SQL MySQL Driver"
77   :long-description "cl-sql-mysql package provides a database driver to the MySQL database system."
78
79   :depends-on (uffi clsql-base clsql-uffi)
80   :components
81   ((:module :db-mysql
82             :components
83             ((:clsql-mysql-source-file "mysql")
84              (:file "mysql-package")
85              (:file "mysql-loader" :depends-on ("mysql-package" "mysql"))
86              (:file "mysql-client-info" :depends-on ("mysql-loader"))
87              (:file "mysql-api" :depends-on ("mysql-client-info"))
88              (:file "mysql-sql" :depends-on ("mysql-api"))))))