cleanup *.asd files
[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 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2010 by Kevin M. Rosenberg
11 ;;;;
12 ;;;; CLSQL users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
14 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
15 ;;;; *************************************************************************
16
17 (defpackage #:clsql-mysql-system (:use #:asdf #:cl))
18 (in-package #:clsql-mysql-system)
19
20 (eval-when (:compile-toplevel :load-toplevel :execute)
21   (unless (find-package 'uffi)
22     (asdf:operate 'asdf:load-op 'uffi)))
23
24 (defvar *library-file-dir*
25   (merge-pathnames "db-mysql/"
26                    (make-pathname :name nil :type nil
27                                   :defaults *load-truename*)))
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                              :defaults *library-file-dir*)))))
46
47 (defmethod perform ((o load-op) (c clsql-mysql-source-file))
48   t)
49
50 (defmethod operation-done-p ((o load-op) (c clsql-mysql-source-file))
51   (and (symbol-function (intern (symbol-name '#:mysql-get-client-info)
52                                 (find-package '#:mysql)))
53        t))
54
55 (defmethod perform ((o compile-op) (c clsql-mysql-source-file))
56   (unless (operation-done-p o c)
57     #-(or win32 win64 windows mswindows)
58     (unless (zerop (run-shell-command
59                     #-freebsd "cd ~A; make"
60                     #+freebsd "cd ~A; gmake"
61                     (namestring *library-file-dir*)))
62       (error 'operation-error :component c :operation o))))
63
64 (defmethod operation-done-p ((o compile-op) (c clsql-mysql-source-file))
65   (or (and (probe-file #p"/usr/lib/clsql/clsql_mysql.so") t)
66       (let ((lib (make-pathname :defaults (component-pathname c)
67                                 :type (uffi:default-foreign-library-type))))
68         (and (probe-file lib) (probe-file (component-pathname c))
69              (> (file-write-date lib) (file-write-date (component-pathname c)))))))
70
71 ;;; System definition
72
73 (defsystem :clsql-mysql
74   :name "cl-sql-mysql"
75   :author "Kevin M. Rosenberg <kmr@debian.org>"
76   :maintainer "Kevin M. Rosenberg <kmr@debian.org>"
77   :licence "Lessor Lisp General Public License"
78   :description "Common Lisp SQL MySQL Driver"
79   :long-description "cl-sql-mysql package provides a database driver to the MySQL database system."
80
81   :depends-on (clsql clsql-uffi)
82   :components
83   ((:module :db-mysql
84             :components
85             ((:file "mysql-package")
86              (:clsql-mysql-source-file "clsql_mysql" :depends-on ("mysql-package"))
87              (:file "mysql-loader" :depends-on ("mysql-package" "clsql_mysql"))
88              (:file "mysql-client-info" :depends-on ("mysql-loader"))
89              (:file "mysql-api" :depends-on ("mysql-client-info"))
90              (:file "mysql-sql" :depends-on ("mysql-api"))
91              (:file "mysql-objects" :depends-on ("mysql-sql"))))))