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 (defparameter *clsql-mysql-library-path*
22 (uffi:find-foreign-library
24 `(,(make-pathname :directory (pathname-directory *load-truename*))
27 "/home/kevin/debian/src/clsql/db-mysql/")
28 :drive-letters '("C")))
30 (defparameter *libz-library-path*
31 (uffi:find-foreign-library
33 `(,(make-pathname :directory (pathname-directory *load-truename*))
38 "/home/kevin/debian/src/clsql/db-mysql/"
41 :drive-letters '("C")))
43 (defvar *mysql-library-candidate-names*
44 '("libmysqlclient" "libmysql"))
46 (defparameter *mysql-library-candidate-directories*
47 `(,(pathname-directory *load-pathname*)
48 "/opt/mysql/lib/mysql/" "/usr/local/lib/"
50 "/usr/lib/" "/usr/local/lib/mysql/" "/usr/lib/mysql/" "/mysql/lib/opt/" "/sw/lib/mysql/"))
52 (defvar *mysql-library-candidate-drive-letters* '("C" "D" "E"))
54 (defvar *mysql-supporting-libraries* '("c")
55 "Used only by CMU. List of library flags needed to be passed to ld to
56 load the MySQL client library succesfully. If this differs at your site,
57 set to the right path before compiling or loading the system.")
59 (defvar *mysql-library-loaded* nil
60 "T if foreign library was able to be loaded successfully")
62 (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :mysql)))
63 *mysql-library-loaded*)
65 (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :mysql)))
67 (uffi:find-foreign-library *mysql-library-candidate-names*
68 *mysql-library-candidate-directories*
70 *mysql-library-candidate-drive-letters*)))
71 (unless (probe-file mysql-path)
72 (error "Can't find mysql client library to load"))
73 (uffi:load-foreign-library *libz-library-path*)
74 (uffi:load-foreign-library mysql-path
77 *mysql-supporting-libraries*)
78 (uffi:load-foreign-library *clsql-mysql-library-path*
81 (append *mysql-supporting-libraries*)))
82 (setq *mysql-library-loaded* t))
85 (clsql-sys:database-type-load-foreign :mysql)