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 ;;;; $Id: libraries.cl,v 1.5 2002/03/21 04:05:15 kevin Exp $
12 ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg
14 ;;;; UFFI 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 ;;;; *************************************************************************
19 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
22 (defvar *loaded-libraries* nil
23 "List of foreign libraries loaded. Used to prevent reloading a library")
25 (defun load-foreign-library (filename &key module supporting-libraries
27 #+allegro (declare (ignore module supporting-libraries))
28 #+lispworks (declare (ignore supporting-libraries))
29 #+cmu (declare (ignore module))
31 (when (and filename (probe-file filename))
32 (if (pathnamep filename) ;; ensure filename is a string to check if
33 (setq filename (namestring filename))) ; already loaded
35 (if (and (not force-load)
36 (find filename *loaded-libraries* :test #'string-equal))
37 t ;; return T, but don't reload library
39 #+cmu (alien:load-foreign filename
41 (convert-supporting-libraries-to-string
42 supporting-libraries))
43 #+lispworks (fli:register-module module
44 :connection-style :automatic
46 #+allegro (load filename)
48 (push filename *loaded-libraries*)
52 (defun convert-supporting-libraries-to-string (libs)
55 (push (format nil "-l~A" lib) lib-load-list))
56 (nreverse lib-load-list)))