# Template file for 'openocd'
pkgname=openocd
version=0.11.0+1
revision=2
# update to a commit that has a compatible jimtcl version
_commit=830d70bfc66ada2a68c73283b9e4fa4770d408ee
_jimtcl_version=0.81
build_style=gnu-configure
configure_args="
 --disable-werror
 --disable-internal-jimtcl
 --enable-amtjtagaccel
 --enable-at91rm9200
 --enable-bcm2835gpio
 --enable-buspirate
 --enable-dummy
 --enable-ep93xx
 --enable-gw16012
 --enable-jtag_vpi
 --enable-openjtag
 --enable-parport
 --enable-presto
 --enable-remote-bitbang
 --enable-sysfsgpio
 --enable-usb-blaster
 --enable-usb-blaster-2
 --enable-armjtagew
 --enable-ftdi
 --enable-jlink
 --enable-oocd_trace
 --enable-opendous
 --enable-osbdm
 --enable-rlink
 --enable-stlink
 --enable-ti-icdi
 --enable-ulink
 --enable-usbprog
 --enable-vsllink
 --enable-aice
 --enable-cmsis-dap
 --enable-cmsis-dap-v2
 --disable-internal-libjaylink"
hostmakedepends="automake pkg-config libtool which"
makedepends="hidapi-devel libftdi1-devel
 jimtcl-devel
 libusb-devel libjaylink-devel capstone-devel"
depends="jimtcl-devel>=${_jimtcl_version}_1<=${_jimtcl_version}_9999"
short_desc="Open On-Chip Debugger"
maintainer="Érico Nogueira <ericonr@disroot.org>"
license="GPL-2.0-or-later"
homepage="http://openocd.org/"
# note: switch back to sourceforge for the next tagged release
distfiles="https://github.com/openocd-org/openocd/archive/${_commit}.tar.gz"
checksum=f75cab70ec125ea0cd71cde3bdb2761ae83662c12bbb2d9e1d8e447aa7da9f25

CFLAGS="-fcommon"

case "$XBPS_MACHINE" in
	*-musl) configure_args+=" ac_cv_header_malloc_h=no"  # no mallinfo
esac

# should not be needed when using tagged releases
pre_configure() {
	./bootstrap nosubmodule
}

post_install() {
	vinstall contrib/60-openocd.rules 644 usr/lib/udev/rules.d/
}
