about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/science/electronics/flopoco/default.nix
blob: 7ce1087209e2c03e0e942ffd5567fc9f468cc33f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{ lib
, stdenv
, fetchFromGitLab
, fetchpatch
, cmake
, installShellFiles
, bison
, boost
, flex
, gmp
, libxml2
, mpfi
, mpfr
, scalp
, sollya
, wcpg
}:

stdenv.mkDerivation rec {
  pname = "flopoco";
  version = "4.1.3";

  src = fetchFromGitLab {
    owner = pname;
    repo = pname;
    # flopoco-4.1.3 is not tagged on GitLab
    rev = "67598298207c9f3261c35679c8a5966480c4343c";
    sha256 = "sha256-0jRjg4/qciqBcjsi6BTbKO4VJkcoEzpC98wFkUOIGbI=";
  };

  patches = [
    (fetchpatch {
      name = "fix-clang-error-sin-cos.patch";
      url = "https://gitlab.com/flopoco/flopoco/-/commit/de3aa60ad19333952c176c2a2e51f12653ca736b.patch";
      postFetch = ''
        substituteInPlace $out \
          --replace 'FixSinCosCORDIC.hpp' 'CordicSinCos.hpp'
      '';
      sha256 = "sha256-BlamA/MZuuqqvGYto+jPeQPop6gwva0y394Odw8pdwg=";
    })
    (fetchpatch {
      name = "fix-clang-error-atan2.patch";
      url = "https://gitlab.com/flopoco/flopoco/-/commit/a3ffe2436c1b59ee0809b3772b74f2d43c6edb99.patch";
      sha256 = "sha256-dSYcufLHDL0p1V1ghmy6X6xse5f6mjUqckaVqLZnTaA=";
    })
  ];

  postPatch = lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) ''
    sed -i "s/-pg//g" {,src/Apps/TaMaDi/}CMakeLists.txt
  '';

  strictDeps = true;

  nativeBuildInputs = [
    bison
    cmake
    installShellFiles
  ];

  buildInputs = [
    boost
    flex
    gmp
    libxml2
    mpfi
    mpfr
    scalp
    sollya
    wcpg
  ];

  postBuild = ''
    ./flopoco BuildAutocomplete
  '';

  installPhase = ''
    runHook preInstall

    install -Dm755 flopoco $out/bin/flopoco
    cp bin* fp* ieee* longacc* $out/bin/
    installShellCompletion --bash flopoco_autocomplete

    runHook postInstall
  '';

  meta = with lib; {
    description = "The FloPoCo arithmetic core generator";
    homepage = "https://flopoco.org/";
    license = licenses.unfree;
    platforms = platforms.unix;
    maintainers = with maintainers; [ wegank ];
  };
}