# Maintainer: umarcor <unai.martinezcorral@ehu.eus>

_realname=ffts
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.0.0.r799.gfe86885
pkgrel=1
pkgdesc="ffts: The Fastest Fourier Transform in the South  (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/anthonix/ffts"
license=('custom')
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-gcc"
  "${MINGW_PACKAGE_PREFIX}-cmake"
)

_commit='fe86885e'
source=("${_realname}::git://github.com/anthonix/ffts.git#commit=${_commit}")
sha256sums=('SKIP')

pkgver() {
  cd "${_realname}"
  echo '0.0.0.r'"$(git rev-list --count HEAD)"'.g'"$(git describe --all --long | sed 's/^.*-g\(.*\)/\1/')"
}

build() {
  cd "${srcdir}/${_realname}"
  mkdir build
  cd build
  MSYS2_ARG_CONV_EXCL=-DCMAKE_INSTALL_PREFIX= cmake \
    -G "MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    -DENABLE_SHARED=ON \
    ../
  cmake --build .
}

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

  _pre="${pkgdir}${MINGW_PREFIX}"

  mkdir "${_pre}"/bin
  mv "${_pre}"/lib/*.dll "${_pre}"/bin/

  _licenses="${_pre}/share/licenses/${_realname}"
  mkdir -p "${_licenses}"
  install -m 644 "${srcdir}/${_realname}"/COPYRIGHT "${_licenses}"
}
