# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=libfilezilla
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.25.0
pkgrel=2
pkgdesc="Small and modern C++ library, offering some basic functionality to build high-performing, platform-independent programs (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://lib.filezilla-project.org/"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-nettle"
         "${MINGW_PACKAGE_PREFIX}-gnutls")
makedepends=("${MINGW_PACKAGE_PREFIX}-gettext")
checkdepends=("${MINGW_PACKAGE_PREFIX}-cppunit")
license=('GPL')
source=("${_realname}-${pkgver}.tar.bz2"::"https://download.filezilla-project.org/${_realname}/${_realname}-${pkgver}.tar.bz2")
sha256sums=('3bf6feb5246ed3d11b72d74b485d1989724be0884568cd456195e7624f9c7b2a')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  # autoreconf to get updated libtool files with clang support
  autoreconf -fiv
}

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

  make
}

check() {
  cd "${srcdir}"/build-${CARCH}
  # LANG needed to fix string_test::test_conversion2
  LANG=en_US.UTF-8 make check || true
}

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