removed default dependency of liblapack on ATLAS. was causing an unnecessary double-build of atlas

This commit is contained in:
Allen Nelson
2015-05-28 12:39:49 -05:00
parent 6eb8ff878d
commit 2c125cf37a
3 changed files with 36 additions and 57 deletions
@@ -1,15 +1,38 @@
{ stdenv, fetchurl, gfortran, atlas, cmake, python, shared ? false }:
{
stdenv,
fetchurl,
gfortran,
cmake,
python,
atlas ? null,
shared ? false,
version ? "3.4.1"
}:
let
atlasMaybeShared = atlas.override { inherit shared; };
atlasMaybeShared = if atlas != null then atlas.override { inherit shared; }
else null;
usedLibExtension = if shared then ".so" else ".a";
version = "3.4.1";
inherit (stdenv.lib) optional;
inherit (stdenv.lib) optional optionals concatStringsSep;
inherit (builtins) hasAttr attrNames;
# Hashes of the versions of liblapack we know about.
versions2sha = {
"3.4.1" = "93b910f94f6091a2e71b59809c4db4a14655db527cfc5821ade2e8c8ab75380f";
"3.5.0" = "0lk3f97i9imqascnlf6wr5mjpyxqcdj73pgj97dj2mgvyg9z1n4s";
};
in
if !(builtins.hasAttr version versions2sha)
then throw ''
Unknown liblapack version ${version}.
Available versions: ${concatStringsSep ", " (attrNames versions2sha)}
''
else
stdenv.mkDerivation rec {
name = "liblapack-${version}";
src = fetchurl {
url = "http://www.netlib.org/lapack/lapack-${version}.tgz";
sha256 = "93b910f94f6091a2e71b59809c4db4a14655db527cfc5821ade2e8c8ab75380f";
sha256 = versions2sha."${version}";
};
propagatedBuildInputs = [ atlasMaybeShared ];
@@ -18,10 +41,12 @@ stdenv.mkDerivation rec {
cmakeFlags = [
"-DUSE_OPTIMIZED_BLAS=ON"
"-DBLAS_ATLAS_f77blas_LIBRARY=${atlasMaybeShared}/lib/libf77blas${usedLibExtension}"
"-DBLAS_ATLAS_atlas_LIBRARY=${atlasMaybeShared}/lib/libatlas${usedLibExtension}"
"-DCMAKE_Fortran_FLAGS=-fPIC"
]
++ (optionals (atlas != null) [
"-DBLAS_ATLAS_f77blas_LIBRARY=${atlasMaybeShared}/lib/libf77blas${usedLibExtension}"
"-DBLAS_ATLAS_atlas_LIBRARY=${atlasMaybeShared}/lib/libatlas${usedLibExtension}"
])
++ (optional shared "-DBUILD_SHARED_LIBS=ON")
# If we're on darwin, CMake will automatically detect impure paths. This switch
# prevents that.