# Maintainer: qme5400 <qme5400@gmail.com>

_realname=enet
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.18
pkgrel=1
pkgdesc="Reliable UDP networking library (mingw-w64)"
url="http://enet.bespin.org/"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
license=('custom')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
source=("http://enet.bespin.org/download/${_realname}-${pkgver}.tar.gz"
        001-no-undefined.patch
        002-win-libs.patch)
sha256sums=('2a8a0c5360d68bb4fcd11f2e4c47c69976e8d2c85b109dd7d60b1181a4f85d36'
            'b777d7ad81b48763a4647c75dca3ca6892f884618929970df2f76c5b36b9d479'
            'bc3dec292538395b3ecc72ae3133697190be2e70b2895fd226a7fd1bd563fdc4')

prepare() {
  cd "${srcdir}/enet-${pkgver}"
  patch -p1 -i "${srcdir}"/001-no-undefined.patch
  patch -p1 -i "${srcdir}"/002-win-libs.patch

  autoreconf -fiv
}

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
      --prefix=${MINGW_PREFIX} \
      --enable-shared \
      --enable-static

  make
}

package() {
  cd build-${MSYSTEM}
  make DESTDIR="${pkgdir}" install
}
