r2913: *** empty log message ***
[clsql.git] / db-postgresql / postgresql-loader.cl
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          postgresql-loader.sql
6 ;;;; Purpose:       PostgreSQL library loader using UFFI
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Feb 2002
9 ;;;;
10 ;;;; $Id: postgresql-loader.cl,v 1.1 2002/09/18 07:43:41 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 :postgresql)
21
22
23 (defvar *postgresql-supporting-libraries* '("crypt" "c")
24   "Used only by CMU. List of library flags needed to be passed to ld to
25 load the PostgresSQL client library succesfully.  If this differs at your site,
26 set to the right path before compiling or loading the system.")
27
28 (defvar *postgresql-library-loaded* nil
29   "T if foreign library was able to be loaded successfully")
30
31 (defmethod clsql-base-sys:database-type-library-loaded ((database-type
32                                                     (eql :postgresql)))
33   *postgresql-library-loaded*)
34                                       
35 (defmethod clsql-base-sys:database-type-load-foreign ((database-type
36                                                   (eql :postgresql)))
37   (let ((libpath (uffi:find-foreign-library 
38                   "libpq"
39                   '("/opt/postgresql/lib/" "/usr/local/lib/" 
40                     "/usr/lib/" "/postgresql/lib/"
41                     "/usr/local/pgsql/lib/" "/usr/lib/pgsql/"
42                     "/opt/pgsql/lib/pgsql")
43                   :drive-letters '("C" "D" "E"))))
44     (if (uffi:load-foreign-library libpath
45                                    :module "postgresql"
46                                    :supporting-libraries 
47                                    *postgresql-supporting-libraries*)
48         (setq *postgresql-library-loaded* t)
49       (warn "Can't load PostgreSQL client library ~A" libpath))))
50
51 (clsql-base-sys:database-type-load-foreign :postgresql)
52