# Maintainer: qme5400 <qme5400@gmail.com>

_realname=enet
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.16
pkgrel=1
pkgdesc="Reliable UDP networking library (mingw-w64)"
url="http://enet.bespin.org/"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('custom')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs' 'strip')
source=("http://enet.bespin.org/download/${_realname}-${pkgver}.tar.gz"
        001-no-undefined.patch
        002-win-libs.patch)
sha256sums=('bbb77ebb607f4a03ecce0b06304bae4612bc26f418b75340644cff950562efd1'
            '5dee072b83da458727d828574629b48da7fcb82d839ac90e379cc72340731eb0'
            '5920ea828ed2c96cecbf5957a226244df0cf13e6b107bb82272d7991eabd8f79')

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-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

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

  make
}

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