about summary refs log tree commit diff
path: root/pkgs/by-name/mu/mumps/package.nix
blob: 7d0e3e154cb4fd225ea55196f53c1a4a672915ee (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{
  blas,
  fetchzip,
  fetchpatch,
  gfortran,
  lapack,
  lib,
  metis,
  scotch,
  stdenv,
}:
stdenv.mkDerivation (finalAttrs: {
  name = "mumps";
  version = "5.7.3";

  src = fetchzip {
    url = "https://mumps-solver.org/MUMPS_${finalAttrs.version}.tar.gz";
    hash = "sha256-ZnIfAuvOBJDYqCtKGlWs0r39nG6X2lAVRuUmeIJenZw=";
  };

  patches = [
    # Compatibility with coin-or-mumps version
    (fetchpatch {
      url = "https://raw.githubusercontent.com/coin-or-tools/ThirdParty-Mumps/bd0bdf9baa3f3677bd34fb36ce63b2b32cc6cc7d/mumps_mpi.patch";
      hash = "sha256-70qZUKBVBpJOSRxYxng5Y6ct1fdCUQUGur3chDhGabQ=";
    })
  ];

  postPatch =
    ''
      # Compatibility with coin-or-mumps version
      # https://github.com/coin-or-tools/ThirdParty-Mumps/blob/stable/3.0/get.Mumps#L66
      cp libseq/mpi.h libseq/mumps_mpi.h
    ''
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      substituteInPlace src/Makefile --replace-fail \
        "-Wl,\''$(SONAME),libmumps_common" \
        "-Wl,-install_name,$out/lib/libmumps_common"
    '';

  configurePhase = ''
    cp Make.inc/Makefile.debian.SEQ ./Makefile.inc
  '';

  makeFlags =
    lib.optionals stdenv.hostPlatform.isDarwin [
      "SONAME="
      "LIBEXT_SHARED=.dylib"
    ]
    ++ [
      "LSCOTCHDIR=${scotch}/lib"
      "ISCOTCH=-I${scotch.dev}/include"
      "LMETISDIR=${metis}/lib"
      "IMETIS=-I${metis}/include"
      "allshared"
    ];

  installPhase = ''
    mkdir $out
    cp -r include lib $out

    # Add some compatibility with coin-or-mumps
    ln -s $out/include $out/include/mumps
    cp libseq/mumps_mpi.h $out/include
  '';

  nativeBuildInputs = [ gfortran ];

  buildInputs = [
    blas
    lapack
    metis
    scotch
  ];

  preFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
    install_name_tool \
      -change    libmpiseq.dylib \
        $out/lib/libmpiseq.dylib \
      -change    libpord.dylib \
        $out/lib/libpord.dylib \
        $out/lib/libmumps_common.dylib
    install_name_tool \
      -change    libmpiseq.dylib \
        $out/lib/libmpiseq.dylib \
      -change    libpord.dylib \
        $out/lib/libpord.dylib \
      -id \
        $out/lib/libcmumps.dylib \
        $out/lib/libcmumps.dylib
    install_name_tool \
      -change    libmpiseq.dylib \
        $out/lib/libmpiseq.dylib \
      -change    libpord.dylib \
        $out/lib/libpord.dylib \
      -id \
        $out/lib/libdmumps.dylib \
        $out/lib/libdmumps.dylib
    install_name_tool \
      -change    libmpiseq.dylib \
        $out/lib/libmpiseq.dylib \
      -change    libpord.dylib \
        $out/lib/libpord.dylib \
      -id \
        $out/lib/libsmumps.dylib \
        $out/lib/libsmumps.dylib
    install_name_tool \
      -change    libmpiseq.dylib \
        $out/lib/libmpiseq.dylib \
      -change    libpord.dylib \
        $out/lib/libpord.dylib \
      -id \
        $out/lib/libzmumps.dylib \
        $out/lib/libzmumps.dylib
    install_name_tool \
      -id \
        $out/lib/libmpiseq.dylib \
        $out/lib/libmpiseq.dylib
    install_name_tool \
      -id \
        $out/lib/libpord.dylib \
        $out/lib/libpord.dylib
  '';

  meta = {
    description = "MUltifrontal Massively Parallel sparse direct Solver";
    homepage = "http://mumps-solver.org/";
    license = lib.licenses.cecill-c;
    maintainers = with lib.maintainers; [ nim65s ];
  };
})