# Contributor: Jordi De Groof <jordi dot degroof at gmail dot com>
# Contributor: Andre Klitzing <aklitzing () gmail () com>
# Contributor: Simon Sobisch <simonsobisch () gnu () org>

_realname=lcov
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.16
pkgrel=1
pkgdesc="front-end for GCC's coverage testing tool gcov"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/linux-test-project/lcov"
license=('spdx:GPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-perl")
source=("https://github.com/linux-test-project/lcov/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        "001-mingw-lcov1.12-handle-equals-signs.patch"
        "002-mingw-lcov1.12-fix-undef-behaviour.patch"
        "003-mingw-lcov-win32.patch")
sha256sums=('987031ad5528c8a746d4b52b380bc1bffe412de1f2b9c2ba5224995668e3240b'
            '54728aa4e244d3662c65ba91fb486dc1d5c64d9d55745ee334c4131109dc233c'
            'ceaf41f7cc9cea5a6fc4b0385ffef10d1ab8812acd2a5b16dcd8d7bca7120488'
            '2618246416784d36d48ff23398324eb39f34443c0dbc9ad3b61b100a5be33e7f')

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

  patch -p1 -i "${srcdir}"/001-mingw-lcov1.12-handle-equals-signs.patch
  patch -p1 -i "${srcdir}"/002-mingw-lcov1.12-fix-undef-behaviour.patch
  patch -p1 -i "${srcdir}"/003-mingw-lcov-win32.patch
}

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

  make LCOV_PERL_PATH="${MINGW_PREFIX}/bin/perl" PREFIX="${MINGW_PREFIX}" DESTDIR="${pkgdir}" install
}
