# Maintainer: Rafał Brzegowy <rafal.brzegowy@yahoo.com>

_realname=starpu
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.4.9
pkgrel=2
pkgdesc='StarPU is a task programming library for hybrid architectures (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://starpu.gitlabpages.inria.fr'
msys2_repository_url="https://gitlab.inria.fr/starpu/starpu"
license=('spdx:LGPL-2.1-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-fftw"
         "${MINGW_PACKAGE_PREFIX}-glpk"
         "${MINGW_PACKAGE_PREFIX}-hdf5"
         "${MINGW_PACKAGE_PREFIX}-hwloc"
         $([[ ${CARCH} == aarch64 ]] || echo "${MINGW_PACKAGE_PREFIX}-leveldb")
         "${MINGW_PACKAGE_PREFIX}-libwinpthread"
         #"${MINGW_PACKAGE_PREFIX}-openblas"
         "${MINGW_PACKAGE_PREFIX}-opencl-icd"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-autotools"
  "${MINGW_PACKAGE_PREFIX}-opencl-headers"
  #"${MINGW_PACKAGE_PREFIX}-python"
  #"${MINGW_PACKAGE_PREFIX}-python-setuptools"
  #"${MINGW_PACKAGE_PREFIX}-python-joblib"
  #"${MINGW_PACKAGE_PREFIX}-python-cloudpickle"
  #"${MINGW_PACKAGE_PREFIX}-python-numpy"
)
options=('!docs')
source=(https://files.inria.fr/starpu/${_realname}-${pkgver}/${_realname}-${pkgver}.tar.gz)
sha256sums=('1bf6388d59b3a01e18fb3e9deb001b35a243fe78e4508507284ea1fa00667af1')

prepare() {
  cd ${_realname}-${pkgver}
  autoreconf -fiv
}

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

  declare -a _extra_config
  if [[ ${CARCH} != aarch64 ]]; then
    _extra_config+=("--enable-leveldb")
  fi

  CFLAGS+=" -Wno-null-dereference -Wno-incompatible-pointer-types" \
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --enable-hdf5 \
    --enable-maxcpus=64 \
    --enable-opencl \
    --enable-quick-check \
    --enable-socl \
    --disable-build-doc \
    --disable-build-examples \
    --disable-fortran \
    --disable-gdb \
    --disable-mpi \
    --disable-starpupy \
    "${_extra_config[@]}"

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  make check || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING.LGPL \
    "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

# vim: ts=2 sw=2 et:
