# Maintainer: Silvio Clecio <silvioprog@gmail.com>

_realname=libmicroutils
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=4.3.0
pkgrel=1
pkgdesc="Micro cross-platform C library for handling strings, files, regex, hashs and among others."
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/silvioprog/microutils"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-libsystre"
             "${MINGW_PACKAGE_PREFIX}-libiconv"
             "${MINGW_PACKAGE_PREFIX}-zlib"
             "${MINGW_PACKAGE_PREFIX}-libtool"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-libsystre")
source=("https://github.com/silvioprog/microutils/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz"{,.sig})
validpgpkeys=('ACDEB1EB9330106D5D8F98053BFD572FA16D239A') # Silvio Clecio (silvioprog) <silvioprog@gmail.com>
sha256sums=('66811fcfcb582d567baeb3d48754b82f23b84d3396cb28feb08c53fa35c9773c'
            'SKIP')

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/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}/LICENSE
}
