1{ lib, stdenv, fetchurl, interactive ? false, readline ? null, ncurses ? null }:
2
3assert interactive -> readline != null && ncurses != null;
4
5stdenv.mkDerivation {
6 name = "sqlite-3.8.11.1";
7
8 src = fetchurl {
9 url = "http://sqlite.org/2015/sqlite-autoconf-3081101.tar.gz";
10 sha1 = "d0e22d7e361b6f50830a3cdeafe35311443f8f9a";
11 };
12
13 buildInputs = lib.optionals interactive [ readline ncurses ];
14
15 configureFlags = [ "--enable-threadsafe" ];
16
17 NIX_CFLAGS_COMPILE = [
18 "-DSQLITE_ENABLE_COLUMN_METADATA"
19 "-DSQLITE_ENABLE_DBSTAT_VTAB"
20 "-DSQLITE_ENABLE_FTS3"
21 "-DSQLITE_ENABLE_FTS3_PARENTHESIS"
22 "-DSQLITE_ENABLE_FTS4"
23 "-DSQLITE_ENABLE_RTREE"
24 "-DSQLITE_ENABLE_STMT_SCANSTATUS"
25 "-DSQLITE_ENABLE_UNLOCK_NOTIFY"
26 "-DSQLITE_SOUNDEX"
27 "-DSQLITE_SECURE_DELETE"
28 ];
29
30 # Test for features which may not be available at compile time
31 preBuild = ''
32 # Use pread(), pread64(), pwrite(), pwrite64() functions for better performance if they are available.
33 if cc -Werror=implicit-function-declaration -x c - -o "$TMPDIR/pread_pwrite_test" <<< \
34 ''$'#include <unistd.h>\nint main()\n{\n pread(0, NULL, 0, 0);\n pwrite(0, NULL, 0, 0);\n return 0;\n}'; then
35 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DUSE_PREAD"
36 fi
37 if cc -Werror=implicit-function-declaration -x c - -o "$TMPDIR/pread64_pwrite64_test" <<< \
38 ''$'#include <unistd.h>\nint main()\n{\n pread64(0, NULL, 0, 0);\n pwrite64(0, NULL, 0, 0);\n return 0;\n}'; then
39 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DUSE_PREAD64"
40 elif cc -D_LARGEFILE64_SOURCE -Werror=implicit-function-declaration -x c - -o "$TMPDIR/pread64_pwrite64_test" <<< \
41 ''$'#include <unistd.h>\nint main()\n{\n pread64(0, NULL, 0, 0);\n pwrite64(0, NULL, 0, 0);\n return 0;\n}'; then
42 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DUSE_PREAD64 -D_LARGEFILE64_SOURCE"
43 fi
44
45 echo ""
46 echo "NIX_CFLAGS_COMPILE = $NIX_CFLAGS_COMPILE"
47 echo ""
48 '';
49
50 meta = {
51 homepage = http://www.sqlite.org/;
52 description = "A self-contained, serverless, zero-configuration, transactional SQL database engine";
53 platforms = stdenv.lib.platforms.unix;
54 maintainers = with stdenv.lib.maintainers; [ eelco np ];
55 };
56}