10 , enableStatic ? stdenv.hostPlatform.isStatic
11 , enableOpenmp ? false
15 py = python3.withPackages (ps: with ps; [ numpy ]);
16 option = cond: if cond then "1" else "0";
18 stdenv.mkDerivation rec {
19 pname = "kissfft-${datatype}${lib.optionalString enableOpenmp "-openmp"}";
22 src = fetchFromGitHub {
23 owner = "mborgerding";
26 sha256 = "1yfws5bn4kh62yk6hdyp9h9775l6iz7wsfisbn58jap6b56s8j5s";
30 ./0001-pkgconfig-darwin.patch
33 # https://bugs.llvm.org/show_bug.cgi?id=45034
34 postPatch = lib.optionalString (stdenv.hostPlatform.isLinux && stdenv.cc.isClang && lib.versionOlder stdenv.cc.version "10") ''
35 substituteInPlace test/Makefile \
36 --replace "-ffast-math" ""
38 + lib.optionalString (stdenv.hostPlatform.isDarwin) ''
39 substituteInPlace test/Makefile \
40 --replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH"
41 # Don't know how to make math.h's double long constants available
42 substituteInPlace test/testcpp.cc \
43 --replace "M_PIl" "M_PI"
47 "PREFIX=${placeholder "out"}"
48 "KISSFFT_DATATYPE=${datatype}"
49 "KISSFFT_TOOLS=${option withTools}"
50 "KISSFFT_STATIC=${option enableStatic}"
51 "KISSFFT_OPENMP=${option enableOpenmp}"
54 buildInputs = lib.optionals (withTools && datatype != "simd") [ libpng ]
55 # TODO: This may mismatch the LLVM version in the stdenv, see #79818.
56 ++ lib.optional (enableOpenmp && stdenv.cc.isClang) llvmPackages.openmp;
62 (if datatype == "float" then fftwFloat else fftw)
65 checkFlags = [ "testsingle" ];
68 ln -s ${pname}.pc $out/lib/pkgconfig/kissfft.pc
71 # Tools can't find kissfft libs on Darwin
72 postFixup = lib.optionalString (withTools && stdenv.hostPlatform.isDarwin) ''
73 for bin in $out/bin/*; do
74 install_name_tool -change lib${pname}.dylib $out/lib/lib${pname}.dylib $bin
79 description = "A mixed-radix Fast Fourier Transform based up on the KISS principle";
80 homepage = "https://github.com/mborgerding/kissfft";
81 license = licenses.bsd3;
82 maintainers = [ maintainers.goibhniu ];
83 platforms = platforms.all;