# Maintainer: Andrew Leech <andrew@alelec.net>
# Contributor: Ray Donnelly <mingw.android@gmail.com>
# Contributor: Rocco Marco Guglielmi <guglielmir@playembedded.org>

_realname=openocd
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.11.0
pkgrel=1
pkgdesc="OpenOCD - Open On-Chip Debugger (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="http://openocd.org/"
license=("GPLv2")
options=('!ccache')
depends=("${MINGW_PACKAGE_PREFIX}-hidapi"
         "${MINGW_PACKAGE_PREFIX}-libusb"
         "${MINGW_PACKAGE_PREFIX}-libusb-compat"
         "${MINGW_PACKAGE_PREFIX}-libftdi"
         "${MINGW_PACKAGE_PREFIX}-libjaylink"
         "${MINGW_PACKAGE_PREFIX}-capstone")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
source=("https://downloads.sourceforge.net/sourceforge/${_realname}/${_realname}-${pkgver}.tar.bz2")
sha256sums=("43a3ce734aff1d3706ad87793a9f3a5371cb0e357f0ffd0a151656b06b3d1e7d")

build() {
  cd "${srcdir}"/${_realname}-${pkgver}

  ./configure \
      --prefix=${MINGW_PREFIX} \
      --{build,host}=${MINGW_CHOST} \
      --disable-dependency-tracking \
      --disable-werror \
      --disable-internal-libjaylink \
      --enable-dummy \
      --enable-jtag_vpi \
      --enable-remote-bitbang \
      --enable-amtjtagaccel \
      --enable-gw16012 \
      --enable-parport \
      --enable-parport-giveio

  make
}

package() {
  cd "${srcdir}"/${_realname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -Dm644 COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING

  # bsdtar can't convert non-ascii filenames to UTF-8 when run in
  # non-UTF-8 locale. It proceeds to pack them anyway embedding raw
  # binary filenames in the traditional tar headers.
}
