#Packager: Dimitris Tzemos <dijemos@gmail.com>

pkgname=filezilla
pkgver=3.66.4
pkgrel=2dj
source=("https://download.filezilla-project.org/client/FileZilla_${pkgver}_src.tar.xz" " filezilla.desktop" "interface_Mainfrm_h_include_list.patch")
docs=("AUTHORS" "COPYING" "ChangeLog" "INSTALL" "NEWS" "README" "GPL.html")
url=http://filezilla-project.org/

slackdesc=\
(
#|-----handy-ruler----------------------------------------------|
"filezilla (the free FTP solution)"
"FileZilla is a fast and reliable cross-platform FTP, FTPS, and"
"SFTP client with lots of useful features and an intuitive user"
"interface."
"http://filezilla-project.org/"
)


build() {
	# Check if we have pugixml package
	if [ "${PUGIXML:-no}" = "yes" ]; then
		pugixml="--with-pugixml=system"
	else
		pugixml="--with-pugixml=builtin"
	fi

	case "$arch" in
	i?86)
		# fails to build otherwise
		export CFLAGS="$CFLAGS -D_FORCE_SOFTWARE_SHA "
		;;
	esac
	#CXXFLAGS="$SLKCFLAGS -mno-sse " \
	#SLKCFLAGS="$SLKCFLAGS -mno-sse "
	cd $startdir/src/$pkgname-$pkgver
	
	# patched autoconf
	NOCONFIGURE=1 autoreconf -vif
	# Needed for gcc >= 10.x
	patch -p1 < $startdir/src/interface_Mainfrm_h_include_list.patch || return 1
	
	FLAGS="$SLKCFLAGS" \
	CXXFLAGS="$SLKCFLAGS" \
	./configure --prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--libdir=/usr/lib${LIBDIRSUFFIX} \
		--mandir=/usr/man \
		--disable-static \
		--disable-manualupdatecheck \
		--disable-autoupdatecheck \
		--enable-locales \
		$pugixml \
		--with-wx-config=/usr/bin/wx-config \
		--build=$arch-slackware-linux || return 1
	
	make || return 1
	make install DESTDIR=$startdir/pkg
	
	mkdir -p $startdir/pkg/usr/doc/$pkgname-$pkgver
	mv $startdir/pkg/usr/share/filezilla/docs/fzdefaults.xml.example $startdir/pkg/usr/doc/$pkgname-$pkgver || return 1
	# remove empty docdir
	rmdir $startdir/pkg/usr/share/filezilla/docs || return 1

	# Use our own .desktop which has no BOM characters
	cp $startdir/src/filezilla.desktop $startdir/pkg/usr/share/applications/ || return 1
	mkdir -p $startdir/pkg/usr/share/icons/hicolor/32x32/apps
	mkdir -p $startdir/pkg/usr/share/icons/hicolor/48x48/apps
	cp $startdir/src/$pkgname-$pkgver/src/interface/resources/32x32/filezilla.png $startdir/pkg/usr/share/icons/hicolor/32x32/apps
	cp $startdir/src/$pkgname-$pkgver/src/interface/resources/48x48/filezilla.png $startdir/pkg/usr/share/icons/hicolor/48x48/apps
}
