# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libdiscid
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.6.5
pkgrel=1
pkgdesc="A Library for creating MusicBrainz DiscIDs (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://musicbrainz.org/doc/libdiscid"
msys2_repository_url='https://github.com/metabrainz/libdiscid'
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools" "${MINGW_PACKAGE_PREFIX}-cc")
source=("https://data.metabrainz.org/pub/musicbrainz/libdiscid/libdiscid-${pkgver}.tar.gz"
        "libdiscid-0.6.2-include-location.patch")
sha256sums=('72dbb493e07336418fe2056f0ebc7ce544eedb500bb896cc1cc04bd078c2d530'
            '227e1539e175da6323b1bfd92ac783cee4dbd5d940f97af77a1e67f25bfaa2e8')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/libdiscid-0.6.2-include-location.patch"
  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}"/build-${MSYSTEM}
  make check
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  make install DESTDIR="${pkgdir}"
}
