@@ -4,10 +4,9 @@
44, static ? false
55}:
66
7−let version = "1.2.11"; in
8−
97stdenv.mkDerivation rec {
108 name = "zlib-${version}";
9+ version = "1.2.11";
1110
1211 src = fetchurl {
1312 urls =
@@ -19,7 +18,7 @@ stdenv.mkDerivation rec {
1918
2019 patches = stdenv.lib.optional hostPlatform.isCygwin ./disable-cygwin-widechar.patch;
2120
22− postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
21+ postPatch = stdenv.lib.optionalString hostPlatform.isDarwin ''
2322 substituteInPlace configure \
2423 --replace '/usr/bin/libtool' 'ar' \
2524 --replace 'AR="libtool"' 'AR="ar"' \
@@ -30,14 +29,6 @@ stdenv.mkDerivation rec {
3029 setOutputFlags = false;
3130 outputDoc = "dev"; # single tiny man3 page
3231
33− # TODO(@Dridus) CC set by cc-wrapper setup-hook, so just empty out the preConfigure script when cross building, but leave the old incorrect script when not
34− # cross building to avoid hash breakage. Once hash breakage is acceptable, remove preConfigure entirely.
35− preConfigure = stdenv.lib.optionalString (hostPlatform == buildPlatform) ''
36− if test -n "$crossConfig"; then
37− export CC=$crossConfig-gcc
38− fi
39− '';
40−
4132 # FIXME needs gcc 4.9 in bootstrap tools
4233 hardeningDisable = [ "stackprotector" ];
4334
@@ -49,36 +40,41 @@ stdenv.mkDerivation rec {
4940 # jww (2015-01-06): Sometimes this library install as a .so, even on
5041 # Darwin; others time it installs as a .dylib. I haven't yet figured out
5142 # what causes this difference.
52− + stdenv.lib.optionalString stdenv.isDarwin ''
43+ + stdenv.lib.optionalString hostPlatform.isDarwin ''
5344 for file in $out/lib/*.so* $out/lib/*.dylib* ; do
5445 install_name_tool -id "$file" $file
5546 done
47+ ''
48+ # Non-typical naming confuses libtool which then refuses to use zlib's DLL
49+ # in some cases, e.g. when compiling libpng.
50+ + stdenv.lib.optionalString (hostPlatform.libc == "msvcrt") ''
51+ ln -s zlib1.dll $out/bin/libz.dll
5652 '';
5753
5854 # As zlib takes part in the stdenv building, we don't want references
5955 # to the bootstrap-tools libgcc (as uses to happen on arm/mips)
60− NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!stdenv.isDarwin) "-static-libgcc";
56+ NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!hostPlatform.isDarwin) "-static-libgcc";
6157
62− crossAttrs = {
63− dontStrip = static;
64− configurePlatforms = [];
65− } // stdenv.lib.optionalAttrs (hostPlatform.libc == "msvcrt") {
66− installFlags = [
67− "BINARY_PATH=$(out)/bin"
68− "INCLUDE_PATH=$(dev)/include"
69− "LIBRARY_PATH=$(out)/lib"
70− ];
71− makeFlags = [
72− "-f" "win32/Makefile.gcc"
73− "PREFIX=${stdenv.cc.prefix}"
74− ] ++ stdenv.lib.optional (!static) "SHARED_MODE=1";
58+ dontStrip = hostPlatform != buildPlatform && static;
59+ configurePlatforms = [];
7560
76− # Non-typical naming confuses libtool which then refuses to use zlib's DLL
77− # in some cases, e.g. when compiling libpng.
78− postInstall = postInstall + "ln -s zlib1.dll $out/bin/libz.dll";
79− };
61+ installFlags = stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
62+ "BINARY_PATH=$(out)/bin"
63+ "INCLUDE_PATH=$(dev)/include"
64+ "LIBRARY_PATH=$(out)/lib"
65+ ];
8066
81− passthru.version = version;
67+ makeFlags = [
68+ "PREFIX=${stdenv.cc.prefix}"
69+ ] ++ stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [
70+ "-f" "win32/Makefile.gcc"
71+ ] ++ stdenv.lib.optionals (!static) [
72+ "SHARED_MODE=1"
73+ ];
74+
75+ passthru = {
76+ inherit version;
77+ };
8278
8379 meta = with stdenv.lib; {
8480 description = "Lossless data-compression library";