# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=goxel
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=0.10.7
pkgrel=1
pkgdesc="3D program that lets you create voxel volumes (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64')
url="https://goxel.xyz/"
license=('GPL3')
depends=("${MINGW_PACKAGE_PREFIX}-glfw"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-libiconv"
         "${MINGW_PACKAGE_PREFIX}-gettext"
         "${MINGW_PACKAGE_PREFIX}-libtre")
makedepends=("${MINGW_PACKAGE_PREFIX}-scons"
             "${MINGW_PACKAGE_PREFIX}-pkgconf")
source=("$_realname-$pkgver.tar.gz::https://github.com/guillaumechereau/$_realname/archive/v$pkgver.tar.gz"
        "001-goxel-0.10.7-msys-mingw.patch")
sha256sums=('dfb91e62bdd5332e3938923db924bae43f12eaa181040d16e4cc7082316adf1c'
            'c7926b9d774ae9337679abf0d7a3be0783f6832ee29ab6db16be07eafa3c7c94')

prepare() {
  cd $_realname-$pkgver

  patch -Np1 -i "${srcdir}/001-goxel-0.10.7-msys-mingw.patch"
}

build() {
  msg "Build for ${CARCH}"

  rm -rf build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "build-${CARCH}"
  cd "${srcdir}/build-${CARCH}"

  make release
}

package() {
  cd "${srcdir}/build-${CARCH}"

  make DESTDIR="$pkgdir" PREFIX=${MINGW_PREFIX} install

  install -D -m644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname/LICENSE"
}
