media-sound/hydrogen: x86 stable wrt bug #719012
[gentoo.git] / media-sound / timidity++ / timidity++-2.14.0-r3.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit autotools desktop elisp-common systemd toolchain-funcs user xdg-utils
7
8 MY_PV=${PV/_/-}
9 MY_P=TiMidity++-${MY_PV}
10 S=${WORKDIR}/${MY_P}
11
12 DESCRIPTION="A handy MIDI to WAV converter with OSS and ALSA output support"
13 HOMEPAGE="http://timidity.sourceforge.net/"
14 SRC_URI="mirror://sourceforge/timidity/${MY_P}.tar.xz"
15
16 LICENSE="GPL-2"
17 SLOT="0"
18 KEYWORDS="amd64 ~arm ~arm64 ~hppa ppc ppc64 sparc x86"
19 IUSE="alsa ao emacs flac gtk jack motif nas ncurses oss selinux slang speex tk vorbis X"
20
21 REQUIRED_USE="tk? ( X )"
22
23 DEPEND="
24         alsa? ( media-libs/alsa-lib )
25         ao? ( >=media-libs/libao-0.8.5 )
26         emacs? ( >=app-editors/emacs-23.1:* )
27         flac? ( media-libs/flac )
28         gtk? ( x11-libs/gtk+:2 )
29         jack? ( virtual/jack )
30         motif? ( >=x11-libs/motif-2.3:0 )
31         nas? ( >=media-libs/nas-1.4 )
32         ncurses? ( sys-libs/ncurses:0= )
33         slang? ( sys-libs/slang )
34         speex? ( media-libs/speex )
35         tk? ( dev-lang/tk:0= )
36         vorbis? ( media-libs/libvorbis )
37         X? (
38                 media-libs/libpng:0=
39                 x11-libs/libXaw
40                 x11-libs/libXext
41         )
42 "
43 RDEPEND="${DEPEND}
44         app-eselect/eselect-timidity
45         alsa? ( media-sound/alsa-utils )
46         selinux? ( sec-policy/selinux-timidity )
47 "
48
49 PDEPEND="|| ( media-sound/timidity-eawpatches media-sound/timidity-freepats )"
50
51 SITEFILE=50${PN}-gentoo.el
52
53 pkg_setup() {
54         enewgroup audio 18 # Just make sure it exists
55         enewuser timidity -1 -1 /var/lib/timidity audio
56 }
57
58 DOCS=( AUTHORS ChangeLog NEWS README "${FILESDIR}"/timidity.cfg-r1 )
59
60 PATCHES=(
61         "${FILESDIR}"/${P}-params.patch
62         "${FILESDIR}"/${P}-revert-for-required-ctl_speana_data-function.patch
63         "${FILESDIR}"/${P}-tcltk86.patch
64         "${FILESDIR}"/${P}-ar.patch
65         "${FILESDIR}"/${P}-configure-flags.patch
66         "${FILESDIR}"/${P}-pkg-config.patch
67         "${FILESDIR}"/${P}-CVE-2017-1154{6,7}.patch
68         "${FILESDIR}"/${P}-gcc5.patch # bug 606894
69 )
70
71 src_prepare() {
72         default
73         eautoreconf
74 }
75
76 src_configure() {
77         export EXTRACFLAGS="${CFLAGS}" #385817
78
79         local myconf=()
80         local audios
81
82         use flac && audios+=",flac"
83         use speex && audios+=",speex"
84         use vorbis && audios+=",vorbis"
85         use oss && audios+=",oss"
86         use jack && audios+=",jack"
87         use ao && audios+=",ao"
88
89         if use nas; then
90                 audios+=",nas"
91                 myconf+=( --with-nas-library="/usr/$(get_libdir)/libaudio.so" --with-x )
92                 use X || ewarn "Basic X11 support will be enabled because required by nas."
93         fi
94
95         if use alsa; then
96                 audios+=",alsa"
97                 myconf+=( --with-default-output=alsa --enable-alsaseq )
98         fi
99
100         # We disable motif by default and then only enable it if it's requested.
101         if use motif; then
102                 myconf+=( --enable-motif --with-x )
103                 use X || ewarn "Basic X11 support will be enabled because required by motif."
104         fi
105
106         econf \
107                 --localstatedir=/var/state/timidity++ \
108                 --with-module-dir="${EPREFIX}/usr/share/timidity" \
109                 --with-lispdir="${SITELISP}/${PN}" \
110                 --with-elf \
111                 --enable-audio=${audios} \
112                 --enable-server \
113                 --enable-network \
114                 --enable-dynamic \
115                 --enable-vt100 \
116                 --enable-spline=cubic \
117                 $(use_enable emacs) \
118                 $(use_enable slang) \
119                 $(use_enable ncurses) \
120                 $(use_with X x) \
121                 $(use_enable X spectrogram) \
122                 $(use_enable X wrd) \
123                 $(use_enable X xskin) \
124                 $(use_enable X xaw) \
125                 $(use_enable gtk) \
126                 $(use_enable tk tcltk) \
127                 --disable-motif \
128                 "${myconf[@]}"
129 }
130
131 src_install() {
132         emake DESTDIR="${D}" install
133         einstalldocs
134
135         # these are only for the ALSA sequencer mode
136         if use alsa; then
137                 newconfd "${FILESDIR}"/conf.d.timidity.2 timidity
138                 newinitd "${FILESDIR}"/init.d.timidity.4 timidity
139
140                 systemd_dounit "${FILESDIR}"/timidity.service
141         fi
142
143         insinto /etc
144         newins "${FILESDIR}"/timidity.cfg-r1 timidity.cfg
145
146         dodir /usr/share/timidity
147         dosym ../../../etc/timidity.cfg /usr/share/timidity/timidity.cfg
148
149         if use emacs; then
150                 elisp-site-file-install "${FILESDIR}/${SITEFILE}"
151         fi
152
153         diropts -o timidity -g nobody -m 0700
154         keepdir /var/lib/timidity
155
156         doicon "${FILESDIR}"/timidity.xpm
157         newmenu "${FILESDIR}"/timidity.desktop.2 timidity.desktop
158
159         # Order of preference: gtk, X (Xaw), ncurses, slang
160         # Do not create menu item for terminal ones
161         local interface="-id"
162         local terminal="true"
163         local nodisplay="true"
164         if use gtk || use X; then
165                 interface="-ia"
166                 terminal="false"
167                 nodisplay="false"
168                 use gtk && interface="-ig"
169         elif use ncurses || use slang; then
170                 local interface="-is"
171                 use ncurses && interface="-in"
172         fi
173         sed -e "s/Exec=timidity/Exec=timidity ${interface}/" \
174                 -e "s/Terminal=.*/Terminal=${terminal}/" \
175                 -e "s/NoDisplay=.*/NoDisplay=${nodisplay}/" \
176                 -i "${D}"/usr/share/applications/timidity.desktop || die
177 }
178
179 pkg_postinst() {
180         use emacs && elisp-site-regen
181
182         elog "A timidity config file has been installed in /etc/timidity.cfg."
183         elog "Do not edit this file as it will interfere with the eselect timidity tool."
184         elog "The tool 'eselect timidity' can be used to switch between installed patchsets."
185
186         if use alsa; then
187                 elog "An init script for the alsa timidity sequencer has been installed."
188                 elog "If you wish to use the timidity virtual sequencer, edit /etc/conf.d/timidity"
189                 elog "and run 'rc-update add timidity <runlevel> && /etc/init.d/timidity start'"
190         fi
191
192         if use sparc; then
193                 elog "Only saving to wave file and ALSA soundback has been tested working."
194         fi
195
196         xdg_desktop_database_update
197 }
198
199 pkg_postrm() {
200         use emacs && elisp-site-regen
201         xdg_desktop_database_update
202 }