0ec9c03c2f74e592575605f6ececc8e776bfa609
[clsql.git] / db-mysql / mysql-loader.lisp
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 ;;;; Author:   Kevin M. Rosenberg
8 ;;;; Created:  Feb 2002
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 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 (in-package #:mysql)
20
21 (defparameter *clsql-mysql-library-candidate-names*
22   (list #+(or 64bit x86-64) "clsql_mysql64"
23         "clsql_mysql"))
24
25 (defvar *mysql-library-candidate-names*
26   '("libmysqlclient" "libmysql"))
27
28 (defvar *mysql-supporting-libraries* '("c")
29   "Used only by CMU. List of library flags needed to be passed to ld to
30 load the MySQL client library succesfully.  If this differs at your site,
31 set to the right path before compiling or loading the system.")
32
33 (defvar *mysql-library-loaded* nil
34   "T if foreign library was able to be loaded successfully")
35
36 (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :mysql)))
37   *mysql-library-loaded*)
38
39 (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :mysql)))
40   (clsql:push-library-path
41    (make-pathname :directory clsql-mysql-system::*library-file-dir*))
42   (clsql-uffi:find-and-load-foreign-library *mysql-library-candidate-names*
43                                             :module "mysql"
44                                             :supporting-libraries *mysql-supporting-libraries*)
45   (clsql-uffi:find-and-load-foreign-library *clsql-mysql-library-candidate-names*
46                                             :module "clsql-mysql"
47                                             :supporting-libraries *mysql-supporting-libraries*)
48   (setq *mysql-library-loaded* t))
49
50
51 (clsql-sys:database-type-load-foreign :mysql)
52