about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/libsigrok/default.nix
blob: e2eb40471db3214117c267e37e5442153c4421a1 (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
{ lib
, stdenv
, fetchurl
, pkg-config
, libzip
, glib
, libusb1
, libftdi1
, check
, libserialport
, doxygen
, glibmm
, python
, hidapi
, libieee1284
, bluez
, sigrok-firmware-fx2lafw
}:

stdenv.mkDerivation rec {
  pname = "libsigrok";
  version = "0.5.2";

  src = fetchurl {
    url = "https://sigrok.org/download/source/${pname}/${pname}-${version}.tar.gz";
    sha256 = "0g6fl684bpqm5p2z4j12c62m45j1dircznjina63w392ns81yd2d";
  };

  enableParallelBuilding = true;

  nativeBuildInputs = [ doxygen pkg-config python ];
  buildInputs = [
    libzip glib libusb1 libftdi1 check libserialport glibmm hidapi
  ] ++ lib.optionals stdenv.isLinux [ libieee1284 bluez ];

  strictDeps = true;

  postInstall = ''
    mkdir -p $out/etc/udev/rules.d
    cp contrib/*.rules $out/etc/udev/rules.d

    mkdir -p "$out/share/sigrok-firmware/"
    cp ${sigrok-firmware-fx2lafw}/share/sigrok-firmware/* "$out/share/sigrok-firmware/"
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    # assert that c++ bindings are included
    # note that this is only true for modern (>0.5) versions; the 0.3 series does not have these
    [[ -f $out/include/libsigrokcxx/libsigrokcxx.hpp ]] \
      || { echo 'C++ bindings were not generated; check configure output'; false; }
  '';

  meta = with lib; {
    description = "Core library of the sigrok signal analysis software suite";
    homepage = "https://sigrok.org/";
    license = licenses.gpl3Plus;
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ bjornfor ];
  };
}