about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix
blob: acb737836c0d3afaf7f03b483e46e679a577b086 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{ lib, stdenv, fetchurl, cmake, gfortran
# Wether to build with ILP64 interface
, blas64 ? false
}:

stdenv.mkDerivation rec {
  pname = "blas";
  version = "3.10.0";

  src = fetchurl {
    url = "http://www.netlib.org/blas/${pname}-${version}.tgz";
    sha256 = "sha256-LjYNmcm9yEB6YYiMQKqFP7QhlCDruCZNtIbLiGBGirM=";
  };

  passthru = { inherit blas64; };

  nativeBuildInputs = [ cmake gfortran ];

  cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" ]
    ++ lib.optional blas64 "-DBUILD_INDEX64=ON";

  postInstall = let
    canonicalExtension = if stdenv.hostPlatform.isLinux
                       then "${stdenv.hostPlatform.extensions.sharedLibrary}.${lib.versions.major version}"
                       else stdenv.hostPlatform.extensions.sharedLibrary;
  in lib.optionalString blas64 ''
    ln -s $out/lib/libblas64${canonicalExtension} $out/lib/libblas${canonicalExtension}
  '';

  preFixup = lib.optionalString stdenv.isDarwin ''
    for fn in $(find $out/lib -name "*.so*"); do
      if [ -L "$fn" ]; then continue; fi
      install_name_tool -id "$fn" "$fn"
    done
  '';

  meta = with lib; {
    description = "Basic Linear Algebra Subprograms";
    license = licenses.publicDomain;
    maintainers = [ maintainers.markuskowa ];
    homepage = "http://www.netlib.org/blas/";
    platforms = platforms.unix;
  };
}