SUMMARY="A sophisticated file transfer program"
DESCRIPTION="lftp is a sophisticated file transfer program with command line \
interface. It supports FTP, HTTP, FISH, SFTP and FILE (local FS) protocols. \
GNU Readline library is used for input. BitTorrent protocol is supported as \
built-in torrent command.
Low level stuff supported: ftp proxy, http proxy, ftp over http, opie/skey, \
fxp transfers, automatic retrying on non-fatal errors and timeouts, ipv6, \
socks, http/1.1, sftp v3-v6."
HOMEPAGE="http://lftp.yar.ru"
COPYRIGHT="1996-2017 Alexander V. Lukyanov"
LICENSE="GNU GPL v3"
REVISION="4"
SOURCE_URI="http://lftp.yar.ru/ftp/lftp-$portVersion.tar.gz"
CHECKSUM_SHA256="19f3a4236558fbdb88eec01bc9d693c51b122d23487b6bedad4cc67ae6825fc2"
PATCHES="lftp-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2 ?x86 ?arm"
SECONDARY_ARCHITECTURES="x86"

GLOBAL_WRITABLE_FILES="
	settings/lftp.conf keep-old
	"

PROVIDES="
	lftp$secondaryArchSuffix = $portVersion
	cmd:lftp$secondaryArchSuffix = $portVersion compat >= 4
	cmd:lftpget$secondaryArchSuffix = $portVersion compat >= 4
	lib:liblftp_jobs$secondaryArchSuffix = 0.0.0 compat >= 0
	lib:liblftp_tasks$secondaryArchSuffix = 0.0.0 compat >= 0
		"
REQUIRES="
	haiku$secondaryArchSuffix
	ca_root_certificates
	lib:libcrypto$secondaryArchSuffix
	lib:libexpat$secondaryArchSuffix
	lib:libgnutls$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	lftp${secondaryArchSuffix}_devel = $portVersion
	devel:liblftp_jobs$secondaryArchSuffix = 0.0.0 compat >= 0
	devel:liblftp_tasks$secondaryArchSuffix = 0.0.0 compat >= 0
	"
REQUIRES_devel="
	lftp$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libexpat$secondaryArchSuffix
	devel:libgnutls$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix >= 8
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:awk
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

BUILD()
{
	autoreconf -vfi
	runConfigure ./configure --with-openssl --enable-static --with-readline \
		--with-readline-lib=-lreadline \
		--with-readline-inc="$(finddir B_SYSTEM_HEADERS_DIRECTORY)$secondaryArchSubDir/readline" \
		--with-modules --disable-nls
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/*.la
	# prepare develop/lib
	prepareInstalledDevelLibs liblftp-jobs liblftp-tasks
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
