# Maintainer: Diego Sogari <diego.sogari@gmail.com>

_realname=fann
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.2.0
pkgrel=2
pkgdesc="Fast Artificial Neural Network Library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://leenissen.dk/fann/"
license=('LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/libfann/fann/archive/${pkgver}.tar.gz"
        "${_realname}-${pkgver}.patch")
sha256sums=('f31c92c1589996f97d855939b37293478ac03d24b4e1c08ff21e0bd093449c3c'
            '487aa5ac2201abb8824d1b3b31c7ec1cfd75024982edfe88bca198835912b5c6')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "../${_realname}-${pkgver}.patch"
}

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    "../${_realname}-${pkgver}"

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
  
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.txt
}
