Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / fftw / default.nix
blob026c1f3ed0636a9572bf0ca3180c4fb25c4d5f1e
1 { fetchurl
2 , stdenv
3 , lib
4 , gfortran
5 , perl
6 , llvmPackages
7 , precision ? "double"
8 , enableMpi ? false
9 , mpi
10 , withDoc ? stdenv.cc.isGNU
11 , testers
14 assert lib.elem precision [ "single" "double" "long-double" "quad-precision" ];
16 stdenv.mkDerivation (finalAttrs: {
17   pname = "fftw-${precision}";
18   version = "3.3.10";
20   src = fetchurl {
21     urls = [
22       "https://fftw.org/fftw-${finalAttrs.version}.tar.gz"
23       "ftp://ftp.fftw.org/pub/fftw/fftw-${finalAttrs.version}.tar.gz"
24     ];
25     sha256 = "sha256-VskyVJhSzdz6/as4ILAgDHdCZ1vpIXnlnmIVs0DiZGc=";
26   };
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.
36     llvmPackages.openmp
37   ] ++ lib.optional enableMpi mpi;
39   configureFlags = [
40     "--enable-shared"
41     "--enable-threads"
42     "--enable-openmp"
43   ]
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
55   postPatch = ''
56     substituteInPlace configure --replace "-mtune=native" "-mtune=generic"
57   '';
59   enableParallelBuilding = true;
61   nativeCheckInputs = [ perl ];
63   passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
65   meta = with lib; {
66     description = "Fastest Fourier Transform in the West library";
67     homepage = "http://www.fftw.org/";
68     license = licenses.gpl2Plus;
69     maintainers = [ ];
70     pkgConfigModules = [
71       {
72         "single" = "fftw3f";
73         "double" = "fftw3";
74         "long-double" = "fftw3l";
75         "quad-precision" = "fftw3q";
76       }.${precision}
77     ];
78     platforms = platforms.unix;
79   };