r9727: 1 Jul 2004 Kevin Rosenberg <kevin@rosenberg.net>
[clsql.git] / db-oracle / oracle-loader.lisp
index 0a3772100545acd83e544757ffc27081cca2dd6f..6d91e8dc1847faeb1ec10ea88d9ad01b3cd32250 100644 (file)
 
 (in-package #:clsql-oracle)
 
-(defparameter *clsql-oracle-library-path* 
-  (uffi:find-foreign-library
-   "oracle"
-   `(,(make-pathname :directory (pathname-directory *load-truename*))
-     "/usr/lib/clsql/"
-     "/sw/lib/clsql/"
-     "/home/kevin/debian/src/clsql/db-oracle/")
-   :drive-letters '("C")))
-
-(defvar *oracle-library-candidate-drive-letters* '("C" "D" "E"))
+(defparameter *oracle-lib-path*
+  (let ((oracle-home (getenv "ORACLE_HOME")))
+    (when oracle-home
+      (make-pathname :directory 
+                    (append 
+                     (pathname-directory
+                      (parse-namestring (concatenate 'string oracle-home "/")))
+                       (list "lib"))))))
+
+(defparameter *oracle-client-library-path* 
+    (uffi:find-foreign-library
+     "libclntsh"
+     `(,@(when *load-truename* (list (make-pathname :directory (pathname-directory *load-truename*))))
+       ,@(when *oracle-lib-path* (list *oracle-lib-path*))
+       "/usr/lib/oracle/10.1.0.2/client/lib/")
+     :drive-letters '("C")))
 
 (defvar *oracle-supporting-libraries* '("c")
   "Used only by CMU. List of library flags needed to be passed to ld to
@@ -37,13 +43,16 @@ set to the right path before compiling or loading the system.")
 
 (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :oracle)))
   *oracle-library-loaded*)
-                                     
-(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :oracle)))
-  (uffi:load-foreign-library *clsql-oracle-library-path* 
-                            :module "clsql-oracle" 
-                            :supporting-libraries *oracle-supporting-libraries*)
-  (setq *oracle-library-loaded* t))
 
+(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :oracle)))
+  (if (pathnamep *oracle-client-library-path*) 
+      (progn
+       (uffi:load-foreign-library *oracle-client-library-path*
+                                  :module "clsql-oracle"
+                                  :supporting-libraries 
+                                  *oracle-supporting-libraries*)
+       (setq *oracle-library-loaded* t))
+      (warn "Unable to load oracle client library.")))
 
 (clsql-sys:database-type-load-foreign :oracle)