# Maintainer: Martell Malone <martellmalone@gmail.com>

_realname=chipmunk
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=7.0.3
pkgrel=1
pkgdesc="A high-performance 2D rigid body physics library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://chipmunk-physics.net/"
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake")
source=("https://github.com/slembcke/Chipmunk2D/archive/Chipmunk-${pkgver}.tar.gz")
sha256sums=('1e6f093812d6130e45bdf4cb80280cb3c93d1e1833d8cf989d554d7963b7899a')
options=(staticlibs !buildflags !strip)

prepare() {
  cd ${srcdir}/Chipmunk2D-Chipmunk-${pkgver}
}

build() {

  mkdir -p "${srcdir}/build-${CARCH}"
  cd "${srcdir}/build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DBUILD_DEMOS=OFF \
    -DBUILD_SHARED=ON \
    -DINSTALL_STATIC=ON \
    ../Chipmunk2D-Chipmunk-${pkgver}

  make
}

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