SUMMARY="An offline browser utility"
DESCRIPTION="HTTrack is an offline browser utility, allowing you to download a World Wide \
website from the Internet to a local directory, building recursively all directories, \
getting html, images, and other files from the server to your computer.

HTTrack arranges the original site's relative link-structure. Simply open a page of \
the \"mirrored\" website in your browser, and you can browse the site from link to link, \
as if you were viewing it online.

HTTrack can also update an existing mirrored site, and resume interrupted downloads. \
HTTrack is fully configurable, and has an integrated help system."
HOMEPAGE="https://www.httrack.com/"
COPYRIGHT="Xavier Roche"
LICENSE="GNU GPL v3"
REVISION="4"
SOURCE_URI="https://mirror.httrack.com/httrack-$portVersion.tar.gz"
CHECKSUM_SHA256="3477a0e5568e241c63c9899accbfcdb6aadef2812fcce0173688567b4c7d4025"
SOURCE_DIR="httrack-$portVersion"
PATCHES="httrack-$portVersion.patchset"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

libVersion="2.0.49"

PROVIDES="
	httrack$secondaryArchSuffix = $portVersion
	cmd:webhttrack$commandSuffix = $portVersion
	cmd:proxytrack$commandSuffix = $portVersion
	cmd:httrack$commandSuffix = $portVersion
	cmd:htsserver$commandSuffix = $portVersion
	lib:libhttrack$secondaryArchSuffix = $libVersion compat >= 2
	lib:libhtsjava$secondaryArchSuffix = $libVersion compat >= 2
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	httrack${secondaryArchSuffix}_devel = $portVersion
	devel:libhttrack$secondaryArchSuffix = $libVersion compat >= 2
	devel:libhtsjava$secondaryArchSuffix = $libVersion compat >= 2
	"
REQUIRES_devel="
	httrack${secondaryArchSuffix} == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gawk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	export LIBS="-lnetwork -liconv"
	runConfigure ./configure \
		--bindir=$commandBinDir \
		--enable-static=no \
		--enable-https=yes
	make $jobArgs
}

INSTALL()
{
	make install

	rm -rf $libDir/*.la \
		$libDir/httrack/*.la \
		$prefix/share

	prepareInstalledDevelLibs libhttrack libhtsjava
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
