# Copyright 1999-2025 Gentoo Authors
# Copyright 2026 Bryan Gardiner <bog@khumba.net>
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake desktop xdg

GIT_REV=f9df1bb11706cf2b3bc3d3a766c3d6b011370cbb

DESCRIPTION="Texas Hold'em poker game"
HOMEPAGE="https://www.pokerth.net/"
SRC_URI="https://github.com/pokerth/pokerth/archive/${GIT_REV}.tar.gz -> ${P}.tar.gz"

LICENSE="AGPL-3 GPL-1 GPL-2 GPL-3 BitstreamVera public-domain"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

RDEPEND="
	dev-libs/boost:=[zlib]
	dev-libs/libgcrypt:0
	dev-libs/protobuf:0=
	dev-libs/tinyxml[stl]
	dev-qt/qtbase:6[gui,network,sql,widgets]
	dev-qt/qtmultimedia:6
	dev-qt/qtsvg:6
	dev-qt/qtwebsockets:6
	>=net-libs/libircclient-1.6-r2
"
DEPEND="${RDEPEND}
	dev-cpp/websocketpp
"
BDEPEND="virtual/pkgconfig"

S="${WORKDIR}/${PN}-${GIT_REV}"

PATCHES=(
	# unbundle dev-cpp/websocketpp
	"${FILESDIR}"/${PN}-2.0_pre20260130-system-websockets.patch
	"${FILESDIR}"/${PN}-2.0_pre20260130-protobuf-build.patch
	"${FILESDIR}"/${PN}-2.0_pre20260130-skip-qml-ui.patch
)

src_prepare() {
	# delete bundled dev-cpp/websocketpp to be safe
	rm -r src/third_party/websocketpp || die

	eapply_user
	cmake_src_prepare
}

src_install() {
	cmake_src_install

	dolib.so "${BUILD_DIR}"/libpokerth_db{,official}.so

	dodoc docs/{gui_styling,server_setup}_howto.txt
	doman docs/pokerth.1
}