summaryrefslogtreecommitdiff
blob: 8cd665ace6bda2bee59a2990144ae3030909ebf9 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

DISTUTILS_OPTIONAL=1
PYTHON_COMPAT=( python3_{9..11} )
PYTHON_REQ_USE='threads(+)'
inherit distutils-r1 waf-utils

DESCRIPTION="Library for audio labelling"
HOMEPAGE="https://aubio.org/"
SRC_URI="https://aubio.org/pub/${P}.tar.bz2"

LICENSE="GPL-3"
SLOT="0/5"
KEYWORDS="amd64 ~ppc ppc64 sparc x86"
IUSE="doc double-precision examples ffmpeg fftw jack libsamplerate sndfile python test"

REQUIRED_USE="${PYTHON_REQUIRED_USE}
	?? ( double-precision libsamplerate )
	doc? ( python )
"

RESTRICT="!test? ( test )"

RDEPEND="
	ffmpeg? ( >=media-video/ffmpeg-2.6:0= )
	fftw? ( sci-libs/fftw:3.0= )
	jack? ( virtual/jack )
	libsamplerate? ( media-libs/libsamplerate )
	python? (
		${PYTHON_DEPS}
		dev-python/numpy[${PYTHON_USEDEP}]
	)
	sndfile? ( media-libs/libsndfile )
"

DEPEND="${RDEPEND}
	${PYTHON_DEPS}
	app-text/txt2man
	virtual/pkgconfig
	doc? (
		app-doc/doxygen
		dev-python/sphinx
	)
"

DOCS=( AUTHORS ChangeLog README.md )
PYTHON_SRC_DIR="${S}"

PATCHES=(
	"${FILESDIR}"/${PN}-0.4.9-docdir.patch
	"${FILESDIR}"/ffmpeg5.patch
	"${FILESDIR}"/${PN}-0.4.9-remove-universal-newlines.patch
)

src_prepare() {
	default

	sed -e "s:doxygen:doxygen_disabled:" -i wscript || die

	sed -e "s/, 'sphinx.ext.intersphinx'//" -i doc/conf.py || die

	# ERROR: "Skipped: no test sounds, add some in 'python/tests/sounds/'!"
	rm python/tests/test_source.py || die

	if ! use test; then
		sed -e "/bld.*tests/d" -i wscript || die
	fi
}

src_configure() {
	python_setup

	local mywafconfargs=(
		--enable-complex
		--docdir="${EPREFIX}"/usr/share/doc/${PF}
		$(use_enable doc docs)
		$(use_enable double-precision double)
		$(use_enable fftw fftw3)
		$(use_enable ffmpeg avcodec)
		$(use_enable jack)
		$(use_enable libsamplerate samplerate)
		$(use_enable sndfile)
	)

	use double-precision || mywafconfargs+=( $(use_enable fftw fftw3f) )

	waf-utils_src_configure "${mywafconfargs[@]}"

	if use python ; then
		cd "${PYTHON_SRC_DIR}" || die
		distutils-r1_src_configure
	fi
}

src_compile() {
	waf-utils_src_compile --notests

	if use python ; then
		cd "${PYTHON_SRC_DIR}" || die
		distutils-r1_src_compile

		if use doc ; then
			# No API function like distutils_install_for_testing available for this use case
			pushd "${S}"/doc &>/dev/null || die
			python_setup
			LD_LIBRARY_PATH="${S}/build/src:${LD_LIBRARY_PATH}" \
			PYTHONPATH="${S%%/}-${EPYTHON/./_}/lib${PYTHONPATH:+:${PYTHONPATH}}" \
			emake dirhtml
		fi

		cd "${S}" || die
	fi
}

src_test() {
	waf-utils_src_compile --alltests

	if use python ; then
		cd "${PYTHON_SRC_DIR}" || die
		distutils-r1_src_test
	fi
}

python_test() {
	 LD_LIBRARY_PATH="${S}/build/src:${LD_LIBRARY_PATH}" eunittest python/tests
}

src_install() {
	waf-utils_src_install

	if use examples; then
		# install dist_noinst_SCRIPTS from Makefile.am
		dodoc -r examples
	fi

	if use python ; then
		cd "${PYTHON_SRC_DIR}" || die
		DOCS="" distutils-r1_src_install
		newdoc python/README.md README.python
	fi

	if use doc; then
		dodoc doc/*.txt
		docinto html
		dodoc -r doc/_build/dirhtml/.
	fi

	find "${ED}" -name "*.a" -delete || die
}