nixpkgs/pkgs/development/libraries/kissfft/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
2.3 KiB
Nix
Raw Normal View History

2021-04-18 18:55:09 +00:00
{ lib
, stdenv
2020-04-06 08:58:49 +00:00
, fetchFromGitHub
2021-04-18 18:55:09 +00:00
, fftw
, fftwFloat
, python3
, datatype ? "double"
, withTools ? false
, libpng
, enableStatic ? stdenv.hostPlatform.isStatic
, enableOpenmp ? false
, llvmPackages
2020-04-06 08:58:49 +00:00
}:
2021-04-18 18:55:09 +00:00
let
py = python3.withPackages (ps: with ps; [ numpy ]);
option = cond: if cond then "1" else "0";
in
2020-04-06 08:58:49 +00:00
stdenv.mkDerivation rec {
2021-04-18 18:55:09 +00:00
pname = "kissfft-${datatype}${lib.optionalString enableOpenmp "-openmp"}";
version = "131.1.0";
2020-04-06 08:58:49 +00:00
src = fetchFromGitHub {
owner = "mborgerding";
2021-04-18 18:55:09 +00:00
repo = "kissfft";
rev = version;
sha256 = "1yfws5bn4kh62yk6hdyp9h9775l6iz7wsfisbn58jap6b56s8j5s";
2020-04-06 08:58:49 +00:00
};
patches = [
2021-04-18 18:55:09 +00:00
./0001-pkgconfig-darwin.patch
2020-04-06 08:58:49 +00:00
];
2021-04-18 18:55:09 +00:00
# https://bugs.llvm.org/show_bug.cgi?id=45034
postPatch = lib.optionalString (stdenv.hostPlatform.isLinux && stdenv.cc.isClang && lib.versionOlder stdenv.cc.version "10") ''
substituteInPlace test/Makefile \
--replace "-ffast-math" ""
''
+ lib.optionalString (stdenv.hostPlatform.isDarwin) ''
substituteInPlace test/Makefile \
--replace "LD_LIBRARY_PATH" "DYLD_LIBRARY_PATH"
# Don't know how to make math.h's double long constants available
substituteInPlace test/testcpp.cc \
--replace "M_PIl" "M_PI"
2021-03-11 18:49:28 +00:00
'';
2021-04-18 18:55:09 +00:00
2020-04-06 08:58:49 +00:00
makeFlags = [
"PREFIX=${placeholder "out"}"
2021-04-18 18:55:09 +00:00
"KISSFFT_DATATYPE=${datatype}"
"KISSFFT_TOOLS=${option withTools}"
"KISSFFT_STATIC=${option enableStatic}"
"KISSFFT_OPENMP=${option enableOpenmp}"
];
buildInputs = lib.optionals (withTools && datatype != "simd") [ libpng ]
# TODO: This may mismatch the LLVM version in the stdenv, see #79818.
++ lib.optional (enableOpenmp && stdenv.cc.isClang) llvmPackages.openmp;
doCheck = true;
checkInputs = [
py
(if datatype == "float" then fftwFloat else fftw)
2020-04-06 08:58:49 +00:00
];
2021-04-18 18:55:09 +00:00
checkFlags = [ "testsingle" ];
postInstall = ''
ln -s ${pname}.pc $out/lib/pkgconfig/kissfft.pc
'';
# Tools can't find kissfft libs on Darwin
postFixup = lib.optionalString (withTools && stdenv.hostPlatform.isDarwin) ''
for bin in $out/bin/*; do
install_name_tool -change lib${pname}.dylib $out/lib/lib${pname}.dylib $bin
done
'';
meta = with lib; {
2020-04-06 08:58:49 +00:00
description = "A mixed-radix Fast Fourier Transform based up on the KISS principle";
homepage = "https://github.com/mborgerding/kissfft";
license = licenses.bsd3;
maintainers = [ maintainers.goibhniu ];
2021-03-11 18:49:28 +00:00
platforms = platforms.all;
2020-04-06 08:58:49 +00:00
};
}