summaryrefslogtreecommitdiff
blob: 59fd9ac9158d06a4c911859928ea804298439072 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit common-lisp-2 eutils multilib

DESCRIPTION="A multi-platform SQL interface for Common Lisp"
HOMEPAGE="http://${PN}.b9.com/
		http://packages.debian.org/unstable/devel/cl-sql.html
		http://www.cliki.net/CLSQL"
SRC_URI="http://files.b9.com/clsql/${P}.tar.gz"
LICENSE="LLGPL-2.1"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~sparc ~x86"
IUSE="postgres mysql sqlite sqlite3 odbc"
DEPEND="!dev-lisp/cl-sql
		dev-lisp/md5
		>=dev-lisp/uffi-1.5.7
		postgres? ( dev-db/libpq )
		mysql? ( virtual/mysql )
		sqlite? ( =dev-db/sqlite-2* )
		sqlite3? ( =dev-db/sqlite-3* )
		odbc? ( dev-db/unixODBC )"

src_unpack() {
	unpack ${A}
	sed -i "s,/usr/lib,/usr/$(get_libdir),g" "${S}"/${PN}-{mysql,uffi}.asd
	sed -i 's,"usr" "lib","usr" "'$(get_libdir)'",g' "${S}"/${PN}-{mysql,uffi}.asd
}

src_compile() {
	make -C uffi || die
	if use mysql; then
		make -C db-mysql || die "Cannot build foreign glue to libmysql"
	fi
}

install_clsql_pkg() {
	cd "${S}"
	common-lisp-install db-${1}/*.lisp ${PN}-${1}.asd
	common-lisp-symlink-asdf ${PN}-${1}
	if [ -f db-${1}/${PN}_${1}.so ]; then
		exeinto /usr/$(get_libdir)/${PN} ; doexe db-${1}/${PN}_${1}.so
	fi
}

src_install() {
	common-lisp-install ${PN}.asd sql/*.lisp ${PN}-tests.asd tests
	common-lisp-symlink-asdf ${PN} ${PN}-tests

	common-lisp-install uffi/*.lisp ${PN}-uffi.asd
	common-lisp-symlink-asdf ${PN}-uffi
	exeinto /usr/$(get_libdir)/${PN} ; doexe uffi/${PN}_uffi.so

	install_clsql_pkg postgresql-socket
	use postgres && install_clsql_pkg postgresql
	for dbtype in mysql odbc sqlite sqlite3; do
		use ${dbtype} && install_clsql_pkg ${dbtype}
	done
	# TODO: figure out the dependencies
	install_clsql_pkg aodbc
	install_clsql_pkg db2
	install_clsql_pkg oracle

	dodoc BUGS CONTRIBUTORS ChangeLog INSTALL LATEST-TEST-RESULTS NEWS README TODO
	dodoc doc/clsql.pdf
	tar xfz doc/html.tar.gz -C "${T}" && dohtml "${T}"/html/*
	docinto examples && dodoc examples/*
	docinto notes && dodoc notes/*

	dodir /etc
	cat > "${D}"/etc/clsql-init.lisp <<EOF
(clsql:push-library-path #p"/usr/$(get_libdir)/")
(clsql:push-library-path #p"/usr/$(get_libdir)/clsql/")
EOF
}