From e3924d6e872f06dce33c923b15c5d30baa31460c Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 8 Jun 2005 19:25:26 +0000 Subject: [PATCH] r10575: 09 Jun 2005 Kevin Rosenberg * clsql-mysql.asd: Renamed uffi/mysql interface library from mysql to uffi_mysql * db-mysql/uffi_mysql.c: Renamed from mysql.c * db-mysql/Makefile, db-mysql/mysql-loader.lisp: Rename shared library * db-*/*-loader.lisp: Commit big patch from Edi Weitz to remove absolute pathnames when searching for foreign libraries. * uffi/clsql-uffi-loader: New file from Edi Weitz for support foreign library loading. --- ChangeLog | 10 ++++++ clsql-mysql.asd | 2 +- db-db2/db2-loader.lisp | 28 ++++++--------- db-mysql/Makefile | 5 +-- db-mysql/{uffi_mysql.c => clsql_mysql.c} | 0 db-odbc/odbc-loader.lisp | 19 +++-------- db-oracle/oracle-loader.lisp | 38 +++++++-------------- db-postgresql/postgresql-loader.lisp | 22 +++--------- db-sqlite/sqlite-loader.lisp | 15 +++------ db-sqlite3/sqlite3-loader.lisp | 15 +++------ debian/changelog | 6 ++++ uffi/clsql-uffi-loader.lisp | 43 +++++++++++++++--------- uffi/clsql-uffi-package.lisp | 1 + 13 files changed, 88 insertions(+), 116 deletions(-) rename db-mysql/{uffi_mysql.c => clsql_mysql.c} (100%) diff --git a/ChangeLog b/ChangeLog index b3df41b..42b193d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +09 Jun 2005 Kevin Rosenberg + * clsql-mysql.asd: Renamed uffi/mysql interface library from + mysql to uffi_mysql + * db-mysql/uffi_mysql.c: Renamed from mysql.c + * db-mysql/Makefile, db-mysql/mysql-loader.lisp: Rename shared library + * db-*/*-loader.lisp: Commit big patch from Edi Weitz to remove + absolute pathnames when searching for foreign libraries. + * uffi/clsql-uffi-loader: New file from Edi Weitz for support + foreign library loading. + 07 Jun 2005 Kevin Rosenberg * Version 3.1.16 * db-mysql/mysql-api.lisp: Commit patch from Espen Wiborn diff --git a/clsql-mysql.asd b/clsql-mysql.asd index 3780827..0092175 100644 --- a/clsql-mysql.asd +++ b/clsql-mysql.asd @@ -64,7 +64,7 @@ (error 'operation-error :component c :operation o)))) (defmethod operation-done-p ((o compile-op) (c clsql-mysql-source-file)) - (or (and (probe-file #p"/usr/lib/clsql/mysql.so") t) + (or (and (probe-file #p"/usr/lib/clsql/clsql_mysql.so") t) (let ((lib (make-pathname :defaults (component-pathname c) :type (uffi:default-foreign-library-type)))) (and (probe-file lib) diff --git a/db-db2/db2-loader.lisp b/db-db2/db2-loader.lisp index 70be078..8faf9e3 100644 --- a/db-db2/db2-loader.lisp +++ b/db-db2/db2-loader.lisp @@ -23,16 +23,13 @@ (append (pathname-directory (parse-namestring (concatenate 'string db2-home "/"))) - (list "lib")))))) + (list "lib")))))) -(defparameter *db2-client-library-path* - (uffi:find-foreign-library - "libdb2" - `(,@(when *load-truename* (list (make-pathname :directory (pathname-directory *load-truename*)))) - ,@(when *db2-lib-path* (list *db2-lib-path*)) - #+64bit "/opt/IBM/db2/V8.1/lib64/" - "/opt/IBM/db2/V8.1/lib/") - :drive-letters '("C"))) +(defparameter *db2-library-filenames* + (if *db2-lib-path* + (list (merge-pathnames "libdb2" *db2-lib-path*) + "libdb2") + "libdb2")) (defvar *db2-supporting-libraries* '("c") "Used only by CMU. List of library flags needed to be passed to ld to @@ -46,14 +43,11 @@ set to the right path before compiling or loading the system.") *db2-library-loaded*) (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :db2))) - (if (pathnamep *db2-client-library-path*) - (progn - (uffi:load-foreign-library *db2-client-library-path* - :module "clsql-db2" - :supporting-libraries - *db2-supporting-libraries*) - (setq *db2-library-loaded* t)) - (warn "Unable to load db2 client library."))) + (clsql-uffi:find-and-load-foreign-library *db2-library-filenames* + :module "clsql-db2" + :supporting-libraries + *db2-supporting-libraries*) + (setq *db2-library-loaded* t)) (clsql-sys:database-type-load-foreign :db2) diff --git a/db-mysql/Makefile b/db-mysql/Makefile index dd47bc5..bd3cfd2 100644 --- a/db-mysql/Makefile +++ b/db-mysql/Makefile @@ -17,10 +17,11 @@ SUBDIRS= include ../Makefile.common -base=uffi_mysql +base=clsql_mysql source=$(base).c object=$(base).o -shared_lib=uffi_mysql.so +shared_lib=$(base).so + .PHONY: all all: $(shared_lib) diff --git a/db-mysql/uffi_mysql.c b/db-mysql/clsql_mysql.c similarity index 100% rename from db-mysql/uffi_mysql.c rename to db-mysql/clsql_mysql.c diff --git a/db-odbc/odbc-loader.lisp b/db-odbc/odbc-loader.lisp index 07c77b0..b63a25a 100644 --- a/db-odbc/odbc-loader.lisp +++ b/db-odbc/odbc-loader.lisp @@ -18,19 +18,8 @@ (in-package #:odbc) -(defparameter *odbc-library-path* - (uffi:find-foreign-library - '("odbc32" "libodbc" "libiodbc") - `(,(make-pathname :directory (pathname-directory *load-truename*)) - #+64bit "/usr/lib64/" - "/usr/lib/" - "/sw/lib/" - "/usr/local/lib/" - "/home/kevin/debian/src/clsql/db-odbc/" - "/windows/system32/" - "/winnt/system32/" - "/odbc/lib/opt/") - :drive-letters '("C"))) +(defparameter *odbc-library-filenames* + '("odbc32" "libodbc" "libiodbc")) (defvar *odbc-supporting-libraries* '("c") "Used only by CMU. List of library flags needed to be passed to ld to @@ -44,8 +33,8 @@ set to the right path before compiling or loading the system.") *odbc-library-loaded*) (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :odbc))) - (uffi:load-foreign-library *odbc-library-path* - :module "odbc") + (clsql-uffi:find-and-load-foreign-library *odbc-library-filenames* + :module "odbc") (setq *odbc-library-loaded* t)) (clsql-sys:database-type-load-foreign :odbc) diff --git a/db-oracle/oracle-loader.lisp b/db-oracle/oracle-loader.lisp index 7241402..9a970d3 100644 --- a/db-oracle/oracle-loader.lisp +++ b/db-oracle/oracle-loader.lisp @@ -22,24 +22,14 @@ (parse-namestring (concatenate 'string oracle-home "/")))) "Pathname of ORACLE_HOME as set in user environment.") -(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-client-library-filenames* + (list* "libclntsh" "oci" + (when *oracle-home* + (loop for dir-name in '("lib" "bin") + nconc (loop for lib-name in '("libclntsh" "oci") + collect (make-pathname :defaults lib-name + :directory (append (pathname-directory *oracle-home*) + (list dir-name)))))))) (defvar *oracle-supporting-libraries* '("c") "Used only by CMU. List of library flags needed to be passed to ld to @@ -53,14 +43,10 @@ set to the right path before compiling or loading the system.") *oracle-library-loaded*) (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-uffi:find-and-load-foreign-library *oracle-client-library-filenames* + :module "clsql-oracle" + :supporting-libraries *oracle-supporting-libraries*) + (setq *oracle-library-loaded* t)) (clsql-sys:database-type-load-foreign :oracle) diff --git a/db-postgresql/postgresql-loader.lisp b/db-postgresql/postgresql-loader.lisp index a7fefa9..8124bb9 100644 --- a/db-postgresql/postgresql-loader.lisp +++ b/db-postgresql/postgresql-loader.lisp @@ -33,24 +33,10 @@ set to the right path before compiling or loading the system.") (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :postgresql))) - (let ((libpath (uffi:find-foreign-library - "libpq" - '("/opt/postgresql/lib/" "/usr/local/lib/" - #+(or 64bit x86-64) "/usr/lib64/" - "/usr/lib/" "/postgresql/lib/" - "/usr/local/pgsql/lib/" "/usr/lib/pgsql/" - "/opt/pgsql/lib/pgsql" "/sw/lib/pgsql/" "/sw/lib/" - "/windows/system32/") - :drive-letters '("C" "D" "E") - #+(or macosx darwin ccl-5.0) :types - #+(or macosx darwin ccl-5.0) '("so" "dylib") - ))) - (if (uffi:load-foreign-library libpath - :module "postgresql" - :supporting-libraries - *postgresql-supporting-libraries*) - (setq *postgresql-library-loaded* t) - (warn "Can't load PostgreSQL client library ~A" libpath)))) + (clsql-uffi:find-and-load-foreign-library "libpq" + :module "postgresql" + :supporting-libraries *postgresql-supporting-libraries*) + (setq *postgresql-library-loaded* t)) (clsql-sys:database-type-load-foreign :postgresql) diff --git a/db-sqlite/sqlite-loader.lisp b/db-sqlite/sqlite-loader.lisp index 59baaee..27bea20 100644 --- a/db-sqlite/sqlite-loader.lisp +++ b/db-sqlite/sqlite-loader.lisp @@ -31,17 +31,10 @@ set to the right path before compiling or loading the system.") *sqlite-library-loaded*) (defmethod database-type-load-foreign ((database-type (eql :sqlite))) - (let ((libpath (uffi:find-foreign-library - '("libsqlite" "sqlite") - '(#+64bit "/usr/lib64/" - "/usr/lib/" "/usr/local/lib/" "/bin/") - :drive-letters '("C" "D" "E")))) - (if (uffi:load-foreign-library libpath - :module "sqlite" - :supporting-libraries - *sqlite-supporting-libraries*) - (setq *sqlite-library-loaded* t) - (warn "Can't load SQLite library ~A" libpath)))) + (clsql-uffi:find-and-load-foreign-library '("libsqlite" "sqlite") + :module "sqlite" + :supporting-libraries *sqlite-supporting-libraries*) + (setq *sqlite-library-loaded* t)) (clsql-sys:database-type-load-foreign :sqlite) diff --git a/db-sqlite3/sqlite3-loader.lisp b/db-sqlite3/sqlite3-loader.lisp index 9efaf1f..a3b26b8 100644 --- a/db-sqlite3/sqlite3-loader.lisp +++ b/db-sqlite3/sqlite3-loader.lisp @@ -31,16 +31,9 @@ set to the right path before compiling or loading the system.") *sqlite3-library-loaded*) (defmethod database-type-load-foreign ((database-type (eql :sqlite3))) - (let ((libpath (uffi:find-foreign-library - '("libsqlite3" "sqlite3") - '(#+64bit "/usr/lib64/" - "/usr/lib/" "/usr/local/lib/" "/bin/") - :drive-letters '("C" "D" "E")))) - (if (uffi:load-foreign-library libpath - :module "sqlite3" - :supporting-libraries - *sqlite3-supporting-libraries*) - (setq *sqlite3-library-loaded* t) - (warn "Can't load Sqlite3 library ~A" libpath)))) + (clsql-uffi:find-and-load-foreign-library '("libsqlite3" "sqlite3") + :module "sqlite3" + :supporting-libraries *sqlite3-supporting-libraries*) + (setq *sqlite3-library-loaded* t)) (clsql-sys:database-type-load-foreign :sqlite3) diff --git a/debian/changelog b/debian/changelog index 3abdab6..015d7a2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-sql (3.1.17-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Wed, 08 Jun 2005 13:25:06 -0600 + cl-sql (3.1.16-1) unstable; urgency=low * New upstream diff --git a/uffi/clsql-uffi-loader.lisp b/uffi/clsql-uffi-loader.lisp index 8b9efb7..05eee3f 100644 --- a/uffi/clsql-uffi-loader.lisp +++ b/uffi/clsql-uffi-loader.lisp @@ -18,12 +18,29 @@ (in-package #:clsql-uffi) -(defvar *clsql-uffi-library-filename* - (uffi:find-foreign-library - '(#+(or 64bit x86-64) "uffi64" "uffi") - `(,clsql-uffi-system::*library-file-dir* - "/usr/lib/clsql/") - :drive-letters '("C"))) +(defun find-and-load-foreign-library (filenames &key module supporting-libraries (errorp t)) + (setq filenames (if (listp filenames) filenames (list filenames))) + (or (loop for type in (uffi:foreign-library-types) + for suffix = (make-pathname :type type) + thereis (loop for filename in filenames + thereis (handler-case + (uffi:load-foreign-library (merge-pathnames filename suffix) + :module module + :supporting-libraries supporting-libraries) + (error (c) + (warn "~A" c) + nil)))) + (when errorp + (error "Couldn't load foreign librar~@P ~{~S~^, ~}." + (length filenames) filenames)))) + +(defvar *clsql-uffi-library-filenames* + (list #+(or 64bit x86-64) (make-pathname :name "uffi64" + :directory clsql-uffi-system::*library-file-dir*) + #+(or 64bit x86-64) "uffi64" + (make-pathname :name "uffi" + :directory clsql-uffi-system::*library-file-dir*) + "uffi")) (defvar *clsql-uffi-supporting-libraries* '("c") "Used only by CMU. List of library flags needed to be passed to ld to @@ -34,15 +51,11 @@ set to the right path before compiling or loading the system.") "T if foreign library was able to be loaded successfully") (defun load-uffi-foreign-library () - (unless (probe-file *clsql-uffi-library-filename*) - (error "Unable to find uffi.so")) - - (if (uffi:load-foreign-library *clsql-uffi-library-filename* - :module "clsql-uffi" - :supporting-libraries - *clsql-uffi-supporting-libraries*) - (setq *uffi-library-loaded* t) - (error "Unable to load helper library ~A" *clsql-uffi-library-filename*))) + (find-and-load-foreign-library *clsql-uffi-library-filenames* + :module "clsql-uffi" + :supporting-libraries + *clsql-uffi-supporting-libraries*) + (setq *uffi-library-loaded* t)) (load-uffi-foreign-library) diff --git a/uffi/clsql-uffi-package.lisp b/uffi/clsql-uffi-package.lisp index e5837a0..be5abf5 100644 --- a/uffi/clsql-uffi-package.lisp +++ b/uffi/clsql-uffi-package.lisp @@ -21,6 +21,7 @@ (defpackage #:clsql-uffi (:use #:cl #:uffi) (:export + #:find-and-load-foreign-library #:canonicalize-type-list #:convert-raw-field #:atoi -- 2.34.1