X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-oracle%2Foracle-loader.lisp;h=72414029fb862ad234a02ae811f732220d4b66d0;hb=0f3fe9d3a5a9940966262f760e6972015864cac8;hp=b7f3b84a42238af985fea2c62ed5ce449bdbac96;hpb=7d50938ba2db52a713498e49aa1679deae6f0b6b;p=clsql.git diff --git a/db-oracle/oracle-loader.lisp b/db-oracle/oracle-loader.lisp index b7f3b84..7241402 100644 --- a/db-oracle/oracle-loader.lisp +++ b/db-oracle/oracle-loader.lisp @@ -1,119 +1,67 @@ -;;; -*- Mode: Lisp -*- -;;; $Id: oracle-loader.lisp,v 1.1 2002/09/30 10:19:23 kevin Exp $ -;;; -;;; MaiSQL --- Common Lisp Interface Layer to SQL Databases -;;; This is copyrighted software. See documentation for terms. -;;; -;;; oracle-loader.cl --- Foreign Object Loader for Oracle +;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: oracle-loader.lisp +;;;; Purpose: Foreign library loader for CLSQL Oracle interface +;;;; +;;;; $Id$ +;;;; +;;;; 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 +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. +;;;; ************************************************************************* -(in-package :clsql-oracle) +(in-package #:clsql-oracle) -;; Load the foreign library +(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.") -(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-client-library-path* + (uffi:find-foreign-library + '("libclntsh" "oci") + `(,@(when *load-truename* + (list (make-pathname + :directory (pathname-directory *load-truename*)))) + ,@(when *oracle-home* + (list + (make-pathname :defaults *oracle-home* + :directory + (append (pathname-directory *oracle-home*) + (list "lib"))) + (make-pathname :defaults *oracle-home* + :directory + (append (pathname-directory *oracle-home*) + (list "bin"))))) + "/usr/lib/oracle/10.1.0.2/client/lib/") + :drive-letters '("C"))) -(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.") +(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.") -(defun make-oracle-load-path () - (mapcar (lambda (x) - (concatenate 'string *oracle-home* "/" x)) - *oracle-libs*)) +(defvar *oracle-library-loaded* nil + "T if foreign library was able to be loaded successfully") +(defmethod clsql-sys:database-type-library-loaded ((database-type (eql :oracle))) + *oracle-library-loaded*) -; ;(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.") +(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) -#-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")) -;; "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.") - -#+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")) - -(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)))) - - -(database-type-load-foreign :oracle)