@ -4,10 +4,9 @@
, static ? false
} :
let version = " 1 . 2 . 1 1 " ; in
stdenv . mkDerivation rec {
name = " z l i b - ${ version } " ;
version = " 1 . 2 . 1 1 " ;
src = fetchurl {
urls =
@ -19,7 +18,7 @@ stdenv.mkDerivation rec {
patches = stdenv . lib . optional hostPlatform . isCygwin ./disable-cygwin-widechar.patch ;
postPatch = stdenv . lib . optionalString stdenv . isDarwin ''
postPatch = stdenv . lib . optionalString hostPlatform . isDarwin ''
substituteInPlace configure \
- - replace ' /usr/bin/libtool ' ' ar' \
- - replace ' AR = " l i b t o o l " ' ' AR = " a r " ' \
@ -30,14 +29,6 @@ stdenv.mkDerivation rec {
setOutputFlags = false ;
outputDoc = " d e v " ; # single tiny man3 page
# 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
# cross building to avoid hash breakage. Once hash breakage is acceptable, remove preConfigure entirely.
preConfigure = stdenv . lib . optionalString ( hostPlatform == buildPlatform ) ''
if test - n " $ c r o s s C o n f i g " ; then
export CC = $ crossConfig-gcc
fi
'' ;
# FIXME needs gcc 4.9 in bootstrap tools
hardeningDisable = [ " s t a c k p r o t e c t o r " ] ;
@ -49,36 +40,41 @@ stdenv.mkDerivation rec {
# jww (2015-01-06): Sometimes this library install as a .so, even on
# Darwin; others time it installs as a .dylib. I haven't yet figured out
# what causes this difference.
+ stdenv . lib . optionalString stdenv . isDarwin ''
+ stdenv . lib . optionalString hostPlatform . isDarwin ''
for file in $ out/lib /* . s o * $ o u t / l i b / * . d y l i b * ; d o
install_name_tool - id " $ f i l e " $ file
done
''
# Non-typical naming confuses libtool which then refuses to use zlib's DLL
# in some cases, e.g. when compiling libpng.
+ stdenv . lib . optionalString ( hostPlatform . libc == " m s v c r t " ) ''
ln - s zlib1 . dll $ out/bin/libz.dll
'' ;
# As zlib takes part in the stdenv building, we don't want references
# to the bootstrap-tools libgcc (as uses to happen on arm/mips)
NIX_CFLAGS_COMPILE = stdenv . lib . optionalString ( ! stdenv . isDarwin ) " - s t a t i c - l i b g c c " ;
NIX_CFLAGS_COMPILE = stdenv . lib . optionalString ( ! hostPlatform . isDarwin ) " - s t a t i c - l i b g c c " ;
crossAttrs = {
dontStrip = static ;
configurePlatforms = [ ] ;
} // stdenv . lib . optionalAttrs ( hostPlatform . libc == " m s v c r t " ) {
installFlags = [
" B I N A R Y _ P A T H = $ ( o u t ) / b i n "
" I N C L U D E _ P A T H = $ ( d e v ) / i n c l u d e "
" L I B R A R Y _ P A T H = $ ( o u t ) / l i b "
] ;
makeFlags = [
" - f " " w i n 3 2 / M a k e f i l e . g c c "
" P R E F I X = ${ stdenv . cc . prefix } "
] ++ stdenv . lib . optional ( ! static ) " S H A R E D _ M O D E = 1 " ;
dontStrip = hostPlatform != buildPlatform && static ;
configurePlatforms = [ ] ;
# Non-typical naming confuses libtool which then refuses to use zlib's DLL
# in some cases, e.g. when compiling libpng.
postInstall = postInstall + " l n - s z l i b 1 . d l l $ o u t / b i n / l i b z . d l l " ;
} ;
installFlags = stdenv . lib . optionals ( hostPlatform . libc == " m s v c r t " ) [
" B I N A R Y _ P A T H = $ ( o u t ) / b i n "
" I N C L U D E _ P A T H = $ ( d e v ) / i n c l u d e "
" L I B R A R Y _ P A T H = $ ( o u t ) / l i b "
] ;
passthru . version = version ;
makeFlags = [
" P R E F I X = ${ stdenv . cc . prefix } "
] ++ stdenv . lib . optionals ( hostPlatform . libc == " m s v c r t " ) [
" - f " " w i n 3 2 / M a k e f i l e . g c c "
] ++ stdenv . lib . optionals ( ! static ) [
" S H A R E D _ M O D E = 1 "
] ;
passthru = {
inherit version ;
} ;
meta = with stdenv . lib ; {
description = " L o s s l e s s d a t a - c o m p r e s s i o n l i b r a r y " ;