Patches for loading cl-sql with postgres on Mac OSX
Robert Goldman <[email protected]>
| Newsgroups | gmane.lisp.clsql.general |
|---|---|
| Message-ID | <[email protected]> |
A colleague of mine tweaked CLSQL to make it load with postgres on Mac
OSX with SBCL. He asked me to forward the patches.
He reports:
I found that the check for 64-bit on Mac OS X was failing on 10.6.3.
This fixes it:
Index: Makefile.common
===================================================================
--- Makefile.common (revision 4840)
+++ Makefile.common (revision 4841)
@@ -1,12 +1,14 @@
UNAME=$(shell uname)
UNAME_A=$(shell uname -a)
DARWIN_LIBC=$(shell file /usr/lib/libc.dylib)
+DARWIN_SYSCTL=$(shell /usr/sbin/sysctl -n hw.optional.x86_64)
OS_AIX=$(shell expr "$(UNAME)" : '.*AIX.*')
OS_SUNOS=$(shell expr "$(UNAME)" : '.*SunOS.*')
OS_DARWIN=$(shell expr "$(UNAME)" : '.*Darwin.*')
ifneq ($(OS_DARWIN),0)
- OS_DARWIN64=$(shell expr "$(DARWIN_LIBC)" : '.*x86_64.*')
+ #OS_DARWIN64=$(shell expr "$(DARWIN_LIBC)" : '.*x86_64.*')
+ OS_DARWIN64=$(shell expr "$(DARWIN_SYSCTL)" : '1')
else
OS_DARWIN64=0
endif
and then also:
I tried using the postgresql-socket library on Mac OS
and once I got past the 64-bit issues, I ran into an
error loading libpq. Seems that
CLSQL-SYS:*FOREIGN-LIBRARY-SEARCH-PATHS* only contains
the directory that the clsql_uffi library is in, yet
the postgresql-socket code is trying to load libpq
from that path.
The following patch fixes it for my system, but isn't
very portable as it looks specifically for my install
from macports in /opt/local/lib/postgresql84/. That
should at least be any postgresql directory in
/opt/local/lib.
Index: db-postgresql/postgresql-loader.lisp
===================================================================
--- db-postgresql/postgresql-loader.lisp (revision 4819)
+++ db-postgresql/postgresql-loader.lisp (working copy)
@@ -31,9 +31,16 @@
(defmethod clsql-sys:database-type-load-foreign ((database-type
(eql :postgresql)))
- (clsql-uffi:find-and-load-foreign-library "libpq"
- :module "postgresql"
- :supporting-libraries
*postgresql-supporting-libraries*)
+
+ (uffi:load-foreign-library
+ (uffi:find-foreign-library "libpq"
+ '(#+(or 64bit x86-64) "/usr/lib64/"
+ "/usr/lib/" "/usr/local/lib/" "/lib/"
"/opt/local/lib/postgresql84/"))
+ :module "postgresql"
+ :supporting-libraries *postgresql-supporting-libraries*)
+;; (clsql-uffi:find-and-load-foreign-library "libpq"
+;; :module "postgresql"
+;; :supporting-libraries
*postgresql-supporting-libraries*)
(setq *postgresql-library-loaded* t))
(clsql-sys:database-type-load-foreign :postgresql)