# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=mypaint-brushes
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.1
pkgrel=1
pkgdesc="Brushes for MyPaint (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/mypaint/mypaint-brushes"
license=("ISC")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-libmypaint")
options=('strip' '!debug')
source=(${_realname}-${pkgver}.tar.gz::https://github.com/mypaint/mypaint-brushes/archive/v${pkgver}.tar.gz)
sha256sums=('e6d0f51adb2ad507c12aa40a78265638cb21c53f4eb761c274d044677afaa1ff')
noextract=(${_realname}-${pkgver}.tar.gz)

prepare() {
  [[ -d ${srcdir}/${_realname}-${pkgver} ]] && rm -rf ${srcdir}/${_realname}-${pkgver}

  tar --exclude=README -xzf ${_realname}-${pkgver}.tar.gz

  cd ${_realname}-${pkgver}
  ./autogen.sh
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

  "${srcdir}/${_realname}-${pkgver}"/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX}

  make
}

package() {
  cd "${srcdir}"/build-${MINGW_CHOST}
  make -j1 DESTDIR="${pkgdir}" install
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/Licenses.md "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/Licenses.md
}
