Skip to content

Commit

Permalink
zlib: clean up static/shared distincion
Browse files Browse the repository at this point in the history
This is kind of a mess, but basically:

- static=true, shared=true means to build statically but move it to
  the static output
- static=true, shared=false means to build statically and leave it in
  the main output
- static=false, shared=true means to not build static at all

Confusingly, the old default was static=true, shared=true even though
static=false? Still can’t figure out what was meant by that.
  • Loading branch information
matthewbauer committed Dec 5, 2018
1 parent 5e06294 commit e999def
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkgs/development/libraries/zlib/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ stdenv
, fetchurl
, static ? false
, static ? true
, shared ? true
}:

stdenv.mkDerivation (rec {
Expand All @@ -24,13 +25,15 @@ stdenv.mkDerivation (rec {
--replace 'ARFLAGS="-o"' 'ARFLAGS="-r"'
'';

outputs = [ "out" "dev" "static" ];
outputs = [ "out" "dev" ]
++ stdenv.lib.optional (shared && static) "static";
setOutputFlags = false;
outputDoc = "dev"; # single tiny man3 page

configureFlags = stdenv.lib.optional (!static) "--shared";
configureFlags = stdenv.lib.optional shared "--shared"
++ stdenv.lib.optional (static && !shared) "--static";

postInstall = ''
postInstall = stdenv.lib.optionalString (shared && static) ''
moveToOutput lib/libz.a "$static"
''
# jww (2015-01-06): Sometimes this library install as a .so, even on
Expand Down Expand Up @@ -64,7 +67,7 @@ stdenv.mkDerivation (rec {
"PREFIX=${stdenv.cc.targetPrefix}"
] ++ stdenv.lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [
"-f" "win32/Makefile.gcc"
] ++ stdenv.lib.optionals (!static) [
] ++ stdenv.lib.optionals shared [
"SHARED_MODE=1"
];

Expand Down

0 comments on commit e999def

Please sign in to comment.