# Maintainer: Kreijstal <kreijstal@hotmail.com>

_realname=libgig
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=4.4.1
pkgrel=1
pkgdesc="C++ library for loading, modifying and creating .gig, .dls, .kmp and SF2 files (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.linuxsampler.org/libgig/"
msys2_references=(
  'cpe: cpe:2.3:a:linuxsampler:libgig'
)
license=('spdx:gpl-2.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-libsndfile")
source=("https://download.linuxsampler.org/packages/${_realname}-${pkgver}.tar.bz2"
        "libgig-4.3.0-libdir.patch")
sha256sums=('fdc89efab1f906128e6c54729967577e8d0462017018bc12551257df5dfe3aa4'
            'bfdc3a58af846f7eb8864dd489010b04957f29873a7b3c249460b3f4b02956ee')

prepare() {
  cd "${_realname}-${pkgver}"
  autoreconf -fiv
  patch -p1 -i "${srcdir}/libgig-4.3.0-libdir.patch"
}

build() {
  mkdir -p "build-${MSYSTEM}" && cd "build-${MSYSTEM}"
  export lt_cv_deplibs_check_method='pass_all'

  ../"${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --host="${MINGW_CHOST}" \
    --target="${MINGW_CHOST}" \
    --enable-shared \
    --enable-static

  make
}

check() {
  cd "build-${MSYSTEM}"
  make check
}

package() {
  cd "build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
