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

_realname=libfilezilla
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.51.0
pkgrel=1
pkgdesc="Small and modern C++ library, offering some basic functionality to build high-performing, platform-independent programs (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: libfilezilla'
)
msys2_repository_url="https://svn.filezilla-project.org/filezilla/libfilezilla/trunk/"
msys2_documentation_url="https://lib.filezilla-project.org/doc/"
url="https://lib.filezilla-project.org/"
depends=("${MINGW_PACKAGE_PREFIX}-cc-libs"
         "${MINGW_PACKAGE_PREFIX}-nettle"
         "${MINGW_PACKAGE_PREFIX}-gnutls")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-gettext")
checkdepends=("${MINGW_PACKAGE_PREFIX}-cppunit")
license=('spdx:GPL-2.0-or-later')
# Upstream download link became (purposely) unstable
# See https://trac.filezilla-project.org/ticket/13186
#source=("https://download.filezilla-project.org/${_realname}/${_realname}-${pkgver}.tar.xz")
source=("https://sources.archlinux.org/other/${_realname}/${_realname}-${pkgver}.tar.xz")
sha256sums=('6186c1665e32728b2d1e5f72bd54c4489930c029e2c68b5d649e782cdebe5175')

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

  # autoreconf to get updated libtool files with clang support
  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM}

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

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

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