aboutsummaryrefslogtreecommitdiff
path: root/pkgs/development/libraries/tinycdb
diff options
context:
space:
mode:
authorDmitry Bogatov <KAction@disroot.org>2020-09-07 15:06:00 -0400
committerDmitry Bogatov <KAction@disroot.org>2020-10-08 23:47:32 -0400
commit88b0840f73ddb018027eb46f05d8afa6d40201df (patch)
treeceee2d633e1b5054bc3324746f52ddb5140126e6 /pkgs/development/libraries/tinycdb
parent77cdb1f64f9e365e41beb61f1683948e6261152c (diff)
tinycdb: add support for static build
Diffstat (limited to 'pkgs/development/libraries/tinycdb')
-rw-r--r--pkgs/development/libraries/tinycdb/default.nix35
1 files changed, 27 insertions, 8 deletions
diff --git a/pkgs/development/libraries/tinycdb/default.nix b/pkgs/development/libraries/tinycdb/default.nix
index 71a105f3fd70..63e710643919 100644
--- a/pkgs/development/libraries/tinycdb/default.nix
+++ b/pkgs/development/libraries/tinycdb/default.nix
@@ -1,18 +1,37 @@
{ stdenv, lib, fetchurl }:
+let
+ isCross = stdenv.buildPlatform != stdenv.hostPlatform;
+ cross = "${stdenv.hostPlatform.config}";
+ static = stdenv.hostPlatform.isStatic;
-stdenv.mkDerivation rec {
+ cc = if !isCross then "cc" else "${cross}-cc";
+ ar = if !isCross then "ar" else "${cross}-ar";
+ ranlib = if !isCross then "ranlib" else "${cross}-ranlib";
+in stdenv.mkDerivation rec {
+ postPatch = ''
+ sed -i 's,set --, set -x; set --,' Makefile
+ '';
pname = "tinycdb";
version = "0.78";
- outputs = [ "out" "dev" "lib" "man" ];
+ # In general, static library (.a) goes to "dev", shared (.so) to
+ # "lib". In case of static build, there is no .so library, so "lib"
+ # output is useless and empty.
+ outputs = [ "out" "dev" "man" ] ++ lib.optional (!static) "lib";
separateDebugInfo = true;
- makeFlags = [ "prefix=$(out)" "staticlib" "sharedlib" "cdb-shared" ];
+ makeFlags =
+ [ "prefix=$(out)" "CC=${cc}" "AR=${ar}" "RANLIB=${ranlib}" "static"
+ ] ++ lib.optional (!static) "shared";
postInstall = ''
- mkdir -p $lib/lib $dev/lib $out/bin
- cp libcdb.so* $lib/lib
- cp cdb-shared $out/bin/cdb
+ mkdir -p $dev/lib $out/bin
mv $out/lib/libcdb.a $dev/lib
rmdir $out/lib
- '';
+ '' + (if static then ''
+ cp cdb $out/bin/cdb
+ '' else ''
+ mkdir -p $lib/lib
+ cp libcdb.so* $lib/lib
+ cp cdb-shared $out/bin/cdb
+ '');
src = fetchurl {
url = "http://www.corpit.ru/mjt/tinycdb/${pname}-${version}.tar.gz";
@@ -27,7 +46,7 @@ stdenv.mkDerivation rec {
tinycdb is a small, fast and reliable utility and subroutine
library for creating and reading constant databases. The database
structure is tuned for fast reading.
- '';
+ '';
homepage = "https://www.corpit.ru/mjt/tinycdb.html";
license = licenses.publicDomain;