{ stdenv, lib, fetchFromGitHub, pkg-config, libtool, autoconf, automake, tcl, }: let isWindows = stdenv.hostPlatform.isWindows; notWindows = !isWindows; in stdenv.mkDerivation rec { pname = "openocd-pico"; version = "sdk-2.0.0"; src = fetchFromGitHub { owner = "raspberrypi"; repo = "openocd"; rev = "cf9c0b41cd5c45b2faf01b4fd1186f160342b7b7"; hash = "sha256-8PpBT+RRd8FiVBhzfsTRcIrzwrd1Y4zNYEfDga+11qU="; leaveDotGit = true; fetchSubmodules = true; }; nativeBuildInputs = [ pkg-config libtool tcl autoconf automake ]; # This emulates the bootstrap script, but is ran as a hook so it can use # the native build inputs. preConfigure = '' # SPDX-License-Identifier: GPL-2.0-or-later # Run the autotools bootstrap sequence to create the configure script # Abort execution on error set -e # bootstrap the autotools ( set -x aclocal --warnings=all # Apparently, not all versions of libtoolize support option --warnings=all . libtoolize --automake --copy autoconf --warnings=all autoheader --warnings=all automake --warnings=all --gnu --add-missing --copy ) if [ -x src/jtag/drivers/libjaylink/autogen.sh ]; then ( cd src/jtag/drivers/libjaylink ./autogen.sh ) fi echo "Bootstrap complete. Quick build instructions:" echo "./configure ...." ''; configureFlags = [ "--disable-werror" ]; enableParallelBuilding = true; postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' mkdir -p "$out/etc/udev/rules.d" rules="$out/share/openocd/contrib/60-openocd.rules" if [ ! -f "$rules" ]; then echo "$rules is missing, must update the Nix file." exit 1 fi ln -s "$rules" "$out/etc/udev/rules.d/" ''; meta = with lib; { description = "Free and Open On-Chip Debugging, In-System Programming and Boundary-Scan Testing"; mainProgram = "openocd"; longDescription = '' OpenOCD provides on-chip programming and debugging support with a layered architecture of JTAG interface and TAP support, debug target support (e.g. ARM, MIPS), and flash chip drivers (e.g. CFI, NAND, etc.). Several network interfaces are available for interactiving with OpenOCD: HTTP, telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a "remote target" for source-level debugging of embedded systems using the GNU GDB program. ''; homepage = "https://openocd.sourceforge.net/"; license = licenses.gpl2Plus; maintainers = with maintainers; [ bjornfor prusnak ]; platforms = platforms.unix ++ platforms.windows; }; }