r8936: merged classic-tests into tests
[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 ;;;; $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 (in-package cl-user)
20
21 ;; need to load uffi for below output-files method 
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 (defpackage clsql-uffi-system (:use #:asdf #:cl))
27 (in-package clsql-uffi-system)
28
29 (defvar *library-file-dir* (append (pathname-directory *load-truename*)
30                                    (list "uffi")))
31
32 (defclass clsql-uffi-source-file (c-source-file)
33   ())
34
35
36 (defmethod output-files ((o compile-op) (c clsql-uffi-source-file))
37   (let* ((library-file-type
38           (funcall (intern (symbol-name'#:default-foreign-library-type)
39                            (symbol-name '#:uffi))))
40          (found
41           (some #'(lambda (dir)
42                     (probe-file (make-pathname
43                                  :directory dir
44                                  :name (component-name c)
45                                  :type library-file-type)))
46                 '((:absolute "usr" "lib" "clsql")))))
47     (list (if found
48               found
49               (make-pathname :name (component-name c)
50                              :type library-file-type
51                              :directory *library-file-dir*)))))
52
53 (defmethod perform ((o load-op) (c clsql-uffi-source-file))
54   nil) ;;; library will be loaded by a loader file
55
56 (defmethod operation-done-p ((o load-op) (c clsql-uffi-source-file))
57   nil) 
58
59 (defmethod perform ((o compile-op) (c clsql-uffi-source-file))
60   (unless (zerop (run-shell-command
61                   "cd ~A; make"
62                   (namestring (make-pathname :name nil
63                                              :type nil
64                                              :directory *library-file-dir*))))
65     (error 'operation-error :component c :operation o)))
66
67 (defmethod operation-done-p ((o compile-op) (c clsql-uffi-source-file))
68   (let ((lib (make-pathname :defaults (component-pathname c)
69                             :type (uffi:default-foreign-library-type))))
70     (and (probe-file lib)
71          (> (file-write-date lib) (file-write-date (component-pathname c))))))
72   
73 #+(or allegro lispworks cmu sbcl openmcl mcl scl)
74 (defsystem clsql-uffi
75   :name "cl-sql-base"
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 UFFI Helper functions for Common Lisp SQL Interface Library"
80   :long-description "cl-sql-uffi package provides common helper functions using the UFFI for the CLSQL package."
81
82   :depends-on (uffi clsql-base)
83   
84   :components
85   ((:module :uffi
86             :components
87             ((:clsql-uffi-source-file "uffi")
88              (:file "clsql-uffi-package")
89              (:file "clsql-uffi-loader" :depends-on ("clsql-uffi-package" "uffi"))
90              (:file "clsql-uffi" :depends-on ("clsql-uffi-loader"))))))