# Copyright 2019-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake

DESCRIPTION="power spectrum for RTLSDR dongles"
HOMEPAGE="https://github.com/AD-Vega/rtl-power-fftw"

LICENSE="GPL-3"
SLOT="0"
if [ "${PV}" = "9999" ]; then
	inherit git-r3
	EGIT_REPO_URI="https://github.com/AD-Vega/rtl-power-fftw.git"
else
	KEYWORDS="~amd64 ~x86"
	COMMIT="cee9a22207ea995bd12adbc6bcfbec92521548b1"
	SRC_URI="https://github.com/AD-Vega/rtl-power-fftw/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"
	S="${WORKDIR}/${PN//_/-}-${COMMIT}"
fi

RDEPEND="dev-cpp/tclap
	sci-libs/fftw:3.0=
	net-wireless/rtl-sdr:="
DEPEND="${RDEPEND}
	virtual/pkgconfig"

src_prepare() {
	cmake_src_prepare
	# Remove the -O3 flag from CMakeLists.txt
	sed -i -e '/CMAKE_CXX_FLAGS_.*\-O3/s/-O3//' "${CMAKE_USE_DIR}/CMakeLists.txt" || die "sed failed!"
}

src_configure() {
	cmake_src_configure
}

src_compile() {
	cmake_src_compile
}