# Contributor: Jeongbin Park <pjb7687@gmail.com>

_realname=cas-offinder
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.4.1
pkgrel=1
pkgdesc='A fast algorithm to search for potential off-target sites of Cas9 RNA-guided endonucleases (mingw-w64)' 
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
license=('BSD')
url="https://github.com/snugel/${_realname}"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-openmp"
         "${MINGW_PACKAGE_PREFIX}-opencl-headers" 
         "${MINGW_PACKAGE_PREFIX}-opencl-icd")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake>=3.1.0"
             "make")
source=(${_realname}-${pkgver}.tar.gz::"${url}/archive/${pkgver}.tar.gz")
sha256sums=('b33b9f39c15abae317ddaf6a4d93cd4dd184a73e8437a1a1c2dc75d933531f84')

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}

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

  make
}

package() {
  cd ${srcdir}/${_realname}-${pkgver}
  mkdir -p ${pkgdir}${MINGW_PREFIX}/bin/
  cp ${srcdir}/build-${MINGW_CHOST}/cas-offinder ${pkgdir}${MINGW_PREFIX}/bin/
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname
  cp -pf ${srcdir}/${_realname}-${pkgver}/LICENSE \
    ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}
}
