lol
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 22.05-pre 137 lines 5.2 kB view raw
1{ lib, stdenv 2, fetchurl 3, shared ? !stdenv.hostPlatform.isStatic 4, static ? true 5# If true, a separate .static ouput is created and the .a is moved there. 6# In this case `pkg-config` auto detection does not currently work if the 7# .static output is given as `buildInputs` to another package (#66461), because 8# the `.pc` file lists only the main output's lib dir. 9# If false, and if `{ static = true; }`, the .a stays in the main output. 10, splitStaticOutput ? shared && static 11}: 12 13# Without either the build will actually still succeed because the build 14# system makes an arbitrary choice, but we shouldn't be so indecisive. 15assert shared || static; 16 17# Note: this package is used for bootstrapping fetchurl, and thus 18# cannot use fetchpatch! All mutable patches (generated by GitHub or 19# cgit) that are needed here should be included directly in Nixpkgs as 20# files. 21 22assert splitStaticOutput -> static; 23 24stdenv.mkDerivation (rec { 25 name = "zlib-${version}"; 26 version = "1.2.11"; 27 28 src = fetchurl { 29 urls = 30 [ "https://www.zlib.net/fossils/${name}.tar.gz" # stable archive path 31 "mirror://sourceforge/libpng/zlib/${version}/${name}.tar.gz" 32 ]; 33 sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"; 34 }; 35 36 patches = lib.optional stdenv.hostPlatform.isCygwin ./disable-cygwin-widechar.patch; 37 38 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' 39 substituteInPlace configure \ 40 --replace '/usr/bin/libtool' '${stdenv.cc.targetPrefix}ar' \ 41 --replace 'AR="libtool"' 'AR="${stdenv.cc.targetPrefix}ar"' \ 42 --replace 'ARFLAGS="-o"' 'ARFLAGS="-r"' 43 ''; 44 45 outputs = [ "out" "dev" ] 46 ++ lib.optional splitStaticOutput "static"; 47 setOutputFlags = false; 48 outputDoc = "dev"; # single tiny man3 page 49 50 # For zlib's ./configure (as of verion 1.2.11), the order 51 # of --static/--shared flags matters! 52 # `--shared --static` builds only static libs, while 53 # `--static --shared` builds both. 54 # So we use the latter order to be able to build both. 55 # Also, giving just `--shared` builds both, 56 # giving just `--static` builds only static, 57 # and giving nothing builds both. 58 # So we have 3 possible ways to build both: 59 # `--static --shared`, `--shared` and giving nothing. 60 # Of these, we choose `--static --shared`, for clarity and simpler 61 # conditions. 62 configureFlags = lib.optional static "--static" 63 ++ lib.optional shared "--shared"; 64 # We do the right thing manually, above, so don't need these. 65 dontDisableStatic = true; 66 dontAddStaticConfigureFlags = true; 67 68 # Note we don't need to set `dontDisableStatic`, because static-disabling 69 # works by grepping for `enable-static` in the `./configure` script 70 # (see `pkgs/stdenv/generic/setup.sh`), and zlib's handwritten one does 71 # not have such. 72 # It wouldn't hurt setting `dontDisableStatic = static && !splitStaticOutput` 73 # here (in case zlib ever switches to autoconf in the future), 74 # but we don't do it simply to avoid mass rebuilds. 75 76 postInstall = lib.optionalString splitStaticOutput '' 77 moveToOutput lib/libz.a "$static" 78 '' 79 # jww (2015-01-06): Sometimes this library install as a .so, even on 80 # Darwin; others time it installs as a .dylib. I haven't yet figured out 81 # what causes this difference. 82 + lib.optionalString stdenv.hostPlatform.isDarwin '' 83 for file in $out/lib/*.so* $out/lib/*.dylib* ; do 84 ${stdenv.cc.bintools.targetPrefix}install_name_tool -id "$file" $file 85 done 86 '' 87 # Non-typical naming confuses libtool which then refuses to use zlib's DLL 88 # in some cases, e.g. when compiling libpng. 89 + lib.optionalString (stdenv.hostPlatform.libc == "msvcrt" && shared) '' 90 ln -s zlib1.dll $out/bin/libz.dll 91 ''; 92 93 # As zlib takes part in the stdenv building, we don't want references 94 # to the bootstrap-tools libgcc (as uses to happen on arm/mips) 95 NIX_CFLAGS_COMPILE = lib.optionalString (!stdenv.hostPlatform.isDarwin) "-static-libgcc"; 96 97 # We don't strip on static cross-compilation because of reports that native 98 # stripping corrupted the target library; see commit 12e960f5 for the report. 99 dontStrip = stdenv.hostPlatform != stdenv.buildPlatform && static; 100 configurePlatforms = []; 101 102 installFlags = lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [ 103 "BINARY_PATH=$(out)/bin" 104 "INCLUDE_PATH=$(dev)/include" 105 "LIBRARY_PATH=$(out)/lib" 106 ]; 107 108 enableParallelBuilding = true; 109 doCheck = true; 110 111 makeFlags = [ 112 "PREFIX=${stdenv.cc.targetPrefix}" 113 ] ++ lib.optionals (stdenv.hostPlatform.libc == "msvcrt") [ 114 "-f" "win32/Makefile.gcc" 115 ] ++ lib.optionals shared [ 116 # Note that as of writing (zlib 1.2.11), this flag only has an effect 117 # for Windows as it is specific to `win32/Makefile.gcc`. 118 "SHARED_MODE=1" 119 ]; 120 121 passthru = { 122 inherit version; 123 }; 124 125 meta = with lib; { 126 homepage = "https://zlib.net"; 127 description = "Lossless data-compression library"; 128 license = licenses.zlib; 129 platforms = platforms.all; 130 }; 131} // lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) { 132 preConfigure = '' 133 export CHOST=${stdenv.hostPlatform.config} 134 ''; 135} // lib.optionalAttrs (stdenv.hostPlatform.libc == "msvcrt") { 136 dontConfigure = true; 137})