#! /usr/bin/bash
# Contributor: Jevgeny Krasovsky <jkrasovsky@gmail.com>

_realname=qrencode
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=4.1.1
pkgrel=1
pkgdesc="C library for encoding data in a QR Code symbol (mingw-w64)"
arch=(any)
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
depends=("${MINGW_PACKAGE_PREFIX}-libpng")
makedepends=(${MINGW_PACKAGE_PREFIX}-SDL)
url="https://fukuchi.org/works/qrencode/index.en.html"
license=('GPL')
source=(https://fukuchi.org/works/${_realname}/${_realname}-${pkgver}.tar.bz2)
sha256sums=('e455d9732f8041cf5b9c388e345a641fd15707860f928e94507b1961256a6923')

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --with-tests

  make
}

check () {
  make check -C build-${MINGW_CHOST}
}

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