1{ fetchurl, stdenv, lib, precision ? "double" }:
2
3with lib;
4
5assert elem precision [ "single" "double" "long-double" "quad-precision" ];
6
7let
8 version = "3.3.7";
9 withDoc = stdenv.cc.isGNU;
10in
11
12stdenv.mkDerivation rec {
13 name = "fftw-${precision}-${version}";
14
15 src = fetchurl {
16 url = "ftp://ftp.fftw.org/pub/fftw/fftw-${version}.tar.gz";
17 sha256 = "0wsms8narnbhfsa8chdflv2j9hzspvflblnqdn7hw8x5xdzrnq1v";
18 };
19
20 outputs = [ "out" "dev" "man" ]
21 ++ optional withDoc "info"; # it's dev-doc only
22 outputBin = "dev"; # fftw-wisdom
23
24 configureFlags =
25 [ "--enable-shared" "--disable-static"
26 "--enable-threads"
27 ]
28 ++ optional (precision != "double") "--enable-${precision}"
29 # all x86_64 have sse2
30 # however, not all float sizes fit
31 ++ optional (stdenv.isx86_64 && (precision == "single" || precision == "double") ) "--enable-sse2"
32 ++ optional (stdenv.cc.isGNU && !stdenv.hostPlatform.isMusl) "--enable-openmp"
33 # doc generation causes Fortran wrapper generation which hard-codes gcc
34 ++ optional (!withDoc) "--disable-doc";
35
36 enableParallelBuilding = true;
37
38 meta = with stdenv.lib; {
39 description = "Fastest Fourier Transform in the West library";
40 homepage = http://www.fftw.org/;
41 license = licenses.gpl2Plus;
42 maintainers = [ maintainers.spwhitt ];
43 platforms = platforms.unix;
44 };
45}