SUMMARY="A graphics and text mode web browser"
DESCRIPTION="Links is a multi-platform web browser you can run in Terminal."
HOMEPAGE="http://links.twibright.com/"
COPYRIGHT="1999-2020 Mikulas Patocka
	2000-2011 Petr Kulhavy, Karel Kulhavy, Martin Pergel"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="http://links.twibright.com/download/links-$portVersion.tar.bz2"
CHECKSUM_SHA256="285eed8591c7781ec26213df82786665aaa1b9286782e8a7a1a7e2a6e1630d63"

PATCHES="links-$portVersion.patchset"
ADDITIONAL_FILES="links.rdef.in"

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

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

USER_SETTINGS_FILES="
	settings/links directory
	"

PROVIDES="
	links$secondaryArchSuffix = $portVersion
	cmd:links$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbrotlicommon$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libevent_2.1$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:liblzma$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbrotlicommon$secondaryArchSuffix
	devel:libbz2$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libevent_2.1$secondaryArchSuffix
	devel:libfontconfig$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libglu$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:liblzma$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoreconf
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage links$secondaryArchSuffix \
	"$commandBinDir"/links

BUILD()
{
	autoreconf -vfi
	runConfigure --omit-dirs binDir ./configure \
		--bindir="$commandBinDir" \
		--without-x \
		--with-haiku \
		--with-ssl \
		--enable-graphics
	make $jobArgs
}

INSTALL()
{
	make install

	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="0"
	sed \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		$portDir/additional-files/links.rdef.in > links.rdef

	addResourcesToBinaries links.rdef $commandBinDir/links
	addAppDeskbarSymlink $commandBinDir/links Links
}
