Skip to content

Commit

Permalink
mumps: refactor makeFlags with toString
Browse files Browse the repository at this point in the history
  • Loading branch information
qbisi committed Nov 12, 2024
1 parent 928969d commit 727aa59
Showing 1 changed file with 51 additions and 49 deletions.
100 changes: 51 additions & 49 deletions pkgs/by-name/mu/mumps/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,6 @@
}:
assert withParmetis -> mpiSupport;
assert withPtScotch -> mpiSupport;
let
profile = if mpiSupport then "debian.PAR" else "debian.SEQ";
metisFlags =
if withParmetis then
''
IMETIS="-I${parmetis}/include -I${metis}/include" \
LMETIS="-L${parmetis}/lib -lparmetis -L${metis}/lib -lmetis"
''
else
''
IMETIS=-I${metis}/include \
LMETIS="-L${metis}/lib -lmetis"
'';
scotchFlags =
if withPtScotch then
''
ISCOTCH=-I${scotch.dev}/include \
LSCOTCH="-L${scotch}/lib -lptscotch -lptesmumps -lptscotcherr"
''
else
''
ISCOTCH=-I${scotch.dev}/include \
LSCOTCH="-L${scotch}/lib -lesmumps -lscotch -lscotcherr"
'';
macroFlags =
"-Dmetis -Dpord -Dscotch"
+ lib.optionalString withParmetis " -Dparmetis"
+ lib.optionalString withPtScotch " -Dptscotch";
# Optimized options
# Disable -fopenmp in lines below to benefit from OpenMP
optFlags = ''
OPTF="-O3 -fallow-argument-mismatch" \
OPTL="-O3" \
OPTC="-O3"
'';
in
stdenv.mkDerivation (finalAttrs: {
name = "mumps";
version = "5.7.3";
Expand All @@ -70,25 +34,63 @@ stdenv.mkDerivation (finalAttrs: {
"-Wl,-install_name,$out/lib/libmumps_common"
'';

configurePhase = ''
cp Make.inc/Makefile.${profile} ./Makefile.inc
'';
configurePhase =
let
profile = if mpiSupport then "debian.PAR" else "debian.SEQ";
in
''
cp Make.inc/Makefile.${profile} ./Makefile.inc
'';

enableParallelBuilding = true;

LMETIS = toString ([ "-lmetis" ] ++ lib.optional withParmetis "-lparmetis");
LSCOTCH = toString (
if withPtScotch then
[
"-lptscotch"
"-lptesmumps"
"-lptscotcherr"
]
else
[
"-lesmumps"
"-lscotch"
"-lscotcherr"
]
);
ORDERINGSF = toString (
[
"-Dmetis"
"-Dpord"
"-Dscotch"
]
++ lib.optional withParmetis "-Dparmetis"
++ lib.optional withPtScotch "-Dptscotch"
);
OPTF = toString [
"-O3"
"-fallow-argument-mismatch"
];

preBuild = ''
makeFlagsArray+=(${metisFlags} ${scotchFlags} ORDERINGSF="${macroFlags}" ${optFlags})
makeFlagsArray+=(
ISCOTCH=-I${scotch.dev}/include
LSCOTCH="$LSCOTCH"
LMETIS="$LMETIS"
ORDERINGSF="$ORDERINGSF"
OPTF="$OPTF"
OPTC=-O3
OPTL=-O3
SCALAP=-lscalapack
allshared
)
'';

makeFlags =
lib.optionals stdenv.hostPlatform.isDarwin [
"SONAME="
"LIBEXT_SHARED=.dylib"
]
++ [
"SCALAP=-lscalapack"
"allshared"
];
makeFlags = lib.optionals stdenv.hostPlatform.isDarwin [
"SONAME="
"LIBEXT_SHARED=.dylib"
];

installPhase =
''
Expand Down

0 comments on commit 727aa59

Please sign in to comment.