1{ stdenv, fetchurl, libdbi
2, mysql ? null
3, sqlite ? null
4, postgresql ? null
5}:
6
7with stdenv.lib;
8stdenv.mkDerivation rec {
9 name = "libdbi-drivers-0.9.0";
10
11 src = fetchurl {
12 url = "mirror://sourceforge/libdbi-drivers/${name}.tar.gz";
13 sha256 = "0m680h8cc4428xin4p733azysamzgzcmv4psjvraykrsaz6ymlj3";
14 };
15
16 buildInputs = [ libdbi sqlite postgresql ] ++ optional (mysql != null) mysql.connector-c;
17
18 postPatch = ''
19 sed -i '/SQLITE3_LIBS/ s/-lsqlite/-lsqlite3/' configure;
20 '';
21
22 configureFlags = [
23 "--sysconfdir=/etc"
24 "--localstatedir=/var"
25 "--disable-docs"
26 "--enable-libdbi"
27 "--with-dbi-incdir=${libdbi}/include"
28 "--with-dbi-libdir=${libdbi}/lib"
29 ] ++ optionals (mysql != null) [
30 "--with-mysql"
31 "--with-mysql-incdir=${mysql.connector-c}/include/mysql"
32 "--with-mysql-libdir=${mysql.connector-c}/lib/mysql"
33 ] ++ optionals (sqlite != null) [
34 "--with-sqlite3"
35 "--with-sqlite3-incdir=${sqlite.dev}/include/sqlite"
36 "--with-sqlite3-libdir=${sqlite.out}/lib/sqlite"
37 ] ++ optionals (postgresql != null) [
38 "--with-pgsql"
39 "--with-pgsql_incdir=${postgresql}/include"
40 "--with-pgsql_libdir=${postgresql.lib}/lib"
41 ];
42
43 installFlags = [ "DESTDIR=\${out}" ];
44
45 postInstall = ''
46 mv $out/$out/* $out
47 DIR=$out/$out
48 while rmdir $DIR 2>/dev/null; do
49 DIR="$(dirname "$DIR")"
50 done
51
52 # Remove the unneeded var/lib directories
53 rm -rf $out/var
54 '';
55
56 meta = {
57 homepage = http://libdbi-drivers.sourceforge.net/;
58 description = "Database drivers for libdbi";
59 platforms = platforms.all;
60 license = licenses.lgpl21;
61 maintainers = with maintainers; [ wkennington ];
62 };
63}