# Maintainer: James Ross-Gowan <rossymiles@gmail.com>

_realname=uchardet
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.0.7
pkgrel=1
pkgdesc="An encoding detector library ported from Mozilla (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://www.freedesktop.org/wiki/Software/uchardet/'
license=('MPL')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-gcc")
source=("https://www.freedesktop.org/software/uchardet/releases/${_realname}-${pkgver}.tar.xz")
sha256sums=('3fc79408ae1d84b406922fa9319ce005631c95ca0f34b205fad867e8b30e45b1')

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -r "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    ../${_realname}-${pkgver}
  make
}

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