# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

pkgname=blackmagic
pkgver=1.10.2
pkgrel=2
pkgdesc='In application debugger for ARM Cortex microcontrollers'
arch=('x86_64')
url='https://github.com/blacksphere/blackmagic'
license=('GPL')
depends=('libusb' 'libftdi' 'libhidapi-hidraw.so')
makedepends=('git' 'hidapi' 'python')
#             'arm-none-eabi-gcc')
source=("git+$url#tag=v$pkgver")
#        'git+https://github.com/libopencm3/libopencm3.git')
sha512sums=('afe1fabcfd8492ca57ca817cc7da18d1d814dbde5831b96af4a65b443a48035af687c822aa61d38713fc334398359c668d84d99a25f8760c7c70cba143fabd60')

#prepare() {
#  cd $pkgname
#
#  git submodule init
#  git config submodule.libopencm3.url "$srcdir"/libopencm3
#  git submodule update
#}

prepare() {
  sed -i 's| -Werror||' $pkgname/src/Makefile
}

build() {
  cd $pkgname

  make PROBE_HOST=hosted
}

package() {
  cd $pkgname

  install -Dm 755 src/blackmagic "$pkgdir"/usr/bin/blackmagic

  install -Dm 644 driver/99-blackmagic-uucp.rules -t "$pkgdir"/usr/lib/udev/rules.d/
}
