nixpkgs/pkgs/development/libraries/sundials/default.nix

84 lines
2.3 KiB
Nix
Raw Normal View History

{ lib, stdenv
2019-07-02 13:55:34 +01:00
, cmake
, fetchurl
, fetchpatch
2019-08-01 13:28:19 +01:00
, python
, blas
, lapack
2019-08-01 13:28:19 +01:00
, gfortran
2020-08-08 10:36:03 +01:00
, suitesparse
, lapackSupport ? true
, kluSupport ? true
}:
2019-08-01 13:28:19 +01:00
stdenv.mkDerivation rec {
2018-03-01 09:14:18 +00:00
pname = "sundials";
version = "5.6.1";
2018-03-01 09:14:18 +00:00
outputs = [ "out" "examples" ];
src = fetchurl {
url = "https://computation.llnl.gov/projects/${pname}/download/${pname}-${version}.tar.gz";
sha256 = "Frd5mex+fyFXqh0Eyh3kojccqBUOBW0klR0MWJZvKoM=";
};
patches = [
# Fixing an upstream regression in treating cmake prefix directories:
# https://github.com/LLNL/sundials/pull/58
(fetchpatch {
url = "https://github.com/LLNL/sundials/commit/dd32ff9baa05618f36e44aadb420bbae4236ea1e.patch";
sha256 = "kToAuma+2iHFyL1v/l29F3+nug4AdK5cPG6IcXv2afc=";
})
];
nativeBuildInputs = [ cmake ];
2020-08-08 10:36:03 +01:00
buildInputs = [
python
2020-09-23 10:56:28 +01:00
]
++ lib.optionals (lapackSupport)
# Check that the same index size is used for both libraries
(assert (blas.isILP64 == lapack.isILP64); [
gfortran
blas
lapack
])
2020-08-08 10:36:03 +01:00
# KLU support is based on Suitesparse.
# It is tested upstream according to the section 1.1.4 of
# [INSTALL_GUIDE.pdf](https://raw.githubusercontent.com/LLNL/sundials/master/INSTALL_GUIDE.pdf)
++ lib.optionals (kluSupport) [
2020-08-08 10:36:03 +01:00
suitesparse
];
2019-08-01 13:02:00 +01:00
2019-07-02 13:55:34 +01:00
cmakeFlags = [
2020-12-20 19:30:15 +00:00
"-DEXAMPLES_INSTALL_PATH=${placeholder "examples"}/share/examples"
] ++ lib.optionals (lapackSupport) [
"-DENABLE_LAPACK=ON"
"-DLAPACK_LIBRARIES=${lapack}/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary}"
] ++ lib.optionals (kluSupport) [
"-DENABLE_KLU=ON"
2020-08-08 10:36:03 +01:00
"-DKLU_INCLUDE_DIR=${suitesparse.dev}/include"
"-DKLU_LIBRARY_DIR=${suitesparse}/lib"
] ++ [(
# Use the correct index type according to lapack and blas used. They are
# already supposed to be compatible but we check both for extra safety. 64
# should be the default but we prefer to be explicit, for extra safety.
if blas.isILP64 then
"-DSUNDIALS_INDEX_SIZE=64"
else
"-DSUNDIALS_INDEX_SIZE=32"
)]
;
2018-03-01 09:14:18 +00:00
2019-08-01 13:02:00 +01:00
doCheck = true;
checkTarget = "test";
2019-08-01 13:02:00 +01:00
meta = with lib; {
2018-03-01 09:14:18 +00:00
description = "Suite of nonlinear differential/algebraic equation solvers";
homepage = "https://computation.llnl.gov/projects/sundials";
2018-03-01 09:14:18 +00:00
platforms = platforms.all;
2020-09-23 10:56:28 +01:00
maintainers = with maintainers; [ idontgetoutmuch ];
2018-03-11 15:21:37 +00:00
license = licenses.bsd3;
2018-03-01 09:14:18 +00:00
};
}