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 21 assert withPtScotch -> mpiSupport; 22 22 let 23 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 = 24 + LMETIS = toString ([ "-lmetis" ] ++ lib.optional withParmetis "-lparmetis"); 25 + LSCOTCH = toString ( 36 26 if withPtScotch then 37 - '' 38 - ISCOTCH=-I${scotch.dev}/include \ 39 - LSCOTCH="-L${scotch}/lib -lptscotch -lptesmumps -lptscotcherr" 40 - '' 27 + [ 28 + "-lptscotch" 29 + "-lptesmumps" 30 + "-lptscotcherr" 31 + ] 41 32 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 - ''; 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 + ); 57 48 in 58 49 stdenv.mkDerivation (finalAttrs: { 59 50 name = "mumps"; 60 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; 61 55 62 56 src = fetchzip { 63 57 url = "https://mumps-solver.org/MUMPS_${finalAttrs.version}.tar.gz"; ··· 76 70 77 71 enableParallelBuilding = true; 78 72 79 - preBuild = '' 80 - makeFlagsArray+=(${metisFlags} ${scotchFlags} ORDERINGSF="${macroFlags}" ${optFlags}) 81 - ''; 82 - 83 73 makeFlags = 84 74 lib.optionals stdenv.hostPlatform.isDarwin [ 85 75 "SONAME=" 86 76 "LIBEXT_SHARED=.dylib" 87 77 ] 88 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" 89 86 "SCALAP=-lscalapack" 90 87 "allshared" 91 88 ]; ··· 105 102 106 103 nativeBuildInputs = [ 107 104 gfortran 108 - ] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames ++ lib.optional mpiSupport mpi; 105 + ] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 109 106 110 107 # Parmetis should be placed before scotch to avoid conflict of header file "parmetis.h" 111 108 buildInputs = ··· 125 122 ${lib.optionalString stdenv.hostPlatform.isDarwin "export DYLD_LIBRARY_PATH=$out/lib\n"} 126 123 ${lib.optionalString mpiSupport "export MPIRUN='mpirun -n 2'\n"} 127 124 cd examples 128 - make all 129 125 $MPIRUN ./ssimpletest <input_simpletest_real 130 126 $MPIRUN ./dsimpletest <input_simpletest_real 131 127 $MPIRUN ./csimpletest <input_simpletest_cmplx