11 , withDoc ? stdenv.cc.isGNU
15 assert lib.elem precision [ "single" "double" "long-double" "quad-precision" ];
17 stdenv.mkDerivation (finalAttrs: {
18 pname = "fftw-${precision}";
23 "https://fftw.org/fftw-${finalAttrs.version}.tar.gz"
24 "ftp://ftp.fftw.org/pub/fftw/fftw-${finalAttrs.version}.tar.gz"
26 sha256 = "sha256-VskyVJhSzdz6/as4ILAgDHdCZ1vpIXnlnmIVs0DiZGc=";
31 name = "remove_missing_FFTW3LibraryDepends.patch";
32 url = "https://github.com/FFTW/fftw3/pull/338/commits/f69fef7aa546d4477a2a3fd7f13fa8b2f6c54af7.patch";
33 hash = "sha256-lzX9kAHDMY4A3Td8necXwYLcN6j8Wcegi3A7OIECKeU=";
37 outputs = [ "out" "dev" "man" ]
38 ++ lib.optional withDoc "info"; # it's dev-doc only
39 outputBin = "dev"; # fftw-wisdom
41 nativeBuildInputs = [ gfortran ];
43 buildInputs = lib.optionals stdenv.cc.isClang [
44 # TODO: This may mismatch the LLVM version sin the stdenv, see #79818.
46 ] ++ lib.optional enableMpi mpi;
54 ++ lib.optional (precision != "double") "--enable-${precision}"
55 # https://www.fftw.org/fftw3_doc/SIMD-alignment-and-fftw_005fmalloc.html
56 # FFTW will try to detect at runtime whether the CPU supports these extensions
57 ++ lib.optional (stdenv.hostPlatform.isx86_64 && (precision == "single" || precision == "double"))
58 "--enable-sse2 --enable-avx --enable-avx2 --enable-avx512 --enable-avx128-fma"
59 ++ lib.optional enableMpi "--enable-mpi"
60 # doc generation causes Fortran wrapper generation which hard-codes gcc
61 ++ lib.optional (!withDoc) "--disable-doc";
63 # fftw builds with -mtune=native by default
65 substituteInPlace configure --replace "-mtune=native" "-mtune=generic"
68 enableParallelBuilding = true;
70 nativeCheckInputs = [ perl ];
72 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
75 description = "Fastest Fourier Transform in the West library";
76 homepage = "https://www.fftw.org/";
77 license = licenses.gpl2Plus;
83 "long-double" = "fftw3l";
84 "quad-precision" = "fftw3q";
87 platforms = platforms.unix;
88 # quad-precision requires libquadmath from gfortran, but libquadmath is not supported on aarch64
89 badPlatforms = lib.optionals (precision == "quad-precision") platforms.aarch64;