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

_realname=pystring
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.1.4
pkgrel=1
pkgdesc="A collection of C++ functions which match the interface and behavior of python's string class methods using std::string (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/imageworks/pystring"
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools")
source=(https://github.com/imageworks/pystring/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz
        01-makefile.patch)
sha256sums=('49da0fe2a049340d3c45cce530df63a2278af936003642330287b68cefd788fb'
            '35754393c734730664fb7686d463db7e0c05f59c3a9e51fc38c22ff177e2cfee')

prepare() {
  cd ${_realname}-${pkgver}
  patch -p1 -i "${srcdir}"/01-makefile.patch
}

build() {
  [[ -d "build-${MSYSTEM}" ]] && rm -rf "build-${MSYSTEM}"
  cp -rf ${_realname}-${pkgver} build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  make
}

package() {
  cd build-${MSYSTEM}

  mkdir -p "${pkgdir}"${MINGW_PREFIX}/{include/pystring,lib}
  make DESTDIR="${pkgdir}" PREFIX=${MINGW_PREFIX} install

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