3395e71956e85f1951945b851125d4e86dd6ef23
[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 ;; searches clsql_mysql64 to accomodate both 32-bit and 64-bit libraries on same system
22 (defparameter *clsql-mysql-library-candidate-names*
23   `(,@(when (> most-positive-fixnum (expt 2 32)) (list "clsql_mysql64"))
24     "clsql_mysql"))
25
26 (defvar *mysql-library-candidate-names*
27   '("libmysqlclient" "libmysql"))
28
29 (defvar *mysql-supporting-libraries* '("c")
30   "Used only by CMU. List of library flags needed to be passed to ld to
31 load the MySQL client library succesfully.  If this differs at your site,
32 set to the right path before compiling or loading the system.")
33
34 (defvar *mysql-library-loaded* nil
35   "T if foreign library was able to be loaded successfully")
36
37 (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :mysql)))
38   *mysql-library-loaded*)
39
40 (defmethod clsql-sys:database-type-load-foreign ((database-type (eql :mysql)))
41   (clsql:push-library-path clsql-mysql-system::*library-file-dir*)
42
43   (clsql-uffi:find-and-load-foreign-library *mysql-library-candidate-names*
44                                             :module "mysql"
45                                             :supporting-libraries *mysql-supporting-libraries*)
46
47   (clsql-uffi:find-and-load-foreign-library *clsql-mysql-library-candidate-names*
48                                             :module "clsql-mysql"
49                                             :supporting-libraries *mysql-supporting-libraries*)
50   (setq *mysql-library-loaded* t))
51
52
53 (clsql-sys:database-type-load-foreign :mysql)
54