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

74 lines
2.0 KiB
Nix
Raw Normal View History

{ lib, stdenv
2019-07-02 13:55:34 +01:00
, cmake
, fetchurl
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";
2021-02-07 10:56:49 +00:00
version = "5.7.0";
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";
2021-02-07 10:56:49 +00:00
sha256 = "jW3QlP7Mu41uzEE0DsFqZfq6yC7UQVAj9tfBwjkOovM=";
};
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
};
}