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

_realname=libgoom2
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2k4
pkgrel=5
pkgdesc="Shared library part of the Goom visualization plugin (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.fovea.cc/?page=details_produits&id=goom"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "flex" "${MINGW_PACKAGE_PREFIX}-autotools")
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
source=("https://downloads.sourceforge.net/project/goom/goom2k4/0/goom-${pkgver}-0-src.tar.gz"
        001-no-undefined.patch
        002-fix-random.patch
        003-fix-x87-clobbers.patch
        004-use-memset-instead-of-bzero.patch
        005-remove-duplicated-file-reference-in-makefile.patch)
sha256sums=('d993c904c05faba87fd7f159291fa1cb7aadcff2edd28454d8e967880a8a0c85'
            'dc11dec75b93c479b8036871656a967748de71e26b40225d0e4d3b427c6afa7f'
            'f3ec1a7c295441c3e29f43ae92d9d4191c13c7a9d5a8668796a613d65e43ab1d'
            '6bf406a9da62702fd6f70c9a8c7a4f2655936f00e4de8685093e2262ed1a7157'
            'e6bf737b87fb6071d85cb3838edcf9c29b4db1ab7cf300efc4a81f1517551636'
            '0b5a9e9db4ab93b14fc520407ea10cf0a8141cf7dbfcb6a957ecde1865ac733d')

prepare() {
  cd "${srcdir}/goom2k4-0"
  patch -p1 -i "${srcdir}"/001-no-undefined.patch
  patch -p1 -i "${srcdir}"/002-fix-random.patch
  patch -p1 -i "${srcdir}"/003-fix-x87-clobbers.patch
  patch -p1 -i "${srcdir}"/004-use-memset-instead-of-bzero.patch
  patch -p1 -i "${srcdir}"/005-remove-duplicated-file-reference-in-makefile.patch

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

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

  ../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-${MSYSTEM}"
  make check
}

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