summaryrefslogtreecommitdiff
blob: e3538ad7031b7e0216ae9bc37b1369786c17e880 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Copyright 2022-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit autotools toolchain-funcs

DESCRIPTION="Console-based Audio Visualizer for Alsa"
HOMEPAGE="https://github.com/karlstav/cava/"
SRC_URI="
	https://github.com/karlstav/cava/archive/refs/tags/${PV}.tar.gz
		-> ${P}.tar.gz
"

LICENSE="MIT Unlicense"
SLOT="0"
KEYWORDS="amd64 x86"
IUSE="alsa jack +ncurses pipewire portaudio pulseaudio sdl sndio"

RDEPEND="
	dev-libs/iniparser:4
	sci-libs/fftw:3.0=
	alsa? ( media-libs/alsa-lib )
	jack? ( virtual/jack )
	ncurses? ( sys-libs/ncurses:= )
	pipewire? ( media-video/pipewire:= )
	portaudio? ( media-libs/portaudio )
	pulseaudio? ( media-libs/libpulse )
	sdl? (
		media-libs/libglvnd
		media-libs/libsdl2[opengl,video]
	)
	sndio? ( media-sound/sndio:= )
"
DEPEND="${RDEPEND}"
# bug #941845 wrt autoconf-archive bounds
BDEPEND="
	virtual/pkgconfig
	sdl? (
		|| (
			>dev-build/autoconf-archive-2024.10.16
			<dev-build/autoconf-archive-2024.10.16
		)
	)
"

src_prepare() {
	# TODO: depend on >=4.2.2 and remove after 4.2.2 is stable unless bug
	# #933610 reintroduces slotting hacks (also drop GENTOO_SYSROOT below)
	has_version '<dev-libs/iniparser-4.2.2:4' &&
		eapply "${FILESDIR}"/${PN}-0.8.0-gentoo-iniparser4.patch

	default

	# TODO: drop this when autoconf-archive is fixed (bug #941845), this is
	# to handle the USE=-sdl case given it breaks it present
	use sdl || sed -i 's/AX_CHECK_GL/&_DISABLED/' configure.ac || die

	echo ${PV} > version || die
	eautoreconf
}

src_configure() {
	local econfargs=(
		$(use_enable alsa input-alsa)
		$(use_enable jack input-jack)
		$(use_enable pipewire input-pipewire)
		$(use_enable portaudio input-portaudio)
		$(use_enable pulseaudio input-pulse)
		$(use_enable sndio input-sndio)

		$(use_enable ncurses output-ncurses)
		$(use_enable sdl output-sdl)
		# note: not behind USE=opengl and sdl2[opengl?] given have not gotten
		# normal output-sdl to work without USE=opengl on sdl either way
		$(use_enable sdl output-sdl_glsl)

		GENTOO_SYSROOT="${ESYSROOT}" # see iniparser4.patch
	)

	# autoconf-archive (currently) does not support -lOpenGL for libglvnd[-X]
	use sdl && econfargs+=( GL_LIBS="$($(tc-getPKG_CONFIG) --libs opengl || die)" )

	econf "${econfargs[@]}"
}

pkg_postinst() {
	if [[ ! ${REPLACING_VERSIONS##* } ]]; then
		elog "A default ~/.config/cava/config will be created after initial"
		elog "use of ${PN}, see it and ${EROOT}/usr/share/doc/${PF}/README*"
		elog "for configuring audio input and more."
	elif ver_test ${REPLACING_VERSIONS##* } -lt 0.9; then
		elog "If used, the noise_reduction config option in ~/.config/cava/config needs"
		elog "to be updated from taking a float to integer (e.g. replace 0.77 with 77)."
	fi
}