acr-cli: init at 0.14 (#359508)
[NixPkgs.git] / pkgs / by-name / ff / fftw / package.nix
blob2cc3a85adb9c25d82351f07e8216dd04c1ae1111
1 { fetchurl
2 , fetchpatch
3 , stdenv
4 , lib
5 , gfortran
6 , perl
7 , llvmPackages
8 , precision ? "double"
9 , enableMpi ? false
10 , mpi
11 , withDoc ? stdenv.cc.isGNU
12 , testers
15 assert lib.elem precision [ "single" "double" "long-double" "quad-precision" ];
17 stdenv.mkDerivation (finalAttrs: {
18   pname = "fftw-${precision}";
19   version = "3.3.10";
21   src = fetchurl {
22     urls = [
23       "https://fftw.org/fftw-${finalAttrs.version}.tar.gz"
24       "ftp://ftp.fftw.org/pub/fftw/fftw-${finalAttrs.version}.tar.gz"
25     ];
26     sha256 = "sha256-VskyVJhSzdz6/as4ILAgDHdCZ1vpIXnlnmIVs0DiZGc=";
27   };
29   patches = [
30     (fetchpatch {
31       name = "remove_missing_FFTW3LibraryDepends.patch";
32       url = "https://github.com/FFTW/fftw3/pull/338/commits/f69fef7aa546d4477a2a3fd7f13fa8b2f6c54af7.patch";
33       hash = "sha256-lzX9kAHDMY4A3Td8necXwYLcN6j8Wcegi3A7OIECKeU=";
34     })
35   ];
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.
45     llvmPackages.openmp
46   ] ++ lib.optional enableMpi mpi;
48   configureFlags = [
49     "--enable-shared"
50     "--enable-threads"
51     "--enable-openmp"
52   ]
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
64   postPatch = ''
65     substituteInPlace configure --replace "-mtune=native" "-mtune=generic"
66   '';
68   enableParallelBuilding = true;
70   nativeCheckInputs = [ perl ];
72   passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
74   meta = with lib; {
75     description = "Fastest Fourier Transform in the West library";
76     homepage = "https://www.fftw.org/";
77     license = licenses.gpl2Plus;
78     maintainers = [ ];
79     pkgConfigModules = [
80       {
81         "single" = "fftw3f";
82         "double" = "fftw3";
83         "long-double" = "fftw3l";
84         "quad-precision" = "fftw3q";
85       }.${precision}
86     ];
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;
90   };