# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libgoom2
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2k4
pkgrel=3
pkgdesc="Shared library part of the Goom visualization plugin (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://www.fovea.cc/?page=details_produits&id=goom"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "flex")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('staticlibs' 'strip')
source=("https://downloads.sourceforge.net/project/goom/goom2k4/0/goom-${pkgver}-0-src.tar.gz"
        001-no-undefined.patch
        002-fix-random.patch)
sha256sums=('d993c904c05faba87fd7f159291fa1cb7aadcff2edd28454d8e967880a8a0c85'
            'dc11dec75b93c479b8036871656a967748de71e26b40225d0e4d3b427c6afa7f'
            'f3ec1a7c295441c3e29f43ae92d9d4191c13c7a9d5a8668796a613d65e43ab1d')

prepare() {
  cd "${srcdir}/goom2k4-0"
  patch -p1 -i ${srcdir}/001-no-undefined.patch
  patch -p1 -i ${srcdir}/002-fix-random.patch

  aclocal -I m4
  libtoolize --copy --force
  automake --foreign --add-missing
  autoconf
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
  ../goom2k4-0/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
      --target=${MINGW_CHOST} \
      --enable-shared \
      --enable-static \
      --without-xmms \
      --without-sdl

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make check
}

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