# Maintainer: Martell Malone <martell malone at g mail dot com>

_realname=box2d
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.4.1
pkgrel=1
pkgdesc="2D rigid body simulation library for games (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://www.box2d.org/"
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-doxygen")
source=(${_realname}-${pkgver}.tar.gz::https://github.com/erincatto/Box2D/archive/v${pkgver}.tar.gz)
sha256sums=('d6b4650ff897ee1ead27cf77a5933ea197cbeef6705638dd181adc2e816b23c2')
options=(staticlibs !buildflags !strip)

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_SHARED_LIBS=ON \
    -DBOX2D_BUILD_DOCS=ON \
    -DBOX2D_BUILD_TESTBED=OFF \
    -DBOX2D_BUILD_UNIT_TESTS=OFF \
    ../${_realname}-${pkgver}/

  make
}

package() {
  cd "${srcdir}/build-${CARCH}"
  make DESTDIR=${pkgdir} install
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
