SUMMARY="A tool for downloading files from the internet"
DESCRIPTION="wget is a tool that can download files from the internet through \
protocols such as HTTP, HTTPS and FTP. wget is non-interactive, so it can be \
called from scripts."
HOMEPAGE="https://www.gnu.org/software/wget/"
COPYRIGHT="1996-2018 Free Software Foundation"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://ftpmirror.gnu.org/wget/wget-$portVersion.tar.gz"
CHECKSUM_SHA256="59ba0bdade9ad135eda581ae4e59a7a9f25e3a4bde6a5419632b31906120e26e"
PATCHES="wget-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86 x86_gcc2"

GLOBAL_WRITABLE_FILES="
	settings/wgetrc keep-old
	"
USER_SETTINGS_FILES="
	settings/wgetrc
	"

PROVIDES="
	wget$secondaryArchSuffix = $portVersion
	cmd:wget$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix >= 1.2.3
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:gettext
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:makeinfo
	cmd:pkg_config$secondaryArchSuffix
	cmd:pod2man
	"

BUILD()
{
	AUTOPOINT=true autoreconf -fi
	runConfigure ./configure --with-ssl=openssl
	make
}

INSTALL()
{
	make install
	# Tells wget where to find certificates
	echo "ca_certificate=/boot/system/data/ssl/CARootCertificates.pem" > $settingsDir/wgetrc
	rm -f "$infoDir"/dir
	rm -f "$libDir"/charset.alias
}

TEST()
{
	[ -d .git ] && mv .git .git-temp
	make check || true
	[ -d .git-temp ] && mv .git-temp .git
}
