Merge branch 'development'
[clsql.git] / clsql-uffi.asd
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          clsql-uffi.asd
6 ;;;; Purpose:       ASDF definition file for CLSQL UFFI Helper package
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Aug 2002
9 ;;;;
10 ;;;; This file, part of CLSQL, is Copyright (c) 2002 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 (in-package cl-user)
18
19 (defpackage clsql-uffi-system (:use #:asdf #:cl))
20 (in-package clsql-uffi-system)
21
22 (defvar *clsql-uffi-library-dir*
23   (merge-pathnames "uffi/"
24                    (make-pathname :name nil :type nil :defaults *load-truename*)))
25
26 (defclass clsql-uffi-source-file (c-source-file)
27   ())
28
29
30 (defmethod output-files ((o compile-op) (c clsql-uffi-source-file))
31   (let* ((library-file-type
32           (funcall (intern (symbol-name'#:default-foreign-library-type)
33                            (symbol-name '#:uffi))))
34          (found
35           (some #'(lambda (dir)
36                     (probe-file (make-pathname
37                                  :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 *clsql-uffi-library-dir*)))))
46
47 (defmethod perform ((o load-op) (c clsql-uffi-source-file))
48   nil) ;;; library will be loaded by a loader file
49
50 (defmethod operation-done-p ((o load-op) (c clsql-uffi-source-file))
51   (and (symbol-function (intern (symbol-name '#:atol64)
52                                 (find-package '#:clsql-uffi)))
53        t))
54
55 (defmethod perform ((o compile-op) (c clsql-uffi-source-file))
56   (unless (operation-done-p o c)
57     #-(or win32 win64 windows mswindows)
58     (unless (zerop (run-shell-command
59                     #-(or freebsd netbsd) "cd ~A; make"
60                     #+(or freebsd netbsd) "cd ~A; gmake"
61                     (namestring *clsql-uffi-library-dir*)))
62       (error 'operation-error :component c :operation o))))
63
64 (defmethod operation-done-p ((o compile-op) (c clsql-uffi-source-file))
65   (or (and (probe-file #p"/usr/lib/clsql/clsql_uffi.so") t)
66       (let ((lib (make-pathname :defaults (component-pathname c)
67                                 :type (funcall (intern (symbol-name '#:default-foreign-library-type)
68                                                        (find-package '#:uffi))))))
69         (and (probe-file lib) (probe-file (component-pathname c))
70              (> (file-write-date lib) (file-write-date (component-pathname c)))))))
71
72 (defsystem clsql-uffi
73   :name "cl-sql-base"
74   :author "Kevin M. Rosenberg <kmr@debian.org>"
75   :maintainer "Kevin M. Rosenberg <kmr@debian.org>"
76   :licence "Lessor Lisp General Public License"
77   :description "Common UFFI Helper functions for Common Lisp SQL Interface Library"
78   :long-description "cl-sql-uffi package provides common helper functions using the UFFI for the CLSQL package."
79
80   :depends-on (clsql #-:clsql-cffi uffi #+:clsql-cffi cffi-uffi-compat)
81
82   :components
83   ((:module :uffi
84             :components
85             ((:file "clsql-uffi-package")
86              (:clsql-uffi-source-file "clsql_uffi" :depends-on ("clsql-uffi-package"))
87              (:file "clsql-uffi-loader" :depends-on ("clsql-uffi-package" "clsql_uffi"))
88              (:file "clsql-uffi" :depends-on ("clsql-uffi-loader"))))))