Update domain name to kpe.io
[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 (find-package '#:mysql)
52        (symbol-function (intern (symbol-name '#:mysql-get-client-info)
53                                 (find-package '#:mysql)))
54        t))
55
56 (defmethod perform ((o compile-op) (c clsql-mysql-source-file))
57   (unless (operation-done-p o c)
58     #-(or win32 win64 windows mswindows)
59     (unless (zerop (run-shell-command
60                     #-freebsd "cd ~A; make"
61                     #+freebsd "cd ~A; gmake"
62                     (namestring *library-file-dir*)))
63       (error 'operation-error :component c :operation o))))
64
65 (defmethod operation-done-p ((o compile-op) (c clsql-mysql-source-file))
66   (or (and (probe-file #p"/usr/lib/clsql/clsql_mysql.so") t)
67       (let ((lib (make-pathname :defaults (component-pathname c)
68                                 :type (uffi:default-foreign-library-type))))
69         (and (probe-file lib) (probe-file (component-pathname c))
70              (> (file-write-date lib) (file-write-date (component-pathname c)))))))
71
72 ;;; System definition
73
74 (defsystem :clsql-mysql
75   :name "cl-sql-mysql"
76   :author "Kevin M. Rosenberg <kmr@debian.org>"
77   :maintainer "Kevin M. Rosenberg <kmr@debian.org>"
78   :licence "Lessor Lisp General Public License"
79   :description "Common Lisp SQL MySQL Driver"
80   :long-description "cl-sql-mysql package provides a database driver to the MySQL database system."
81
82   :depends-on (clsql clsql-uffi)
83   :components
84   ((:module :db-mysql
85             :components
86             ((:file "mysql-package")
87              (:clsql-mysql-source-file "clsql_mysql" :depends-on ("mysql-package"))
88              (:file "mysql-loader" :depends-on ("mysql-package" "clsql_mysql"))
89              (:file "mysql-client-info" :depends-on ("mysql-loader"))
90              (:file "mysql-api" :depends-on ("mysql-client-info"))
91              (:file "mysql-sql" :depends-on ("mysql-api"))
92              (:file "mysql-objects" :depends-on ("mysql-sql"))))))