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

_realname=mpg123
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.27.2
pkgrel=2
pkgdesc="A console based real time MPEG Audio Player for Layer 1, 2 and 3 (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://www.mpg123.com/"
license=("LGPL2.1")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-openal"
             "${MINGW_PACKAGE_PREFIX}-portaudio"
             "${MINGW_PACKAGE_PREFIX}-SDL2")
depends=("${MINGW_PACKAGE_PREFIX}-libtool"
         "${MINGW_PACKAGE_PREFIX}-gcc-libs")
optdepends=("${MINGW_PACKAGE_PREFIX}-openal"
            "${MINGW_PACKAGE_PREFIX}-portaudio"
            "${MINGW_PACKAGE_PREFIX}-SDL2")
options=('strip' 'staticlibs' 'libtool')
source=("https://www.mpg123.com/download/mpg123-${pkgver}.tar.bz2"{,.sig})
sha256sums=('52f6ceb962c05db0c043bb27acf5a721381f5f356ac4610e5221f50293891b04'
            'SKIP')
validpgpkeys=('D021FF8ECF4BE09719D61A27231C4CBC60D5CAFE')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  autoreconf -fi
}

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} \
    --enable-shared \
    --enable-static

  make
}

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

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
} 
