10 , withDoc ? stdenv.cc.isGNU
14 assert lib.elem precision [ "single" "double" "long-double" "quad-precision" ];
16 stdenv.mkDerivation (finalAttrs: {
17 pname = "fftw-${precision}";
22 "https://fftw.org/fftw-${finalAttrs.version}.tar.gz"
23 "ftp://ftp.fftw.org/pub/fftw/fftw-${finalAttrs.version}.tar.gz"
25 sha256 = "sha256-VskyVJhSzdz6/as4ILAgDHdCZ1vpIXnlnmIVs0DiZGc=";
28 outputs = [ "out" "dev" "man" ]
29 ++ lib.optional withDoc "info"; # it's dev-doc only
30 outputBin = "dev"; # fftw-wisdom
32 nativeBuildInputs = [ gfortran ];
34 buildInputs = lib.optionals stdenv.cc.isClang [
35 # TODO: This may mismatch the LLVM version sin the stdenv, see #79818.
37 ] ++ lib.optional enableMpi mpi;
45 ++ lib.optional (precision != "double") "--enable-${precision}"
46 # https://www.fftw.org/fftw3_doc/SIMD-alignment-and-fftw_005fmalloc.html
47 # FFTW will try to detect at runtime whether the CPU supports these extensions
48 ++ lib.optional (stdenv.isx86_64 && (precision == "single" || precision == "double"))
49 "--enable-sse2 --enable-avx --enable-avx2 --enable-avx512 --enable-avx128-fma"
50 ++ lib.optional enableMpi "--enable-mpi"
51 # doc generation causes Fortran wrapper generation which hard-codes gcc
52 ++ lib.optional (!withDoc) "--disable-doc";
54 # fftw builds with -mtune=native by default
56 substituteInPlace configure --replace "-mtune=native" "-mtune=generic"
59 enableParallelBuilding = true;
61 nativeCheckInputs = [ perl ];
63 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
66 description = "Fastest Fourier Transform in the West library";
67 homepage = "http://www.fftw.org/";
68 license = licenses.gpl2Plus;
74 "long-double" = "fftw3l";
75 "quad-precision" = "fftw3q";
78 platforms = platforms.unix;