# Contributor: Ozkan Sezer <sezero@users.sourceforge.net>

_realname=libtimidity
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2.7
pkgrel=1
pkgdesc="MIDI to WAVE converter library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://libtimidity.sourceforge.io/"
license=("LGPL" "Artistic")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             )
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('strip' 'staticlibs')
source=(https://downloads.sourceforge.net/libtimidity/${_realname}-${pkgver}.tar.gz)
sha256sums=('26447cbc049fb262e26b640e42c063e8694133aa92ff145e0d0b15a03a352e6a')

# change this if necessary:
_timidity_cfg=timidity.cfg

# libao is only needed for make check, therefore disable it surely.
build() {
  export lt_cv_deplibs_check_method='pass_all'
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-ao \
    --with-timidity-cfg=${_timidity_cfg}

  make
}

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

  # Install license
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING.artistic ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING.artistic
}
