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

EAPI=8

LOMIRI_PACKAGING_COMMIT="6507e203e6e43326ab7493cdc7420ac340de21d0"
inherit vala lomiri

KEYWORDS="~amd64"
SRC_URI="https://releases.ayatana-indicators.org/source/${PN}/${P}.tar.gz
         https://github.com/AyatanaIndicators/${PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz
         ${LOMIRI_PACKAGING_URI}"

DESCRIPTION="Ayatana System Indicator for Bluetooth Management"
HOMEPAGE="https://github.com/AyatanaIndicators/${PN}"
LICENSE="GPL-3"
SLOT="0"
RESTRICT="test mirror"

DEPEND="
    dev-libs/glib
    gui-libs/libayatana-common
    sys-apps/systemd
"
RDEPEND="${DEPEND}"

BDEPEND="
    dev-build/cmake
    dev-build/cmake-extras
    $(vala_depend)
"

src_prepare() {
    eapply_user

    vala_setup

    # fix hard coded name 'FindVala.cmake' -> maybe we should disable this file
    sed -i "s:find_program (VALA_COMPILER \"valac\"):find_program (VALA_COMPILER \"valac-$(vala_best_api_version)\"):" cmake/FindVala.cmake || die
    sed -i "s:find_program (VAPI_GEN \"vapigen\"):find_program (VAPI_GEN \"vapigen-$(vala_best_api_version)\"):" cmake/FindVala.cmake || die

    lomiri_src_prepare
}

src_configure() {
    local mycmakeargs=(
        -DENABLE_WERROR=ON
    )

    lomiri_src_configure
}

src_install() {
    lomiri_src_install

    # create 'service,wants' symlinks
    dosym /usr/lib/systemd/user/ayatana-indicator-bluetooth.service \
        /usr/lib/systemd/user/lomiri-indicators.target.wants/ayatana-indicator-bluetooth.service
    dosym /usr/lib/systemd/user/ayatana-indicator-bluetooth.service \
        /usr/lib/systemd/user/ayatana-indicators.target.wants/ayatana-indicator-bluetooth.service
}