summaryrefslogtreecommitdiff
path: root/media-sound/snd/snd-26.4.ebuild
blob: 677a2c2856f208e1976048014c9e9e5197925de2 (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit autotools desktop flag-o-matic optfeature toolchain-funcs

DESCRIPTION="Sound editor"
HOMEPAGE="https://ccrma.stanford.edu/software/snd/"
SRC_URI="https://ccrma.stanford.edu/software/${PN}/${P}.tar.gz"

LICENSE="Snd 0BSD BSD-2 HPND GPL-2+ LGPL-2.1+ LGPL-3+"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~x86"
# alsa may be optional too but at-most-one with pulseaudio breaks profiles
IUSE="fftw gmp gsl gui jack ladspa notcurses opengl oss portaudio pulseaudio ruby +s7"
REQUIRED_USE="
	?? ( jack oss pulseaudio portaudio )
	?? ( gui notcurses )
	?? ( ruby s7 )
	notcurses? ( s7 )
"

RDEPEND="
	media-libs/alsa-lib
	fftw? ( sci-libs/fftw:3.0= )
	gmp? (
		dev-libs/gmp:=
		dev-libs/mpc:=
		dev-libs/mpfr:=
	)
	gsl? ( sci-libs/gsl:= )
	gui? (
		x11-libs/motif:0=
		x11-libs/libX11
		x11-libs/libXext
		x11-libs/libXft
		x11-libs/libXpm
		x11-libs/libXt
		opengl? (
			media-libs/glu
			media-libs/libglvnd[X]
		)
	)
	jack? (
		media-libs/libsamplerate
		virtual/jack
	)
	ladspa? ( media-libs/ladspa-sdk )
	notcurses? ( dev-cpp/notcurses )
	portaudio? ( media-libs/portaudio )
	pulseaudio? ( media-libs/libpulse )
	ruby? ( dev-lang/ruby:* )
"
DEPEND="${RDEPEND}"
BDEPEND="virtual/pkgconfig"

src_prepare() {
	default

	# upstream searches <=ruby-3.0, try forcing with latest ruby version
	if use ruby; then
		local ruby_ver="$(best_version dev-lang/ruby | sed 's/.*\(ruby-[0-9]\+\.[0-9]\+\).*/\1/')"
		sed -e "s/m4_foreach(\[ruby_version\].*/m4_foreach([ruby_version], [[${ruby_ver}]],/" \
			-i configure.ac || die
	fi

	sed -i -e "s:-O2 ::" configure.ac || die
	eautoreconf
}

src_configure() {
	# -Wincompatible-pointer-types
	use ruby && append-cflags -std=gnu17

	# fix s7 bindings exporting s7_f symbols
	use s7 && append-ldflags -Wl,--export-dynamic

	export ac_cv_path_PKG_CONFIG="$(tc-getPKG_CONFIG)"

	# define the path for all tools instead of automagic
	local tools=(
		oggdec
		oggenc
		mpg123
		flac
		speexdec
		speexenc
		timidity
		wavpack
		wvunpack
	)
	local tool
	for tool in "${tools[@]}"; do
		export ac_cv_path_PATH_${tool^^}="${EPREFIX}/usr/bin/${tool}"
	done

	local myeconfargs=(
		$(use_with fftw)
		$(use_with gmp)
		$(use_with gsl)
		$(use_with gui)
		$(use_with jack)
		$(use_with ladspa)
		$(use_with notcurses)
		$(use_with oss)
		$(use_with portaudio)
		$(use_with pulseaudio)
		$(use_with ruby)
		$(use_with s7)
	)

	if use gui && use opengl; then
		# -Werror=lto-type-mismatch
		filter-lto
		myeconfargs+=( --with-gl )
	else
		myeconfargs+=( --without-gl )
	fi

	# determine audio backend and use alsa as a fallback
	if use oss || use portaudio || use pulseaudio; then
		myeconfargs+=( --without-alsa )
	else
		# jack and alsa can be used together
		myeconfargs+=( --with-alsa )
	fi

	if ! use ruby && ! use s7 ; then
		myeconfargs+=( --without-extension-language )
	fi

	econf "${myeconfargs[@]}"
}

src_compile() {
	emake snd

	# Do not compile ruby extensions for command line programs since they fail
	if use ruby; then
		sed -i -e "s:HAVE_RUBY 1:HAVE_RUBY 0:" mus-config.h || die
	fi

	emake sndplay sndinfo
}

src_install() {
	dobin snd sndplay sndinfo

	if use gui; then
		newicon pix/s.png ${PN}.png
		make_desktop_entry --eapi9 ${PN} -C "sound editor" -c "AudioVideo;AudioVideoEditing"
	fi

	if use ruby ; then
		insinto /usr/share/snd
		doins *.rb
	fi

	if use s7 ; then
		insinto /usr/share/snd
		doins *.scm s7.h
	fi

	doman snd.1

	local DOCS=( *.Snd NEWS )
	local HTML_DOCS=( *.html pix/*.png )
	einstalldocs
}

pkg_postinst() {
	optfeature_header "converting in audio formats:"
	optfeature flac media-libs/flac
	optfeature MIDI media-sound/timidity++
	optfeature MPEG media-sound/mpg123-base
	optfeature Ogg media-sound/vorbis-tools
	optfeature Speex media-libs/speex[utils]
	optfeature WavPack media-sound/wavpack
}