X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-oracle%2Foracle-loader.lisp;h=f1493d3a1a585fb0d8c2d103d92a590f5d13b4c0;hp=c63a6733cbab1f76e42d8b410292f7630a17a07d;hb=d2d49ab13c98bc7a1819a0fd3968268a5567bdc3;hpb=48652576baf88a7dcde5649cec889228aa7b5133 diff --git a/db-oracle/oracle-loader.lisp b/db-oracle/oracle-loader.lisp index c63a673..f1493d3 100644 --- a/db-oracle/oracle-loader.lisp +++ b/db-oracle/oracle-loader.lisp @@ -5,9 +5,7 @@ ;;;; Name: oracle-loader.lisp ;;;; Purpose: Foreign library loader for CLSQL Oracle interface ;;;; -;;;; $Id$ -;;;; -;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg +;;;; This file is part of CLSQL. ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License @@ -16,112 +14,40 @@ (in-package #:clsql-oracle) -;; Load the foreign library - -(eval-when (:load-toplevel :compile-toplevel) - (defvar *oracle-home* - nil - "The root of the Oracle installation, usually $ORACLE_HOME is set to this.") - (unless *oracle-home* - (setf *oracle-home* - (cdr (assoc ':ORACLE_HOME ext:*environment-list* :test #'eq))))) - -(defparameter *oracle-libs* - '(#-oracle-9i "rdbms/lib/ssdbaed.o" - "rdbms/lib/defopt.o" - #-oracle-9i "rdbms/lib/homts.o" - "lib/nautab.o" - "lib/naeet.o" - "lib/naect.o" - "lib/naedhs.o" - #-oracle-9i"lib/libnsslb8.a" - #+oracle-9i "lib/homts.o" - ) - "Oracle client libraries, relative to ORACLE_HOME.") - -(defun make-oracle-load-path () - (mapcar (lambda (x) - (concatenate 'string *oracle-home* "/" x)) - *oracle-libs*)) +(defparameter *oracle-home* + (let ((oracle-home (getenv "ORACLE_HOME"))) + (when oracle-home + (parse-namestring (concatenate 'string oracle-home "/")))) + "Pathname of ORACLE_HOME as set in user environment.") +(defparameter *oracle-client-library-filenames* + (list "libclntsh" "oci")) -; ;(defparameter *oracle-so-libraries* -; ;; `(,(concatenate 'string "-L" *oracle-home* "/lib/") -; '( -; "-lclntsh" -; "-lnetv2" -; "-lnttcp" -; "-lnetwork" -; "-lncr" -; "-lclient" -; "-lvsn" -; "-lcommon" -; "-lgeneric" -; "-lmm" -; "-lnlsrtl3" -; "-lcore4" -; "-lnlsrtl3" -; "-lepc" -; "-ldl" -; "-lm") -; "List of library flags needed to be passed to ld to load the -; Oracle client library succesfully. If this differs at your site, -; set *oracle-so-libraries* to the right path before compiling or -; loading the system.") +(defvar *oracle-supporting-libraries* '("c") + "Used only by CMU. List of library flags needed to be passed to ld to +load the Oracle client library succesfully. If this differs at your site, +set to the right path before compiling or loading the system.") +(defvar *oracle-library-loaded* nil + "T if foreign library was able to be loaded successfully") -#-oracle-9i -(defun oracle-libraries () - `(,(concatenate 'string - "-L" *oracle-home* "/lib") - "-lagtsh" -;; "-locijdbc8" - "-lclntsh" - "-lclient8" - "-lvsn8" - "-lcommon8" - "-lskgxp8" - "-lmm" - "-lnls8" - "-lcore8" - "-lgeneric8" - "-ltrace8" - "-ldl" - "-lm")) +(defmethod clsql-sys:database-type-library-loaded ((database-type (eql :oracle))) + *oracle-library-loaded*) -;; "List of library flags needed to be passed to ld to load the -;;Oracle client library succesfully. If this differs at your site, -;;set *oracle-so-libraries* to the right path before compiling or -;;loading the system.") +(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :oracle))) + (when *oracle-home* + (dolist (dir-name '("lib" "bin")) + (dolist (lib-name '("libclntsh" "oci")) + (clsql:push-library-path + (make-pathname :name lib-name + :directory (append (pathname-directory *oracle-home*) + (list dir-name))))))) -#+oracle-9i -(defun oracle-libraries () - `(,(concatenate 'string - "-L" *oracle-home* "/lib") - "-lagent9" - "-lagtsh" -;; "-locijdbc8" - "-lclntsh" - "-lclntst9" - "-lclient9" - "-lvsn9" - "-lcommon9" - "-lskgxp9" - "-lmm" - "-lnls9" - "-lcore9" - "-lgeneric9" - "-ltrace9" - "-ldl" - #+redhat-linux "-L/usr/lib/gcc-lib/i386-redhat-linux/2.96" - "-lgcc" - "-lm")) + (clsql-uffi:find-and-load-foreign-library *oracle-client-library-filenames* + :module "clsql-oracle" + :supporting-libraries *oracle-supporting-libraries*) + (setq *oracle-library-loaded* t)) -(defmethod database-type-load-foreign ((database-type (eql :oracle))) - (progv '(sys::*dso-linker*) - '("/usr/bin/ld") - (ext:load-foreign (make-oracle-load-path) - :libraries (oracle-libraries)))) +(clsql-sys:database-type-load-foreign :oracle) -(database-type-load-foreign :oracle)