# Maintainer: Martchus <martchus@gmx.net>

# All my PKGBUILDs are managed at https://github.com/Martchus/PKGBUILDs where
# you also find the URL of a binary repository.

_name=filezilla
pkgname=mingw-w64-filezilla
pkgver=3.25.2
pkgrel=1
pkgdesc="Fast and reliable FTP, FTPS and SFTP client (mingw-w64)"
arch=('any')
url="https://filezilla-project.org/"
license=('GPL')
depends=('mingw-w64-crt' 'mingw-w64-libidn' 'mingw-w64-sqlite' 'mingw-w64-gnutls' 'mingw-w64-wxmsw' 'mingw-w64-libfilezilla')
makedepends=('mingw-w64-configure' 'wxgtk')
options=(staticlibs !strip !buildflags)
install=
source=("http://downloads.sourceforge.net/project/filezilla/FileZilla_Client/${pkgver}/FileZilla_${pkgver}_src.tar.bz2")
md5sums=('eee0a1bd902d23fe3ce5b4ddd7d6a6c9')

_architectures="i686-w64-mingw32 x86_64-w64-mingw32"

prepare() {
  cd "${_name}-${pkgver}"
  autoreconf -i
}

build() {
  for _arch in ${_architectures}; do
    mkdir -p "${srcdir}/${_name}-${pkgver}/build-${_arch}" && cd "${srcdir}/${_name}-${pkgver}/build-${_arch}"
    export PATH="/usr/${_arch}/bin:${PATH}"
    ${_arch}-configure \
      --disable-manualupdatecheck \
      --disable-autoupdatecheck \
      --with-pugixml=builtin \
      --with-wx-config="${_arch}-wx-config --static=no"
    make
  done
}

package() {
  for _arch in ${_architectures}; do
    cd "${srcdir}/${_name}-${pkgver}/build-${_arch}"
    export PATH="/usr/${_arch}/bin:${PATH}"
    make DESTDIR="${pkgdir}" install
    ${_arch}-strip --strip-all "${pkgdir}"/usr/${_arch}/bin/*.exe
    #${_arch}-strip --strip-unneeded "${pkgdir}"/usr/${_arch}/bin/*.dll
    #${_arch}-strip -g "${pkgdir}/usr/${_arch}/lib/"*.a
    rm -r "${pkgdir}/usr/${_arch}/share/"{icons,man,appdata,applications,pixmaps}
  done
}
