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

_realname=libguess
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.2
pkgrel=3
pkgdesc="High-speed character set detection library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="http://atheme.org/projects/libguess.html"
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-libmowgli")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs' 'strip')
source=("http://rabbit.dereferenced.org/%7Enenolod/distfiles/${_realname}-${pkgver}.tar.bz2")
sha256sums=('8019a16bdc7ca9d2efbdcc1429d48d033d5053d42e45fccea10abf98074f05f8')

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

  sed 's/libmowgli >= 0.9.50/libmowgli-2/g' -i configure
}

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  cp -rf ${_realname}-${pkgver} ${srcdir}/build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR="$pkgdir" install
  install -D -m644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
