bzip2: fix on mingw

The whole expression is rather a mess, mainly due to upstream
often behaving badly with non-standard configurations.
This commit is contained in:
Vladimír Čunát 2016-04-21 15:37:52 +02:00
parent 8b292a1b35
commit 91f2b9ed66
1 changed files with 29 additions and 22 deletions

View File

@ -35,10 +35,6 @@ in stdenv.mkDerivation {
sed -i -e '/<sys\\stat\.h>/s|\\|/|' bzip2.c sed -i -e '/<sys\\stat\.h>/s|\\|/|' bzip2.c
''; '';
preConfigure = "sh ./autogen.sh"; 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"; 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"} make -f ${if stdenv.isDarwin then "Makefile-libbz2_dylib" else "Makefile-libbz2_so"}
''; '';
preInstall = stdenv.lib.optionalString sharedLibrary (if !stdenv.isDarwin then '' preInstall = stdenv.lib.optionalString
mkdir -p $out/lib (sharedLibrary && stdenv.cross.libc or null != "msvcrt")
mv libbz2.so* $out/lib (if !stdenv.isDarwin then ''
( cd $out/lib && mkdir -p $out/lib
ln -s libbz2.so.1.0.? libbz2.so && mv libbz2.so* $out/lib
ln -s libbz2.so.1.0.? libbz2.so.1 ( cd $out/lib &&
) ln -s libbz2.so.1.0.? libbz2.so &&
'' else '' ln -s libbz2.so.1.0.? libbz2.so.1
mkdir -p $out/lib )
mv libbz2.*.dylib $out/lib '' else ''
( cd $out/lib && mkdir -p $out/lib
ln -s libbz2.1.0.?.dylib libbz2.dylib && mv libbz2.*.dylib $out/lib
ln -s libbz2.1.0.?.dylib libbz2.1.dylib ( cd $out/lib &&
) ln -s libbz2.1.0.?.dylib libbz2.dylib &&
''); ln -s libbz2.1.0.?.dylib libbz2.1.dylib
)
'');
installFlags = [ "PREFIX=$(bin)" ]; installFlags = [ "PREFIX=$(bin)" ];
@ -70,9 +68,18 @@ in stdenv.mkDerivation {
ln -s bzip2 $bin/bin/bunzip2 ln -s bzip2 $bin/bin/bunzip2
ln -s bzip2 $bin/bin/bzcat 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 = '' postPatch = ''
substituteInPlace Makefile --replace CC=gcc CC=cc substituteInPlace Makefile --replace CC=gcc CC=cc