# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=gavl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.4.0
pkgrel=2
pkgdesc="A low level library, upon which multimedia APIs can be built. (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://gmerlin.sourceforge.io/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs" "${MINGW_PACKAGE_PREFIX}-libpng")
source=("https://downloads.sourceforge.net/sourceforge/gmerlin/${_realname}-${pkgver}.tar.gz"
        "0001-gavl-1.4.0-fix-64-bit-compilation.patch"
        "0002-gavl-1.4.0-fix-shared-dll-installation.patch"
        "0003-missing-include.patch")
sha256sums=('51aaac41391a915bd9bad07710957424b046410a276e7deaff24a870929d33ce'
            '5d4b74dd6caa0d8c87945820785bc63918d2b74edaba07a4b1c566c9e544e976'
            '091f2990f75ddb212752b8ed5e0ab509dd6292e2593411ca387a44fc7ec9ece3'
            'ff1f349d891d64859f9de1458a3374db6021fa86e4c5c9cf0838a7189c79043d')
prepare(){
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/0001-gavl-1.4.0-fix-64-bit-compilation.patch"
  patch -Np1 -i "${srcdir}/0002-gavl-1.4.0-fix-shared-dll-installation.patch"
  patch -Np1 -i "${srcdir}/0003-missing-include.patch"
  autoreconf -fiv
}

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

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --with-cpuflags=none \
    --enable-static \
    --enable-shared \
    --without-doxygen

  make
}

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