at master 110 lines 2.7 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 autoreconfHook, 6 cxxSupport ? true, 7 compat185 ? true, 8 dbmSupport ? false, 9 10 # Options from inherited versions 11 version, 12 sha256, 13 extraPatches ? [ ], 14 license ? lib.licenses.sleepycat, 15 drvArgs ? { }, 16}: 17 18stdenv.mkDerivation ( 19 rec { 20 pname = "db"; 21 inherit version; 22 23 src = fetchurl { 24 url = "https://download.oracle.com/berkeley-db/db-${version}.tar.gz"; 25 sha256 = sha256; 26 }; 27 28 # The provided configure script features `main` returning implicit `int`, which causes 29 # configure checks to work incorrectly with clang 16. 30 nativeBuildInputs = [ autoreconfHook ]; 31 32 patches = extraPatches; 33 34 outputs = [ 35 "bin" 36 "out" 37 "dev" 38 ]; 39 40 # Required when regenerated the configure script to make sure the vendored macros are found. 41 autoreconfFlags = [ 42 "-fi" 43 "-Iaclocal" 44 "-Iaclocal_java" 45 ]; 46 47 preAutoreconf = '' 48 pushd dist 49 # Upstreams `dist/s_config` cats everything into `aclocal.m4`, but that doesnt work with 50 # autoreconfHook, so cat `config.m4` to another file. Otherwise, it wont be found by `aclocal`. 51 cat aclocal/config.m4 >> aclocal/options.m4 52 ''; 53 54 # This isn’t pretty. The version information is kept separate from the configure script. 55 # After the configure script is regenerated, the version information has to be replaced with the 56 # contents of `dist/RELEASE`. 57 postAutoreconf = '' 58 ( 59 declare -a vars=( 60 "DB_VERSION_FAMILY" 61 "DB_VERSION_RELEASE" 62 "DB_VERSION_MAJOR" 63 "DB_VERSION_MINOR" 64 "DB_VERSION_PATCH" 65 "DB_VERSION_STRING" 66 "DB_VERSION_FULL_STRING" 67 "DB_VERSION_UNIQUE_NAME" 68 "DB_VERSION" 69 ) 70 source RELEASE 71 for var in "''${vars[@]}"; do 72 sed -e "s/__EDIT_''${var}__/''${!var}/g" -i configure 73 done 74 ) 75 popd 76 ''; 77 78 configureFlags = [ 79 (if cxxSupport then "--enable-cxx" else "--disable-cxx") 80 (if compat185 then "--enable-compat185" else "--disable-compat185") 81 ] 82 ++ lib.optional dbmSupport "--enable-dbm" 83 ++ lib.optional stdenv.hostPlatform.isFreeBSD "--with-pic"; 84 85 preConfigure = '' 86 cd build_unix 87 configureScript=../dist/configure 88 ''; 89 90 postInstall = '' 91 rm -rf $out/docs 92 ''; 93 94 enableParallelBuilding = true; 95 96 doCheck = true; 97 98 checkPhase = '' 99 make examples_c examples_cxx 100 ''; 101 102 meta = with lib; { 103 homepage = "https://www.oracle.com/database/technologies/related/berkeleydb.html"; 104 description = "Berkeley DB"; 105 license = license; 106 platforms = platforms.unix; 107 }; 108 } 109 // drvArgs 110)