1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: mysql-loader.sql
6 ;;;; Purpose: MySQL library loader using UFFI
7 ;;;; Programmers: Kevin M. Rosenberg
8 ;;;; Date Started: Feb 2002
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
14 ;;;; CLSQL users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
21 ;;;; Modified by Kevin Rosenberg
22 ;;;; - probe potential directories to find library
23 ;;;; - Changed from CMUCL functions to UFFI to
24 ;;;; -- prevent library from being loaded multiple times
25 ;;;; -- support Allegro CL and Lispworks
27 (defparameter *clsql-mysql-library-path*
28 (uffi:find-foreign-library
30 `(,(make-pathname :directory (pathname-directory *load-truename*))
33 "/home/kevin/debian/src/clsql/db-mysql/")
34 :drive-letters '("C")))
36 (defparameter *libz-library-path*
37 (uffi:find-foreign-library
39 `(,(make-pathname :directory (pathname-directory *load-truename*))
43 "/home/kevin/debian/src/clsql/db-mysql/"
46 :drive-letters '("C")))
48 (defvar *mysql-library-candidate-names*
49 '("libmysqlclient" "libmysql"))
51 (defparameter *mysql-library-candidate-directories*
52 `(,(pathname-directory *load-pathname*)
53 "/opt/mysql/lib/mysql/" "/usr/local/lib/" "/usr/lib/" "/usr/local/lib/mysql/" "/usr/lib/mysql/" "/mysql/lib/opt/" "/sw/lib/mysql/"))
55 (defvar *mysql-library-candidate-drive-letters* '("C" "D" "E"))
57 (defvar *mysql-supporting-libraries* '("c")
58 "Used only by CMU. List of library flags needed to be passed to ld to
59 load the MySQL client library succesfully. If this differs at your site,
60 set to the right path before compiling or loading the system.")
62 (defvar *mysql-library-loaded* nil
63 "T if foreign library was able to be loaded successfully")
65 (defmethod clsql-base-sys:database-type-library-loaded ((database-type (eql :mysql)))
66 *mysql-library-loaded*)
68 (defmethod clsql-base-sys:database-type-load-foreign ((database-type (eql :mysql)))
70 (uffi:find-foreign-library *mysql-library-candidate-names*
71 *mysql-library-candidate-directories*
73 *mysql-library-candidate-drive-letters*)))
74 (unless (probe-file mysql-path)
75 (error "Can't find mysql client library to load"))
76 (uffi:load-foreign-library *libz-library-path*)
77 (uffi:load-foreign-library mysql-path
80 *mysql-supporting-libraries*)
81 (uffi:load-foreign-library *clsql-mysql-library-path*
84 (append *mysql-supporting-libraries*)))
85 (setq *mysql-library-loaded* t))
88 (clsql-base-sys:database-type-load-foreign :mysql)