Mumps: use magic __structuredAttrs to handle space in makeFlags (#355128)

authored by

lassulus and committed by
GitHub
efc9da91 1a3635f4

+33 -37
+33 -37
pkgs/by-name/mu/mumps/package.nix
··· 21 assert withPtScotch -> mpiSupport; 22 let 23 profile = if mpiSupport then "debian.PAR" else "debian.SEQ"; 24 - metisFlags = 25 - if withParmetis then 26 - '' 27 - IMETIS="-I${parmetis}/include -I${metis}/include" \ 28 - LMETIS="-L${parmetis}/lib -lparmetis -L${metis}/lib -lmetis" 29 - '' 30 - else 31 - '' 32 - IMETIS=-I${metis}/include \ 33 - LMETIS="-L${metis}/lib -lmetis" 34 - ''; 35 - scotchFlags = 36 if withPtScotch then 37 - '' 38 - ISCOTCH=-I${scotch.dev}/include \ 39 - LSCOTCH="-L${scotch}/lib -lptscotch -lptesmumps -lptscotcherr" 40 - '' 41 else 42 - '' 43 - ISCOTCH=-I${scotch.dev}/include \ 44 - LSCOTCH="-L${scotch}/lib -lesmumps -lscotch -lscotcherr" 45 - ''; 46 - macroFlags = 47 - "-Dmetis -Dpord -Dscotch" 48 - + lib.optionalString withParmetis " -Dparmetis" 49 - + lib.optionalString withPtScotch " -Dptscotch"; 50 - # Optimized options 51 - # Disable -fopenmp in lines below to benefit from OpenMP 52 - optFlags = '' 53 - OPTF="-O3 -fallow-argument-mismatch" \ 54 - OPTL="-O3" \ 55 - OPTC="-O3" 56 - ''; 57 in 58 stdenv.mkDerivation (finalAttrs: { 59 name = "mumps"; 60 version = "5.7.3"; 61 62 src = fetchzip { 63 url = "https://mumps-solver.org/MUMPS_${finalAttrs.version}.tar.gz"; ··· 76 77 enableParallelBuilding = true; 78 79 - preBuild = '' 80 - makeFlagsArray+=(${metisFlags} ${scotchFlags} ORDERINGSF="${macroFlags}" ${optFlags}) 81 - ''; 82 - 83 makeFlags = 84 lib.optionals stdenv.hostPlatform.isDarwin [ 85 "SONAME=" 86 "LIBEXT_SHARED=.dylib" 87 ] 88 ++ [ 89 "SCALAP=-lscalapack" 90 "allshared" 91 ]; ··· 105 106 nativeBuildInputs = [ 107 gfortran 108 - ] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames ++ lib.optional mpiSupport mpi; 109 110 # Parmetis should be placed before scotch to avoid conflict of header file "parmetis.h" 111 buildInputs = ··· 125 ${lib.optionalString stdenv.hostPlatform.isDarwin "export DYLD_LIBRARY_PATH=$out/lib\n"} 126 ${lib.optionalString mpiSupport "export MPIRUN='mpirun -n 2'\n"} 127 cd examples 128 - make all 129 $MPIRUN ./ssimpletest <input_simpletest_real 130 $MPIRUN ./dsimpletest <input_simpletest_real 131 $MPIRUN ./csimpletest <input_simpletest_cmplx
··· 21 assert withPtScotch -> mpiSupport; 22 let 23 profile = if mpiSupport then "debian.PAR" else "debian.SEQ"; 24 + LMETIS = toString ([ "-lmetis" ] ++ lib.optional withParmetis "-lparmetis"); 25 + LSCOTCH = toString ( 26 if withPtScotch then 27 + [ 28 + "-lptscotch" 29 + "-lptesmumps" 30 + "-lptscotcherr" 31 + ] 32 else 33 + [ 34 + "-lesmumps" 35 + "-lscotch" 36 + "-lscotcherr" 37 + ] 38 + ); 39 + ORDERINGSF = toString ( 40 + [ 41 + "-Dmetis" 42 + "-Dpord" 43 + "-Dscotch" 44 + ] 45 + ++ lib.optional withParmetis "-Dparmetis" 46 + ++ lib.optional withPtScotch "-Dptscotch" 47 + ); 48 in 49 stdenv.mkDerivation (finalAttrs: { 50 name = "mumps"; 51 version = "5.7.3"; 52 + # makeFlags contain space and one should use makeFlagsArray+ 53 + # Setting this magic var is an optional solution 54 + __structuredAttrs = true; 55 56 src = fetchzip { 57 url = "https://mumps-solver.org/MUMPS_${finalAttrs.version}.tar.gz"; ··· 70 71 enableParallelBuilding = true; 72 73 makeFlags = 74 lib.optionals stdenv.hostPlatform.isDarwin [ 75 "SONAME=" 76 "LIBEXT_SHARED=.dylib" 77 ] 78 ++ [ 79 + "ISCOTCH=-I${scotch.dev}/include" 80 + "LMETIS=${LMETIS}" 81 + "LSCOTCH=${LSCOTCH}" 82 + "ORDERINGSF=${ORDERINGSF}" 83 + "OPTF=-O3 -fallow-argument-mismatch" 84 + "OPTC=-O3" 85 + "OPTL=-O3" 86 "SCALAP=-lscalapack" 87 "allshared" 88 ]; ··· 102 103 nativeBuildInputs = [ 104 gfortran 105 + ] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 106 107 # Parmetis should be placed before scotch to avoid conflict of header file "parmetis.h" 108 buildInputs = ··· 122 ${lib.optionalString stdenv.hostPlatform.isDarwin "export DYLD_LIBRARY_PATH=$out/lib\n"} 123 ${lib.optionalString mpiSupport "export MPIRUN='mpirun -n 2'\n"} 124 cd examples 125 $MPIRUN ./ssimpletest <input_simpletest_real 126 $MPIRUN ./dsimpletest <input_simpletest_real 127 $MPIRUN ./csimpletest <input_simpletest_cmplx