1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit autotools bash-completion-r1 eutils flag-o-matic gnome2-utils linux-info readme.gentoo systemd user versionator udev multilib-minimal
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"
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 )"
19 KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 ~sh sparc x86 ~amd64-fbsd ~amd64-linux ~x86-linux"
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"
27 # See "*** BLUEZ support not found (requires D-Bus)" in configure.ac
30 ofono-headset? ( bluetooth )
31 native-headset? ( bluetooth )
32 udev? ( || ( alsa oss ) )
35 # libpcre needed in some cases, bug #472228
38 elibc_glibc? ( virtual/libc )
39 elibc_uclibc? ( virtual/libc )
42 >=media-libs/libsndfile-1.0.20[${MULTILIB_USEDEP}]
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}]
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 )
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 )
74 !libressl? ( dev-libs/openssl:0 )
75 libressl? ( dev-libs/libressl )
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(-)] )
86 selinux? ( sec-policy/selinux-pulseaudio )
88 # it's a valid RDEPEND, libltdl.so is used for native abi
92 doc? ( app-doc/doxygen )
93 test? ( dev-libs/check )
95 x11-proto/xproto[${MULTILIB_USEDEP}]
96 >=x11-libs/libXtst-1.0.99.2[${MULTILIB_USEDEP}]
98 dev-libs/libatomic_ops
100 system-wide? ( || ( dev-util/unifdef sys-freebsd/freebsd-ubin ) )
102 >=sys-devel/gettext-0.18.1
104 # This is a PDEPEND to avoid a circular dep
106 alsa? ( alsa-plugin? ( >=media-plugins/alsa-plugins-1.0.27-r1[pulseaudio,${MULTILIB_USEDEP}] ) )
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
113 equalizer? ( qt4? ( dev-python/PyQt4[dbus] ) )
115 alsa? ( media-sound/alsa-utils )
116 bluetooth? ( net-wireless/bluez:= )
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"
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}"
136 gnome2_environment_reset #543364
138 enewgroup audio 18 # Just make sure it exists
140 if use system-wide; then
141 enewgroup pulse-access
143 enewuser pulse -1 -1 /var/run/pulse pulse,audio
148 # Skip test that cannot work with sandbox, bug #501846
149 sed -i -e '/lock-autospawn-test/d' src/Makefile.am || die
155 multilib_src_configure() {
159 myconf+=( --with-database=gdbm )
161 myconf+=( --with-database=simple )
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 )
169 myconf+=( --enable-bluez5 --disable-bluez4
170 $(use_enable native-headset bluez5-native-headset)
171 $(use_enable ofono-headset bluez5-ofono-headset) )
175 myconf+=( --disable-bluez5 --disable-bluez4 )
180 $(use_enable glib glib2)
182 $(use_enable asyncns)
183 $(use_enable oss oss-output)
186 $(use_enable neon neon-opt)
187 $(use_enable tcpd tcpwrap)
189 $(use_enable zeroconf avahi)
191 $(use_enable gnome gconf)
192 $(use_enable gtk gtk3)
193 $(use_enable libsamplerate samplerate)
196 $(use_enable test default-build-tests)
199 $(use_enable systemd systemd-daemon)
200 $(use_enable systemd systemd-login)
201 $(use_enable systemd systemd-journal)
203 $(use_enable ssl openssl)
204 $(use_enable webrtc-aec)
207 $(use_with equalizer fftw)
210 --localstatedir="${EPREFIX}"/var
211 --with-udev-rules-dir="${EPREFIX}/$(get_udevdir)"/rules.d
212 --with-systemduserunitdir=$(systemd_get_userunitdir)
215 if ! multilib_is_native_abi; then
216 # disable all the modules and stuff
236 # tests involve random modules, so just do them for the native
237 --disable-default-build-tests
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
252 multilib_src_compile() {
253 if multilib_is_native_abi; then
255 use doc && emake doxygen
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
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
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/
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
288 multilib_src_install_all() {
289 # Drop the script entirely if X is disabled
290 use X || rm "${ED}"/usr/bin/start-pulseaudio-x11
292 if use system-wide; then
293 newconfd "${FILESDIR}/pulseaudio.conf.d" pulseaudio
296 local define=${2:-$(echo $1 | tr '[:lower:]' '[:upper:]')}
298 use "$1" && echo "-D$define" || echo "-U$define"
301 unifdef $(use_define zeroconf AVAHI) \
303 $(use_define bluetooth) \
305 "${FILESDIR}/pulseaudio.init.d-5" \
308 doinitd "${T}/pulseaudio"
310 systemd_dounit "${FILESDIR}/${PN}.service"
313 use zeroconf && sed -i -e '/module-zeroconf-publish/s:^#::' "${ED}/etc/pulse/default.pa"
315 dodoc NEWS README todo
317 # Create the state directory
318 use prefix || diropts -o pulse -g pulse -m0755
320 # We need /var/run/pulse, bug #442852
321 use system-wide && systemd_newtmpfilesd "${FILESDIR}/${PN}.tmpfiles" "${PN}.conf"
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
326 prune_libtool_files --all
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"
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."
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."
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."
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."
365 # Needed for pulseaudio-6.0 update from older versions
367 if ! version_is_at_least 6.0 ${REPLACING_VERSIONS}; then
368 udevadm control --reload && udevadm trigger