# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_realname=libmspack
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.11
pkgrel=1
pkgdesc="A library for Microsoft compression formats. (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://www.cabextract.org.uk/libmspack'
msys2_repository_url="https://github.com/kyz/libmspack"
msys2_references=(
  'archlinux: libmspack'
)
license=('spdx:LGPL-2.1-only')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=("https://github.com/kyz/libmspack/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('284e0e51fee991c40e8cbbc0f5e635f99722796a3642a14397989fc00b862f72')
noextract=("${_realname}-${pkgver}.tar.gz")

prepare() {
  echo "Extracting ${_realname}-${pkgver}.tar.gz..."
  tar -xzf ${_realname}-${pkgver}.tar.gz || true

  cd ${_realname}-${pkgver}/libmspack

  autoreconf -fiv
}

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

  ../${_realname}-${pkgver}/libmspack/configure \
    --prefix="${MINGW_PREFIX}" \
    --enable-shared \
    --disable-static

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

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