qrupdate: refactor & assert compatible blas && lapack

Use `pname` and `version`. Use my preferred indentation style. Use
makeFlagsArray in preBuild instead of overriding configurePhase, per:
https://github.com/jtojnar/nixpkgs-hammering/blob/master/explanations/explicit-phases.md

Assert that lapack and blas are compatible regarding 64 bit indexing, do
it near evaluation of preBuild, per jtojnar's explanation:
https://github.com/NixOS/nixpkgs/pull/94892#discussion_r471110250

Use gpl3Plus, as gpl3 is unclear and deprecated.
This commit is contained in:
Doron Behar 2020-09-23 00:20:47 +03:00
parent 9c3f7ad85b
commit 8109377468
1 changed files with 25 additions and 16 deletions

View File

@ -5,24 +5,33 @@
, lapack , lapack
, which , which
}: }:
stdenv.mkDerivation {
name = "qrupdate-1.1.2"; stdenv.mkDerivation rec {
pname = "qrupdate";
version = "1.1.2";
src = fetchurl { src = fetchurl {
url = "mirror://sourceforge/qrupdate/qrupdate-1.1.2.tar.gz"; url = "mirror://sourceforge/qrupdate/${pname}-${version}.tar.gz";
sha256 = "024f601685phcm1pg8lhif3lpy5j9j0k6n0r46743g4fvh8wg8g2"; sha256 = "024f601685phcm1pg8lhif3lpy5j9j0k6n0r46743g4fvh8wg8g2";
}; };
configurePhase = preBuild =
'' # Check that blas and lapack are compatible
export PREFIX=$out assert (blas.isILP64 == lapack.isILP64);
sed -i -e 's,^BLAS=.*,BLAS=-L${blas}/lib -lblas,' \ # We don't have structuredAttrs yet implemented, and we need to use space
-e 's,^LAPACK=.*,LAPACK=-L${lapack}/lib -llapack,' \ # seprated values in makeFlags, so only this works.
Makeconf ''
'' makeFlagsArray+=(
+ stdenv.lib.optionalString blas.isILP64 "LAPACK=-L${lapack}/lib -llapack"
'' "BLAS=-L${blas}/lib -lblas"
sed -i Makeconf -e '/^FFLAGS=.*/ s/$/-fdefault-integer-8/' "PREFIX=${placeholder "out"}"
''; ${stdenv.lib.optionalString blas.isILP64
# Use their FFLAGS along with `-fdefault-integer-8`. If another
# application intends to use arpack, it should add this to it's FFLAGS as
# well. Otherwise (e.g): https://savannah.gnu.org/bugs/?50339
"FFLAGS=-fimplicit-none -O3 -funroll-loops -fdefault-integer-8"
}
)
'';
doCheck = true; doCheck = true;
@ -32,14 +41,14 @@ stdenv.mkDerivation {
installTargets = stdenv.lib.optionals stdenv.isDarwin [ "install-staticlib" "install-shlib" ]; installTargets = stdenv.lib.optionals stdenv.isDarwin [ "install-staticlib" "install-shlib" ];
buildInputs = [ gfortran blas lapack ]; buildInputs = [ gfortran ];
nativeBuildInputs = [ which ]; nativeBuildInputs = [ which ];
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "Library for fast updating of qr and cholesky decompositions"; description = "Library for fast updating of qr and cholesky decompositions";
homepage = "https://sourceforge.net/projects/qrupdate/"; homepage = "https://sourceforge.net/projects/qrupdate/";
license = licenses.gpl3; license = licenses.gpl3Plus;
maintainers = with maintainers; [ doronbehar ]; maintainers = with maintainers; [ doronbehar ];
platforms = platforms.unix; platforms = platforms.unix;
}; };