r10700: fix xargs chmod
[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   (unless (find-package 'uffi)
24     (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   (and (symbol-function (intern (symbol-name '#:atol64)
58                                 (find-package '#:clsql-uffi)))
59        t))
60
61 (defmethod perform ((o compile-op) (c clsql-uffi-source-file))
62   (unless (operation-done-p o c)
63     #-(or win32 mswindows)
64     (unless (zerop (run-shell-command
65                     #-freebsd "cd ~A; make"
66                     #+freebsd "cd ~A; gmake"
67                     (namestring (make-pathname :name nil
68                                                :type nil
69                                                :directory *library-file-dir*))))
70       (error 'operation-error :component c :operation o))))
71
72 (defmethod operation-done-p ((o compile-op) (c clsql-uffi-source-file))
73   (or (and (probe-file #p"/usr/lib/clsql/clsql_uffi.so") t)
74       (let ((lib (make-pathname :defaults (component-pathname c)
75                                 :type (uffi:default-foreign-library-type))))
76         (and (probe-file lib) (probe-file (component-pathname c))
77              (> (file-write-date lib) (file-write-date (component-pathname c)))))))
78   
79 (defsystem clsql-uffi
80   :name "cl-sql-base"
81   :author "Kevin M. Rosenberg <kmr@debian.org>"
82   :maintainer "Kevin M. Rosenberg <kmr@debian.org>"
83   :licence "Lessor Lisp General Public License"
84   :description "Common UFFI Helper functions for Common Lisp SQL Interface Library"
85   :long-description "cl-sql-uffi package provides common helper functions using the UFFI for the CLSQL package."
86
87   :depends-on (uffi clsql)
88   
89   :components
90   ((:module :uffi
91             :components
92             ((:file "clsql-uffi-package")
93              (:clsql-uffi-source-file "uffi" :depends-on ("clsql-uffi-package"))
94              (:file "clsql-uffi-loader" :depends-on ("clsql-uffi-package" "uffi"))
95              (:file "clsql-uffi" :depends-on ("clsql-uffi-loader"))))))