SUMMARY="Portable and multi-interface IRC client"
DESCRIPTION="WeeChat (Wee Enhanced Environment for Chat) is a free chat \
client, fast and light, designed for many operating systems. \
It is highly customizable and extensible with scripts."
HOMEPAGE="https://weechat.org/"
COPYRIGHT="2003-2019 Sébastien Helleu"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/weechat/weechat/archive/v$portVersion.tar.gz"
SOURCE_FILENAME="weechat-$portVersion.tar.gz"
CHECKSUM_SHA256="a9834f84d8b6b37bcea107fe5a283699f1312da6df9dd70d675e70df65cee7c9"

ARCHITECTURES="all !x86_gcc2"
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
fi

PROVIDES="
	weechat$secondaryArchSuffix = $portVersion
	cmd:weechat
	cmd:weechat_curses
	cmd:weechat_headless
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libgcrypt$secondaryArchSuffix
	lib:libgnutls$secondaryArchSuffix
	lib:libgpg_error$secondaryArchSuffix # for libgcrypt
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:liblua$secondaryArchSuffix >= 5.3
	lib:libncurses$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	weechat${secondaryArchSuffix}_devel = $portVersion compat >= 1
	"
REQUIRES_devel="
	weechat$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcurl$secondaryArchSuffix
	devel:libgcrypt$secondaryArchSuffix
	devel:libgnutls$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:liblua$secondaryArchSuffix >= 5.3
	devel:libncurses$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cmake -B build -S . -DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DLIBDIR=$libDir \
		-DINCLUDEDIR=$includeDir \
		-DDATAROOTDIR=$dataDir \
		-DWEECHAT_HOME=~/config/settings/weechat \
		-DENABLE_GUILE=OFF \
		-DENABLE_JAVASCRIPT=OFF \
		-DENABLE_MAN=OFF \
		-DENABLE_PERL=OFF \
		-DENABLE_PHP=OFF \
		-DENABLE_PYTHON=OFF \
		-DENABLE_RUBY=OFF \
		-DENABLE_SPELL=OFF \
		-DENABLE_TCL=OFF -L
	make -C build $jobArgs
}

INSTALL()
{
	make -C build install

	rm -rf "$dataDir"/{applications,icons}

	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
