1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: libraries.cl
6 ;;;; Purpose: UFFI source to load foreign libraries
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Feb 2002
10 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
12 ;;;; $Id: libraries.cl,v 1.2 2002/03/10 20:01:55 kevin Exp $
14 ;;;; This file is part of the UFFI.
16 ;;;; UFFI is free software; you can redistribute it and/or modify
17 ;;;; it under the terms of the GNU General Public License (version 2) as
18 ;;;; published by the Free Software Foundation.
20 ;;;; UFFI is distributed in the hope that it will be useful,
21 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;;; GNU General Public License for more details.
25 ;;;; You should have received a copy of the GNU General Public License
26 ;;;; along with UFFI; if not, write to the Free Software
27 ;;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 ;;;; *************************************************************************
30 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
33 (defvar *loaded-libraries* nil
34 "List of foreign libraries loaded. Used to prevent reloading a library")
36 (defun load-foreign-library (filename &key module supporting-libraries)
37 #+allegro (declare (ignore module supporting-libraries))
38 #+lispworks (declare (ignore supporting-libraries))
39 #+cmu (declare (ignore module))
41 (when (and filename (probe-file filename))
42 (if (find filename *loaded-libraries* :test #'string-equal)
43 t ;; return T, but don't reload library
45 #+cmu (alien:load-foreign filename
47 (convert-supporting-libraries-to-string
48 supporting-libraries))
49 #+lispworks (fli:register-module module
50 :connection-style :automatic
52 #+allegro (load filename)
54 (push filename *loaded-libraries*))))
57 (defun convert-supporting-libraries-to-string (libs)
60 (push (format nil "-l~A" lib) lib-load-list))
61 (nreverse lib-load-list)))