about summary refs log tree commit diff
path: root/pkgs/tools/compression/bzip2
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2016-04-21 15:37:52 +0200
committerVladimír Čunát <vcunat@gmail.com>2016-04-23 10:52:01 +0200
commit91f2b9ed663bc58c2305edf2d52b4e54228394c4 (patch)
treea0ad1dcee38e874389ba8db484d5a70e9f4f0c23 /pkgs/tools/compression/bzip2
parent8b292a1b355e8e7f6e7a2cf439ab777bdae30422 (diff)
downloadnixlib-91f2b9ed663bc58c2305edf2d52b4e54228394c4.tar
nixlib-91f2b9ed663bc58c2305edf2d52b4e54228394c4.tar.gz
nixlib-91f2b9ed663bc58c2305edf2d52b4e54228394c4.tar.bz2
nixlib-91f2b9ed663bc58c2305edf2d52b4e54228394c4.tar.lz
nixlib-91f2b9ed663bc58c2305edf2d52b4e54228394c4.tar.xz
nixlib-91f2b9ed663bc58c2305edf2d52b4e54228394c4.tar.zst
nixlib-91f2b9ed663bc58c2305edf2d52b4e54228394c4.zip
bzip2: fix on mingw
The whole expression is rather a mess, mainly due to upstream
often behaving badly with non-standard configurations.
Diffstat (limited to 'pkgs/tools/compression/bzip2')
-rw-r--r--pkgs/tools/compression/bzip2/default.nix51
1 files changed, 29 insertions, 22 deletions
diff --git a/pkgs/tools/compression/bzip2/default.nix b/pkgs/tools/compression/bzip2/default.nix
index a165ab2b157b..d3ed5121ba98 100644
--- a/pkgs/tools/compression/bzip2/default.nix
+++ b/pkgs/tools/compression/bzip2/default.nix
@@ -35,10 +35,6 @@ in stdenv.mkDerivation {
       sed -i -e '/<sys\\stat\.h>/s|\\|/|' bzip2.c
     '';
     preConfigure = "sh ./autogen.sh";
-    # clear native hooks that are not needed with autoconf
-    preBuild = "";
-    preInstall = "";
-    postInstall = "";
   };
 
   outputs = [ "dev" "bin" "static" ] ++ stdenv.lib.optional sharedLibrary "out";
@@ -47,21 +43,23 @@ in stdenv.mkDerivation {
     make -f ${if stdenv.isDarwin then "Makefile-libbz2_dylib" else "Makefile-libbz2_so"}
   '';
 
-  preInstall = stdenv.lib.optionalString sharedLibrary (if !stdenv.isDarwin then ''
-    mkdir -p $out/lib
-    mv libbz2.so* $out/lib
-    ( cd $out/lib &&
-      ln -s libbz2.so.1.0.? libbz2.so &&
-      ln -s libbz2.so.1.0.? libbz2.so.1
-    )
-  '' else ''
-    mkdir -p $out/lib
-    mv libbz2.*.dylib $out/lib
-    ( cd $out/lib &&
-      ln -s libbz2.1.0.?.dylib libbz2.dylib &&
-      ln -s libbz2.1.0.?.dylib libbz2.1.dylib
-    )
-  '');
+  preInstall = stdenv.lib.optionalString
+    (sharedLibrary && stdenv.cross.libc or null != "msvcrt")
+    (if !stdenv.isDarwin then ''
+      mkdir -p $out/lib
+      mv libbz2.so* $out/lib
+      ( cd $out/lib &&
+        ln -s libbz2.so.1.0.? libbz2.so &&
+        ln -s libbz2.so.1.0.? libbz2.so.1
+      )
+    '' else ''
+      mkdir -p $out/lib
+      mv libbz2.*.dylib $out/lib
+      ( cd $out/lib &&
+        ln -s libbz2.1.0.?.dylib libbz2.dylib &&
+        ln -s libbz2.1.0.?.dylib libbz2.1.dylib
+      )
+    '');
 
   installFlags = [ "PREFIX=$(bin)" ];
 
@@ -70,9 +68,18 @@ in stdenv.mkDerivation {
     ln -s bzip2 $bin/bin/bunzip2
     ln -s bzip2 $bin/bin/bzcat
 
-    mkdir "$static"
-    mv "$bin/lib" "$static/"
-  '';
+  ''
+    + (if stdenv.cross.libc or null != "msvcrt" # mingw TODO: avoided rebuilds for now
+      then ''
+        mkdir "$static"
+        mv "$bin/lib" "$static/"
+      ''
+      else ''
+        moveToOutput "lib/*.a" "$static"
+        moveToOutput "lib/*.dll.a" "$out"
+        mkdir -p "$static" # empty for now, but we want to avoid failure
+      '')
+    ;
 
   postPatch = ''
     substituteInPlace Makefile --replace CC=gcc CC=cc