36701f005782d1a68592f4b75c620b1f25cb1eda
[clsql.git] / db-db2 / db2-loader.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          db2-loader.lisp
6 ;;;; Purpose:       Foreign library loader for CLSQL Db2 interface
7 ;;;;
8 ;;;; $Id$
9 ;;;;
10 ;;;; This file is part of CLSQL.
11 ;;;;
12 ;;;; CLSQL users are granted the rights to distribute and use this software
13 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
14 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
15 ;;;; *************************************************************************
16
17 (in-package #:clsql-db2)
18
19 (defparameter *db2-lib-path*
20   (let ((db2-home (getenv "DB2_HOME")))
21     (when db2-home
22       (make-pathname :directory
23                      (append
24                       (pathname-directory
25                        (parse-namestring (concatenate 'string db2-home "/")))
26                       (list "lib"))))))
27
28 (defparameter *db2-library-filenames*
29   (if *db2-lib-path*
30     (list (merge-pathnames "libdb2" *db2-lib-path*)
31           "libdb2")
32     "libdb2"))
33
34 (defvar *db2-supporting-libraries* '("c")
35   "Used only by CMU. List of library flags needed to be passed to ld to
36 load the Db2 client library succesfully.  If this differs at your site,
37 set to the right path before compiling or loading the system.")
38
39 (defvar *db2-library-loaded* nil
40   "T if foreign library was able to be loaded successfully")
41
42 (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :db2)))
43   *db2-library-loaded*)
44
45 (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :db2)))
46   (clsql-uffi:find-and-load-foreign-library *db2-library-filenames*
47                                             :module "clsql-db2"
48                                             :supporting-libraries
49                                             *db2-supporting-libraries*)
50   (setq *db2-library-loaded* t))
51
52 (clsql-sys:database-type-load-foreign :db2)
53
54