r1639: Initial revision
[clsql.git] / interfaces / mysql / mysql-loader.cl
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          mysql-loader.sql
6 ;;;; Purpose:       MySQL library loader using UFFI
7 ;;;; Programmers:   Kevin M. Rosenberg
8 ;;;; Date Started:  Feb 2002
9 ;;;;
10 ;;;; $Id: mysql-loader.cl,v 1.1 2002/03/23 14:04:52 kevin Exp $
11 ;;;;
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
13 ;;;;
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 ;;;; *************************************************************************
18
19 (declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
20 (in-package :mysql)
21
22 ;;;; Modified by Kevin Rosenberg 
23 ;;;;  - probe potential directories to find library
24 ;;;;  - Changed from CMUCL functions to UFFI to
25 ;;;;      -- prevent library from being loaded multiple times
26 ;;;;      -- support Allegro CL and Lispworks
27
28 (defvar *clsql-mysql-library-filename* 
29     (translate-logical-pathname 
30      #+(or linux unix) "CLSQL:interfaces;mysql;clsql-mysql.so"
31      #+(or mswindows win32) "CLSQL:interfaces;mysql;clsql-mysql.dll"
32      ))
33
34 (defvar *mysql-library-filename* 
35     (cond
36      ((probe-file "/opt/mysql/lib/mysql/libmysqlclient.so")
37       "/opt/mysql/lib/mysql/libmysqlclient.so")
38      ((probe-file "/usr/local/lib/libmysqlclient.so")
39       "/usr/local/lib/libmysqlclient.so")
40      ((probe-file "/usr/lib/libmysqlclient.so")
41       "/usr/lib/libmysqlclient.so")
42      #+(or win32 mswindows) 
43      ((probe-file "c:/mysql/lib/opt/libmysql.dll")
44       "c:/mysql/lib/opt/libmysql.dll")
45      (t
46       (warn "Can't find MySQL client library to load.")))
47   "Location where the MySQL client library is to be found.")
48
49 (defvar *mysql-supporting-libraries* '("c")
50   "Used only by CMU. List of library flags needed to be passed to ld to
51 load the MySQL client library succesfully.  If this differs at your site,
52 set to the right path before compiling or loading the system.")
53
54
55
56 (defmethod database-type-load-foreign ((database-type (eql :mysql)))
57   (uffi:load-foreign-library *mysql-library-filename* 
58                              :module "mysql" 
59                              :supporting-libraries 
60                              *mysql-supporting-libraries*)
61   (uffi:load-foreign-library *clsql-mysql-library-filename* 
62                              :module "clsql-mysql" 
63                              :supporting-libraries 
64                              (append *mysql-supporting-libraries*)))
65
66
67 (database-type-load-foreign :mysql)
68
69