mate-extra/mate-power-manager: x86 stable wrt bug #573048
[gentoo.git] / media-sound / pulseaudio / pulseaudio-7.1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 inherit autotools bash-completion-r1 eutils flag-o-matic gnome2-utils linux-info readme.gentoo systemd user versionator udev multilib-minimal
7
8 DESCRIPTION="A networked sound server with an advanced plugin system"
9 HOMEPAGE="http://www.pulseaudio.org/"
10 SRC_URI="http://freedesktop.org/software/pulseaudio/releases/${P}.tar.xz"
11
12 # libpulse-simple and libpulse link to libpulse-core; this is daemon's
13 # library and can link to gdbm and other GPL-only libraries. In this
14 # cases, we have a fully GPL-2 package. Leaving the rest of the
15 # GPL-forcing USE flags for those who use them.
16 LICENSE="!gdbm? ( LGPL-2.1 ) gdbm? ( GPL-2 )"
17
18 SLOT="0"
19 KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 ~sh sparc x86 ~amd64-fbsd ~amd64-linux ~x86-linux"
20
21 # +alsa-plugin as discussed in bug #519530
22 IUSE="+alsa +alsa-plugin +asyncns bluetooth +caps dbus doc equalizer +gdbm +glib
23 gnome gtk ipv6 jack libsamplerate libressl lirc native-headset neon ofono-headset
24 +orc oss qt4 realtime selinux sox ssl systemd system-wide tcpd test +udev
25 +webrtc-aec +X xen zeroconf"
26
27 # See "*** BLUEZ support not found (requires D-Bus)" in configure.ac
28 REQUIRED_USE="
29         bluetooth? ( dbus )
30         ofono-headset? ( bluetooth )
31         native-headset? ( bluetooth )
32         udev? ( || ( alsa oss ) )
33 "
34
35 # libpcre needed in some cases, bug #472228
36 RDEPEND="
37         || (
38                 elibc_glibc? ( virtual/libc )
39                 elibc_uclibc? ( virtual/libc )
40                 dev-libs/libpcre
41         )
42         >=media-libs/libsndfile-1.0.20[${MULTILIB_USEDEP}]
43         X? (
44                 >=x11-libs/libX11-1.4.0[${MULTILIB_USEDEP}]
45                 >=x11-libs/libxcb-1.6[${MULTILIB_USEDEP}]
46                 x11-libs/libSM[${MULTILIB_USEDEP}]
47                 x11-libs/libICE[${MULTILIB_USEDEP}]
48                 x11-libs/libXtst[${MULTILIB_USEDEP}]
49         )
50         caps? ( >=sys-libs/libcap-2.22-r2[${MULTILIB_USEDEP}] )
51         libsamplerate? ( >=media-libs/libsamplerate-0.1.1-r1 )
52         alsa? ( >=media-libs/alsa-lib-1.0.19 )
53         glib? ( >=dev-libs/glib-2.4.0:2[${MULTILIB_USEDEP}] )
54         zeroconf? ( >=net-dns/avahi-0.6.12[dbus] )
55         jack? ( >=media-sound/jack-audio-connection-kit-0.117 )
56         tcpd? ( sys-apps/tcp-wrappers[${MULTILIB_USEDEP}] )
57         lirc? ( app-misc/lirc )
58         dbus? ( >=sys-apps/dbus-1.0.0[${MULTILIB_USEDEP}] )
59         gtk? ( x11-libs/gtk+:3 )
60         gnome? ( >=gnome-base/gconf-2.4.0 )
61         bluetooth? (
62                 net-wireless/bluez:=
63                 >=sys-apps/dbus-1.0.0
64                 media-libs/sbc
65         )
66         asyncns? ( net-libs/libasyncns[${MULTILIB_USEDEP}] )
67         udev? ( >=virtual/udev-143[hwdb(+)] )
68         realtime? ( sys-auth/rtkit )
69         equalizer? ( sci-libs/fftw:3.0 )
70         ofono-headset? ( >=net-misc/ofono-1.13 )
71         orc? ( >=dev-lang/orc-0.4.15 )
72         sox? ( >=media-libs/soxr-0.1.1 )
73         ssl? (
74                 !libressl? ( dev-libs/openssl:0 )
75                 libressl? ( dev-libs/libressl )
76         )
77         >=media-libs/speex-1.2_rc1
78         gdbm? ( sys-libs/gdbm )
79         webrtc-aec? ( media-libs/webrtc-audio-processing )
80         xen? ( app-emulation/xen-tools )
81         systemd? ( sys-apps/systemd:0=[${MULTILIB_USEDEP}] )
82         >=dev-libs/json-c-0.11[${MULTILIB_USEDEP}]
83         abi_x86_32? ( !<=app-emulation/emul-linux-x86-soundlibs-20131008-r1
84                 !app-emulation/emul-linux-x86-soundlibs[-abi_x86_32(-)] )
85         dev-libs/libltdl:0
86         selinux? ( sec-policy/selinux-pulseaudio )
87 "
88 # it's a valid RDEPEND, libltdl.so is used for native abi
89
90 DEPEND="${RDEPEND}
91         sys-devel/m4
92         doc? ( app-doc/doxygen )
93         test? ( dev-libs/check )
94         X? (
95                 x11-proto/xproto[${MULTILIB_USEDEP}]
96                 >=x11-libs/libXtst-1.0.99.2[${MULTILIB_USEDEP}]
97         )
98         dev-libs/libatomic_ops
99         virtual/pkgconfig
100         system-wide? ( || ( dev-util/unifdef sys-freebsd/freebsd-ubin ) )
101         dev-util/intltool
102         >=sys-devel/gettext-0.18.1
103 "
104 # This is a PDEPEND to avoid a circular dep
105 PDEPEND="
106         alsa? ( alsa-plugin? ( >=media-plugins/alsa-plugins-1.0.27-r1[pulseaudio,${MULTILIB_USEDEP}] ) )
107 "
108
109 # alsa-utils dep is for the alsasound init.d script (see bug #155707)
110 # bluez dep is for the bluetooth init.d script
111 # PyQt4 dep is for the qpaeq script
112 RDEPEND="${RDEPEND}
113         equalizer? ( qt4? ( dev-python/PyQt4[dbus] ) )
114         system-wide? (
115                 alsa? ( media-sound/alsa-utils )
116                 bluetooth? ( net-wireless/bluez:= )
117         )
118 "
119
120 pkg_pretend() {
121         CONFIG_CHECK="~HIGH_RES_TIMERS"
122         WARNING_HIGH_RES_TIMERS="CONFIG_HIGH_RES_TIMERS:\tis not set (required for enabling timer-based scheduling in pulseaudio)\n"
123         check_extra_config
124
125         if linux_config_exists; then
126                 local snd_hda_prealloc_size=$(linux_chkconfig_string SND_HDA_PREALLOC_SIZE)
127                 if [ -n "${snd_hda_prealloc_size}" ] && [ "${snd_hda_prealloc_size}" -lt 2048 ]; then
128                         ewarn "A preallocated buffer-size of 2048 (kB) or higher is recommended for the HD-audio driver!"
129                         ewarn "CONFIG_SND_HDA_PREALLOC_SIZE=${snd_hda_prealloc_size}"
130                 fi
131         fi
132 }
133
134 pkg_setup() {
135         linux-info_pkg_setup
136         gnome2_environment_reset #543364
137
138         enewgroup audio 18 # Just make sure it exists
139
140         if use system-wide; then
141                 enewgroup pulse-access
142                 enewgroup pulse
143                 enewuser pulse -1 -1 /var/run/pulse pulse,audio
144         fi
145 }
146
147 src_prepare() {
148         # Skip test that cannot work with sandbox, bug #501846
149         sed -i -e '/lock-autospawn-test/d' src/Makefile.am || die
150
151         epatch_user
152         eautoreconf
153 }
154
155 multilib_src_configure() {
156         local myconf=()
157
158         if use gdbm; then
159                 myconf+=( --with-database=gdbm )
160         else
161                 myconf+=( --with-database=simple )
162         fi
163
164         if use bluetooth; then
165                 if multilib_is_native_abi; then
166                         if has_version '<net-wireless/bluez-5'; then
167                                 myconf+=( --disable-bluez5 --enable-bluez4 )
168                         else
169                                 myconf+=( --enable-bluez5 --disable-bluez4
170                                         $(use_enable native-headset bluez5-native-headset)
171                                         $(use_enable ofono-headset bluez5-ofono-headset) )
172                         fi
173                 fi
174         else
175                 myconf+=( --disable-bluez5 --disable-bluez4 )
176         fi
177
178         myconf+=(
179                 --enable-largefile
180                 $(use_enable glib glib2)
181                 --disable-solaris
182                 $(use_enable asyncns)
183                 $(use_enable oss oss-output)
184                 $(use_enable alsa)
185                 $(use_enable lirc)
186                 $(use_enable neon neon-opt)
187                 $(use_enable tcpd tcpwrap)
188                 $(use_enable jack)
189                 $(use_enable zeroconf avahi)
190                 $(use_enable dbus)
191                 $(use_enable gnome gconf)
192                 $(use_enable gtk gtk3)
193                 $(use_enable libsamplerate samplerate)
194                 $(use_enable orc)
195                 $(use_enable X x11)
196                 $(use_enable test default-build-tests)
197                 $(use_enable udev)
198                 $(use_with sox soxr)
199                 $(use_enable systemd systemd-daemon)
200                 $(use_enable systemd systemd-login)
201                 $(use_enable systemd systemd-journal)
202                 $(use_enable ipv6)
203                 $(use_enable ssl openssl)
204                 $(use_enable webrtc-aec)
205                 $(use_enable xen)
206                 $(use_with caps)
207                 $(use_with equalizer fftw)
208                 --disable-adrian-aec
209                 --disable-esound
210                 --localstatedir="${EPREFIX}"/var
211                 --with-udev-rules-dir="${EPREFIX}/$(get_udevdir)"/rules.d
212                 --with-systemduserunitdir=$(systemd_get_userunitdir)
213         )
214
215         if ! multilib_is_native_abi; then
216                 # disable all the modules and stuff
217                 myconf+=(
218                         --disable-oss-output
219                         --disable-alsa
220                         --disable-lirc
221                         --disable-jack
222                         --disable-avahi
223                         --disable-gconf
224                         --disable-gtk3
225                         --disable-samplerate
226                         --disable-bluez4
227                         --disable-bluez5
228                         --disable-udev
229                         --disable-openssl
230                         --disable-orc
231                         --disable-webrtc-aec
232                         --disable-xen
233                         --without-fftw
234                         --without-soxr
235
236                         # tests involve random modules, so just do them for the native
237                         --disable-default-build-tests
238
239                         # hack around unnecessary checks
240                         # (results don't matter, we're not building anything using it)
241                         ac_cv_lib_ltdl_lt_dladvise_init=yes
242                         --with-database=simple
243                         LIBSPEEX_CFLAGS=' '
244                         LIBSPEEX_LIBS=' '
245                 )
246         fi
247
248         ECONF_SOURCE=${S} \
249         econf "${myconf[@]}"
250 }
251
252 multilib_src_compile() {
253         if multilib_is_native_abi; then
254                 emake
255                 use doc && emake doxygen
256         else
257                 local targets=( libpulse.la libpulse-simple.la )
258                 use glib && targets+=( libpulse-mainloop-glib.la )
259                 emake -C src libpulse{,dsp,-simple,-mainloop-glib}.la
260         fi
261 }
262
263 multilib_src_test() {
264         # We avoid running the toplevel check target because that will run
265         # po/'s tests too, and they are broken. Officially, it should work
266         # with intltool 0.41, but that doesn't look like a stable release.
267         if multilib_is_native_abi; then
268                 emake -C src check
269         fi
270 }
271
272 multilib_src_install() {
273         if multilib_is_native_abi; then
274                 emake -j1 DESTDIR="${D}" bashcompletiondir="$(get_bashcompdir)" install
275                 use doc && dohtml -r doxygen/html/
276         else
277                 local targets=( libpulse.la libpulse-simple.la )
278                 use glib && targets+=( libpulse-mainloop-glib.la )
279                 emake DESTDIR="${D}" install-pkgconfigDATA
280                 emake DESTDIR="${D}" -C src \
281                         install-libLTLIBRARIES \
282                         install-padsplibLTLIBRARIES \
283                         lib_LTLIBRARIES="${targets[*]}" \
284                         install-pulseincludeHEADERS
285         fi
286 }
287
288 multilib_src_install_all() {
289         # Drop the script entirely if X is disabled
290         use X || rm "${ED}"/usr/bin/start-pulseaudio-x11
291
292         if use system-wide; then
293                 newconfd "${FILESDIR}/pulseaudio.conf.d" pulseaudio
294
295                 use_define() {
296                         local define=${2:-$(echo $1 | tr '[:lower:]' '[:upper:]')}
297
298                         use "$1" && echo "-D$define" || echo "-U$define"
299                 }
300
301                 unifdef $(use_define zeroconf AVAHI) \
302                         $(use_define alsa) \
303                         $(use_define bluetooth) \
304                         $(use_define udev) \
305                         "${FILESDIR}/pulseaudio.init.d-5" \
306                         > "${T}/pulseaudio"
307
308                 doinitd "${T}/pulseaudio"
309
310                 systemd_dounit "${FILESDIR}/${PN}.service"
311         fi
312
313         use zeroconf && sed -i -e '/module-zeroconf-publish/s:^#::' "${ED}/etc/pulse/default.pa"
314
315         dodoc NEWS README todo
316
317         # Create the state directory
318         use prefix || diropts -o pulse -g pulse -m0755
319
320         # We need /var/run/pulse, bug #442852
321         use system-wide && systemd_newtmpfilesd "${FILESDIR}/${PN}.tmpfiles" "${PN}.conf"
322
323         # Prevent warnings when system-wide is not used, bug #447694
324         use system-wide || rm "${ED}"/etc/dbus-1/system.d/pulseaudio-system.conf
325
326         prune_libtool_files --all
327 }
328
329 pkg_postinst() {
330         if use system-wide; then
331                 elog "You have enabled the 'system-wide' USE flag for pulseaudio."
332                 elog "This mode should only be used on headless servers, embedded systems,"
333                 elog "or thin clients. It will usually require manual configuration, and is"
334                 elog "incompatible with many expected pulseaudio features."
335                 elog "On normal desktop systems, system-wide mode is STRONGLY DISCOURAGED."
336                 elog "For more information, see"
337                 elog "    http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/"
338                 elog "    http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/"
339                 elog "    https://wiki.gentoo.org/wiki/PulseAudio#Headless_server"
340                 if use gnome ; then
341                         elog
342                         elog "By enabling gnome USE flag, you enabled gconf support. Please note"
343                         elog "that you might need to remove the gnome USE flag or disable the"
344                         elog "gconf module on /etc/pulse/system.pa to be able to use PulseAudio"
345                         elog "with a system-wide instance."
346                 fi
347         fi
348
349         if use equalizer && ! use qt4; then
350                 elog "You've enabled the 'equalizer' USE-flag but not the 'qt4' USE-flag."
351                 elog "This will build the equalizer module, but the 'qpaeq' tool"
352                 elog "which is required to set equalizer levels will not work."
353         fi
354
355         if use native-headset && use ofono-headset; then
356                 elog "You have enabled both native and ofono headset profiles. The runtime decision"
357                 elog "which to use is done via the 'headset' argument of module-bluetooth-discover."
358         fi
359
360         if use libsamplerate; then
361                 elog "The libsamplerate based resamplers are now deprecated, because they offer no"
362                 elog "particular advantage over speex. Upstream suggests disabling them."
363         fi
364
365         # Needed for pulseaudio-6.0 update from older versions
366         if use udev; then
367                 if ! version_is_at_least 6.0 ${REPLACING_VERSIONS}; then
368                         udevadm control --reload && udevadm trigger
369                 fi
370         fi
371 }