SUMMARY="Program for filesharing using Direct Connect and ADC protocols"
DESCRIPTION="EiskaltDC++ is a cross-platform program that uses the Direct \
Connect and Advanced Direct Connect protocols. It is compatible with DC++, \
AirDC++, FlylinkDC++ and other DC clients. EiskaltDC++ also interoperates with \
all common DC hub software."
HOMEPAGE="https://github.com/eiskaltdcpp/eiskaltdcpp"
COPYRIGHT="EiskaltDC++ team"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/eiskaltdcpp/eiskaltdcpp/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="2ed853a57c57aab0e87fdea273a01707184ee425a2aaf9fcd2e0a32c57a2de2c"
SOURCE_DIR="eiskaltdcpp-$portVersion"
ADDITIONAL_FILES="eiskaltdcpp.rdef.in"

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

PROVIDES="
	eiskaltdcpp$secondaryArchSuffix = $portVersion
	app:EiskaltDC++ = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libidn$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:liblua$secondaryArchSuffix
	lib:libminiupnpc$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffi
	lib:libQt5Concurrent$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Multimedia$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libgl$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libidn$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:liblua$secondaryArchSuffix
	devel:libminiupnpc$secondaryArchSuffix
	devel:libpcre$secondaryArchSuffix
	devel:libQt5Concurrent$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libQt5Xml$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

PATCH()
{
	# Use haiku iconset by default
	pushd $sourceDir/eiskaltdcpp-qt/icons/appl
	mv default standard
	mv standard/default.qrc standard/standard.qrc
	mv haiku default
	mv default/haiku.qrc default/default.qrc
	popd
}

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DCMAKE_INSTALL_PREFIX:PATH=$appsDir/Eiskaltdcpp \
		-DCMAKE_BUILD_TYPE=Release \
		-DLUA_INCLUDE_DIR="`pkg-config --variable=includedir lua`" \
		-DJSONRPC_DAEMON=OFF \
		-DWITH_LUASCRIPTS=ON \
		-DWITH_EXAMPLES=OFF \
		-DUSE_ASPELL=OFF \
		-DDBUS_NOTIFY=OFF
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

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

	addResourcesToBinaries eiskaltdcpp.rdef $appsDir/Eiskaltdcpp/EiskaltDC++
	addAppDeskbarSymlink $appsDir/Eiskaltdcpp/EiskaltDC++
}
