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

_realname=shine
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.1.1
pkgrel=1
pkgdesc="Super fast fixed-point MP3 encoder (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('GPL2')
url="https://github.com/savonet/shine"
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/toots/${_realname}/archive/${pkgver}.tar.gz"
        "0001-shine-3.1.1-fix-include.patch")
noextract=("${_realname}-${pkgver}.tar.gz")
sha256sums=('565b87867d6f8e6616a236445d194e36f4daa9b4e7af823fcf5010af7610c49e'
            'bc4e9b812611c2a06c7fb58d5e284fa1978a97348c99db52d239edabca26e792')

prepare() {
  cd "${srcdir}"
  tar -xvzf "${_realname}-${pkgver}.tar.gz"
  cd "$srcdir"/${_realname}-${pkgver}
  patch -Np1 -i "${srcdir}/0001-shine-3.1.1-fix-include.patch"
  ./bootstrap
}

build() {
  cd "$srcdir"/${_realname}-${pkgver}
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  cp -R ${srcdir}/${_realname}-${pkgver}/* ${srcdir}/build-${CARCH}
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

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