tuicam: init at 0.0.2 (#377825)
[NixPkgs.git] / pkgs / by-name / op / openocd / package.nix
blob618b998eefcb62a0f3d2b7e02c777d09a3d5a579
2   stdenv,
3   lib,
4   fetchurl,
5   pkg-config,
6   hidapi,
7   tcl,
8   jimtcl,
9   libjaylink,
10   libusb1,
11   libgpiod_1,
13   enableFtdi ? true,
14   libftdi1,
16   # Allow selection the hardware targets (SBCs, JTAG Programmers, JTAG Adapters)
17   extraHardwareSupport ? [ ],
19 let
21   isWindows = stdenv.hostPlatform.isWindows;
22   notWindows = !isWindows;
25 stdenv.mkDerivation rec {
26   pname = "openocd";
27   version = "0.12.0";
28   src = fetchurl {
29     url = "mirror://sourceforge/project/${pname}/${pname}/${version}/${pname}-${version}.tar.bz2";
30     sha256 = "sha256-ryVHiL6Yhh8r2RA/5uYKd07Jaow3R0Tu+Rl/YEMHWvo=";
31   };
33   nativeBuildInputs = [
34     pkg-config
35     tcl
36   ];
38   buildInputs =
39     [ libusb1 ]
40     ++ lib.optionals notWindows [
41       hidapi
42       jimtcl
43       libftdi1
44       libjaylink
45     ]
46     ++
47       # tracking issue for v2 api changes https://sourceforge.net/p/openocd/tickets/306/
48       lib.optional stdenv.hostPlatform.isLinux libgpiod_1;
50   configureFlags = [
51     "--disable-werror"
52     "--enable-jtag_vpi"
53     "--enable-remote-bitbang"
54     (lib.enableFeature notWindows "buspirate")
55     (lib.enableFeature (notWindows && enableFtdi) "ftdi")
56     (lib.enableFeature stdenv.hostPlatform.isLinux "linuxgpiod")
57     (lib.enableFeature stdenv.hostPlatform.isLinux "sysfsgpio")
58     (lib.enableFeature isWindows "internal-jimtcl")
59     (lib.enableFeature isWindows "internal-libjaylink")
60   ] ++ map (hardware: "--enable-${hardware}") extraHardwareSupport;
62   enableParallelBuilding = true;
64   env.NIX_CFLAGS_COMPILE = toString (
65     lib.optionals stdenv.cc.isGNU [
66       "-Wno-error=cpp"
67       "-Wno-error=strict-prototypes" # fixes build failure with hidapi 0.10.0
68     ]
69   );
71   postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
72     mkdir -p "$out/etc/udev/rules.d"
73     rules="$out/share/openocd/contrib/60-openocd.rules"
74     if [ ! -f "$rules" ]; then
75         echo "$rules is missing, must update the Nix file."
76         exit 1
77     fi
78     ln -s "$rules" "$out/etc/udev/rules.d/"
79   '';
81   meta = with lib; {
82     description = "Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing";
83     mainProgram = "openocd";
84     longDescription = ''
85       OpenOCD provides on-chip programming and debugging support with a layered
86       architecture of JTAG interface and TAP support, debug target support
87       (e.g. ARM, MIPS), and flash chip drivers (e.g. CFI, NAND, etc.).  Several
88       network interfaces are available for interactiving with OpenOCD: HTTP,
89       telnet, TCL, and GDB.  The GDB server enables OpenOCD to function as a
90       "remote target" for source-level debugging of embedded systems using the
91       GNU GDB program.
92     '';
93     homepage = "https://openocd.sourceforge.net/";
94     license = licenses.gpl2Plus;
95     maintainers = with maintainers; [
96       bjornfor
97       prusnak
98     ];
99     platforms = platforms.unix ++ platforms.windows;
100   };