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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
{
lib,
stdenv,
fetchpatch,
fetchurl,
autoreconfHook,
autoconf269,
cxxSupport ? true,
compat185 ? true,
dbmSupport ? false,
# Options from inherited versions
version,
sha256,
extraPatches ? [ ],
license ? lib.licenses.sleepycat,
drvArgs ? { },
}:
stdenv.mkDerivation (
rec {
pname = "db";
inherit version;
src = fetchurl {
url = "https://download.oracle.com/berkeley-db/db-${version}.tar.gz";
sha256 = sha256;
};
# autoreconfHook: the provided configure script features `main` returning implicit `int`,
# which causes configure checks to work incorrectly with clang 16.
nativeBuildInputs = lib.optionals stdenv.cc.isClang [ autoconf269 ] ++ [ autoreconfHook ];
patches = [
(fetchpatch {
name = "gcc15.patch";
url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-libs/db/files/db-4.8.30-tls-configure.patch?id=1ae36006c79ef705252f5f7009e79f6add7dc353";
hash = "sha256-OzQL+kgXtcvhvyleDLuH1abhY4Shb/9IXx4ZkeFbHOA=";
})
]
++ extraPatches;
outputs = [
"bin"
"out"
"dev"
];
# Required when regenerated the configure script to make sure the vendored macros are found.
autoreconfFlags = [
"-fi"
"-Iaclocal"
"-Iaclocal_java"
];
preAutoreconf = ''
pushd dist
# Upstream’s `dist/s_config` cats everything into `aclocal.m4`, but that doesn’t work with
# autoreconfHook, so cat `config.m4` to another file. Otherwise, it won’t be found by `aclocal`.
cat aclocal/config.m4 >> aclocal/options.m4
'';
# This isn’t pretty. The version information is kept separate from the configure script.
# After the configure script is regenerated, the version information has to be replaced with the
# contents of `dist/RELEASE`.
postAutoreconf = ''
(
declare -a vars=(
"DB_VERSION_FAMILY"
"DB_VERSION_RELEASE"
"DB_VERSION_MAJOR"
"DB_VERSION_MINOR"
"DB_VERSION_PATCH"
"DB_VERSION_STRING"
"DB_VERSION_FULL_STRING"
"DB_VERSION_UNIQUE_NAME"
"DB_VERSION"
)
source RELEASE
for var in "''${vars[@]}"; do
sed -e "s/__EDIT_''${var}__/''${!var}/g" -i configure
done
)
popd
'';
env.NIX_CFLAGS_COMPILE = toString [
"-Wno-error=incompatible-pointer-types"
];
configureFlags = [
(if cxxSupport then "--enable-cxx" else "--disable-cxx")
(if compat185 then "--enable-compat185" else "--disable-compat185")
]
++ lib.optional dbmSupport "--enable-dbm"
++ lib.optional stdenv.hostPlatform.isFreeBSD "--with-pic";
preConfigure = ''
cd build_unix
configureScript=../dist/configure
'';
postInstall = ''
rm -rf $out/docs
'';
enableParallelBuilding = true;
doCheck = true;
checkPhase = ''
make examples_c examples_cxx
'';
meta = {
homepage = "https://www.oracle.com/database/technologies/related/berkeleydb.html";
description = "Berkeley DB";
license = license;
platforms = lib.platforms.unix;
};
}
// drvArgs
)
|