r10812: 7 Nov 2005 Kevin Rosenberg <kevin@rosenberg.net>
[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 (defpackage clsql-uffi-system (:use #:asdf #:cl))
22 (in-package clsql-uffi-system)
23
24 (defvar *library-file-dir* (append (pathname-directory *load-truename*)
25                                    (list "uffi")))
26
27 (defclass clsql-uffi-source-file (c-source-file)
28   ())
29
30
31 (defmethod output-files ((o compile-op) (c clsql-uffi-source-file))
32   (let* ((library-file-type
33           (funcall (intern (symbol-name'#:default-foreign-library-type)
34                            (symbol-name '#:uffi))))
35          (found
36           (some #'(lambda (dir)
37                     (probe-file (make-pathname
38                                  :directory dir
39                                  :name (component-name c)
40                                  :type library-file-type)))
41                 '((:absolute "usr" "lib" "clsql")))))
42     (list (if found
43               found
44               (make-pathname :name (component-name c)
45                              :type library-file-type
46                              :directory *library-file-dir*)))))
47
48 (defmethod perform ((o load-op) (c clsql-uffi-source-file))
49   nil) ;;; library will be loaded by a loader file
50
51 (defmethod operation-done-p ((o load-op) (c clsql-uffi-source-file))
52   (and (symbol-function (intern (symbol-name '#:atol64)
53                                 (find-package '#:clsql-uffi)))
54        t))
55
56 (defmethod perform ((o compile-op) (c clsql-uffi-source-file))
57   (unless (operation-done-p o c)
58     #-(or win32 mswindows)
59     (unless (zerop (run-shell-command
60                     #-freebsd "cd ~A; make"
61                     #+freebsd "cd ~A; gmake"
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   (or (and (probe-file #p"/usr/lib/clsql/clsql_uffi.so") t)
69       (let ((lib (make-pathname :defaults (component-pathname c)
70                                 :type (uffi:default-foreign-library-type))))
71         (and (probe-file lib) (probe-file (component-pathname c))
72              (> (file-write-date lib) (file-write-date (component-pathname c)))))))
73   
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)
83   
84   :components
85   ((:module :uffi
86             :components
87             ((:file "clsql-uffi-package")
88              (:clsql-uffi-source-file "uffi" :depends-on ("clsql-uffi-package"))
89              (:file "clsql-uffi-loader" :depends-on ("clsql-uffi-package" "uffi"))
90              (:file "clsql-uffi" :depends-on ("clsql-uffi-loader"))))))