# Copyright 2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake git-r3 udev

DESCRIPTION="Command line tool to print labels on Brother P-Touch printers"
HOMEPAGE="https://dominic.familie-radermacher.ch/projekte/ptouch-print/"

EGIT_REPO_URI="https://git.familie-radermacher.ch/linux/ptouch-print.git"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS=""

# deps from CMakeLists.txt and guessing
DEPEND="
	virtual/libusb:1
	media-libs/gd:2=
	virtual/libintl
"
RDEPEND="${DEPEND}"
# VDB says no for gettext, so maybe bdepend?
BDEPEND="
	sys-devel/gettext
	dev-vcs/git
	virtual/pkgconfig
"

PATCHES=(
	"${FILESDIR}/0001-don-t-install-udev-automatically.patch"
	#"${FILESDIR}/0002-do-not-auto-version.patch"
)

# disable the manual version thing, because not sure how to get commit hash
# from git this way. so fallback to whatever upstream does, like N/A.r.gN/A
#
#src_configure() {
#	default
#	cmake_src_configure
#
#	# cmake's BUILD_DIR
#	# manually add version, won't match upstream
#	echo "#define VERSION \"${PV}\"" > "${BUILD_DIR}/version.h"
#}

src_install() {
	cmake_src_install
	udev_dorules udev/20-usb-ptouch-permissions.rules
}

pkg_postinst() {
	udev_reload
}

pkg_postrm() {
	udev_reload
}