r9475: testing new oracle library lookup
[clsql.git] / db-oracle / oracle-loader.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          oracle-loader.lisp
6 ;;;; Purpose:       Foreign library loader for CLSQL Oracle 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-oracle)
18
19 (defparameter *oracle-lib-path*
20     (let ((oracle-home (getenv "ORACLE_HOME")))
21       (when oracle-home
22         (make-pathname :directory 
23                        (append 
24                         (pathname-directory
25                          (parse-namestring (concatenate 'string oracle-home "/")))
26                         (list "lib"))))))
27
28 (defparameter *clsql-oracle-library-path* 
29     (uffi:find-foreign-library
30      '("libclntsh" "oracle") 
31      `(,@(when *load-truename* (list (make-pathname :directory (pathname-directory *load-truename*))))
32        ,@(when *oracle-lib-path* (list *oracle-lib-path*))
33        "/9i/lib/"
34        "/usr/lib/clsql/"
35        "/sw/lib/clsql/"
36        "/home/kevin/debian/src/clsql/db-oracle/")
37      :drive-letters '("C")))
38
39 (defvar *oracle-library-candidate-drive-letters* '("C" "D" "E"))
40
41 (defvar *oracle-supporting-libraries* '("c")
42   "Used only by CMU. List of library flags needed to be passed to ld to
43 load the Oracle client library succesfully.  If this differs at your site,
44 set to the right path before compiling or loading the system.")
45
46 (defvar *oracle-library-loaded* nil
47   "T if foreign library was able to be loaded successfully")
48
49 (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :oracle)))
50   *oracle-library-loaded*)
51
52 (setf *oracle-lib-path* #p"/usr/lib/oracle/10.1.0.2/client/lib/")
53
54 (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :oracle)))
55   #+ignore
56   (uffi:load-foreign-library
57    (make-pathname :defaults *oracle-lib-path* :name "libclntsh" :type "so"))
58   (uffi:load-foreign-library *clsql-oracle-library-path* 
59                              :module "clsql-oracle" 
60                              :supporting-libraries *oracle-supporting-libraries*)
61   (setq *oracle-library-loaded* t))
62
63
64 (clsql-sys:database-type-load-foreign :oracle)
65
66