# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{10..15} )

inherit git-r3 python-single-r1 xdg

DESCRIPTION="Fully-featured audio plugin host (LADSPA, DSSI, LV2, VST2/3, AU)"
HOMEPAGE="https://kx.studio/Applications:Carla https://github.com/falkTX/Carla"
EGIT_REPO_URI="https://github.com/falkTX/Carla.git"
EGIT_BRANCH="main"

LICENSE="GPL-2+"
SLOT="0"
KEYWORDS=""
IUSE="alsa fluidsynth jack ladspa-rdflib pulseaudio +qt6 X"
REQUIRED_USE="${PYTHON_REQUIRED_USE}"

RDEPEND="
	${PYTHON_DEPS}
	$(python_gen_cond_dep '
		dev-python/pyqt6[gui,svg,widgets,${PYTHON_USEDEP}]
	')
	sys-apps/file
	media-libs/liblo
	alsa? ( media-libs/alsa-lib )
	fluidsynth? ( media-sound/fluidsynth:= )
	jack? ( virtual/jack )
	ladspa-rdflib? ( $(python_gen_cond_dep 'dev-python/rdflib[${PYTHON_USEDEP}]') )
	pulseaudio? ( media-libs/libpulse )
	qt6? (
		dev-qt/qtbase:6[gui,widgets]
		dev-qt/qtsvg:6
	)
	X? (
		x11-libs/libX11
		x11-libs/libXcursor
		x11-libs/libXext
	)
"
DEPEND="${RDEPEND}"
BDEPEND="
	${PYTHON_DEPS}
	$(python_gen_cond_dep '
		dev-python/pyqt6[gui,svg,widgets,${PYTHON_USEDEP}]
	')
	virtual/pkgconfig
"

RESTRICT="test"

pkg_setup() {
	python-single-r1_pkg_setup
}

src_compile() {
	emake \
		PREFIX="/usr" \
		NOOPT=1 \
		DEBUG=0
}

src_install() {
	emake \
		PREFIX="/usr" \
		DESTDIR="${D}" \
		install

	einstalldocs
}

pkg_postinst() {
	xdg_pkg_postinst
}

pkg_postrm() {
	xdg_pkg_postrm
}