1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 )
7 inherit autotools python-single-r1 systemd udev user multilib-minimal
9 DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
10 HOMEPAGE="http://www.bluez.org"
12 mirror://kernel/linux/bluetooth/${P}.tar.xz
13 https://dev.gentoo.org/~pacho/${PN}/${P}-fedora-backports.tar.xz
16 LICENSE="GPL-2+ LGPL-2.1+"
18 KEYWORDS="amd64 arm arm64 ~hppa ~mips ppc ppc64 x86"
19 IUSE="btpclient cups doc debug deprecated extra-tools experimental +mesh midi +obex +readline selinux systemd test test-programs +udev user-session"
21 # Since this release all remaining extra-tools need readline support, but this could
22 # change in the future, hence, this REQUIRED_USE constraint could be dropped
23 # again in the future.
25 extra-tools? ( deprecated readline )
26 test? ( ${PYTHON_REQUIRED_USE} )
27 test-programs? ( ${PYTHON_REQUIRED_USE} )
30 TEST_DEPS="${PYTHON_DEPS}
31 >=dev-python/dbus-python-1[${PYTHON_USEDEP}]
32 dev-python/pygobject:3[${PYTHON_USEDEP}]
36 test? ( ${TEST_DEPS} )
39 >=dev-libs/glib-2.28:2[${MULTILIB_USEDEP}]
40 >=sys-apps/hwids-20121202.2
41 btpclient? ( >=dev-libs/ell-0.3 )
42 cups? ( net-print/cups:= )
48 midi? ( media-libs/alsa-lib )
49 obex? ( dev-libs/libical:= )
50 readline? ( sys-libs/readline:0= )
52 >=sys-apps/dbus-1.6:=[user-session=]
55 !systemd? ( >=sys-apps/dbus-1.6:= )
56 udev? ( >=virtual/udev-172 )
59 selinux? ( sec-policy/selinux-bluetooth )
60 test-programs? ( ${TEST_DEPS} )
64 # Fix missing header (fixed in 'master')
65 "${FILESDIR}"/${P}-btpclient-header.patch
67 # Fix switch to A2DP sink profile
68 "${FILESDIR}"/${P}-sink-connect.patch
70 # Try both udevadm paths to cover udev/systemd vs. eudev locations (#539844)
71 # http://www.spinics.net/lists/linux-bluetooth/msg58739.html
72 "${FILESDIR}"/${PN}-udevadm-path-r1.patch
74 # build: Quote systemd variable names, bug #527432
75 # http://article.gmane.org/gmane.linux.bluez.kernel/67230
76 "${FILESDIR}"/${PN}-5.39-systemd-quote.patch
79 # http://www.spinics.net/lists/linux-bluetooth/msg40136.html
80 "${FILESDIR}"/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
83 "${FILESDIR}"/0004-agent-Assert-possible-infinite-loop.patch
87 if use test || use test-programs; then
88 python-single-r1_pkg_setup
93 ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
94 ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
95 ewarn "and hid2hci will not be available."
103 # Apply Fedora backports
104 eapply "${WORKDIR}"/${P}-fedora-backports/*.patch
106 # http://www.spinics.net/lists/linux-bluetooth/msg38490.html
107 if ! use user-session || ! use systemd; then
108 eapply "${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch
113 -e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
114 Makefile.{in,tools} || die
117 # Broken test https://bugzilla.kernel.org/show_bug.cgi?id=196621
118 sed -i -e '/unit_tests += unit\/test-gatt\b/d' Makefile.am || die
122 multilib_copy_sources
125 multilib_src_configure() {
127 # readline is automagic when client is enabled
128 # --enable-client always needs readline, bug #504038
129 # --enable-mesh is handled in the same way
130 ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
131 ac_cv_header_readline_readline_h=$(multilib_native_usex mesh)
134 if ! multilib_is_native_abi; then
136 # deps not used for the library
137 {DBUS,GLIB}_{CFLAGS,LIBS}=' '
142 --localstatedir=/var \
145 --enable-optimization \
146 $(use_enable debug) \
153 --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
154 --with-systemduserunitdir="$(systemd_get_userunitdir)" \
155 $(multilib_native_use_enable btpclient) \
156 $(multilib_native_use_enable cups) \
157 $(multilib_native_use_enable deprecated) \
158 $(multilib_native_use_enable experimental) \
159 $(multilib_native_use_enable mesh) \
160 $(multilib_native_use_enable midi) \
161 $(multilib_native_use_enable obex) \
162 $(multilib_native_use_enable readline client) \
163 $(multilib_native_use_enable systemd) \
164 $(multilib_native_use_enable test-programs test) \
165 $(multilib_native_use_enable udev) \
166 $(multilib_native_use_enable udev sixaxis)
169 multilib_src_compile() {
170 if multilib_is_native_abi; then
173 emake -f Makefile -f - libs \
174 <<<'libs: $(lib_LTLIBRARIES)'
178 multilib_src_test() {
179 multilib_is_native_abi && default
182 multilib_src_install() {
183 if multilib_is_native_abi; then
184 emake DESTDIR="${D}" install
186 # Only install extra-tools when relevant USE flag is enabled
187 if use extra-tools; then
188 ewarn "Upstream doesn't support using this tools and their bugs are"
189 ewarn "likely to be ignored forever, also that tools can break"
190 ewarn "without previous announcement."
191 ewarn "Upstream also states all this tools are not really needed,"
192 ewarn "then, if you still need to rely on them, you must ask them"
193 ewarn "to either install that tool by default or add the needed"
194 ewarn "functionality to the existing 'official' tools."
195 ewarn "Please report this issues to:"
196 ewarn "http://www.bluez.org/development/lists/"
198 # Upstream doesn't install this, bug #524640
199 # http://permalink.gmane.org/gmane.linux.bluez.kernel/53115
200 # http://comments.gmane.org/gmane.linux.bluez.kernel/54564
201 # gatttool is only built with readline, bug #530776
202 dobin attrib/gatttool
206 # Not installed by default after being built, bug #666756
207 use btpclient && dobin tools/btpclient
209 # Unittests are not that useful once installed, so make them optional
210 if use test-programs; then
211 # example-gatt-client is the only one needing
212 # python3, the others are python2 only. Remove
213 # until we see how to pull in python2 and python3
215 rm "${ED}"/usr/$(get_libdir)/bluez/test/example-gatt-server || die
216 rm "${ED}"/usr/$(get_libdir)/bluez/test/example-gatt-client || die
217 python_fix_shebang "${ED}"/usr/$(get_libdir)/bluez/test
218 for i in $(find "${ED}"/usr/$(get_libdir)/bluez/test -maxdepth 1 -type f ! -name "*.*"); do
219 dosym "${i}" /usr/bin/bluez-"${i##*/}"
223 emake DESTDIR="${D}" \
224 install-includeHEADERS \
225 install-libLTLIBRARIES \
226 install-pkgconfigDATA
230 multilib_src_install_all() {
231 # We need to ensure obexd can be spawned automatically by systemd
232 # when user-session is enabled:
233 # http://marc.info/?l=linux-bluetooth&m=148096094716386&w=2
234 # https://bugs.gentoo.org/show_bug.cgi?id=577842
235 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804908
236 # https://bugs.archlinux.org/task/45816
237 # https://bugzilla.redhat.com/show_bug.cgi?id=1318441
238 # https://bugzilla.redhat.com/show_bug.cgi?id=1389347
239 if use user-session && use systemd; then
240 ln -s "${ED}"/usr/lib/systemd/user/obex.service "${ED}"/usr/lib/systemd/user/dbus-org.bluez.obex.service
243 find "${D}" -name '*.la' -delete || die
245 keepdir /var/lib/bluetooth
247 # Upstream don't want people to play with them
248 # But we keep installing them due to 'historical' reasons
249 insinto /etc/bluetooth
251 for d in input network; do
252 doins profiles/${d}/${d}.conf
256 newinitd "${FILESDIR}"/bluetooth-init.d-r4 bluetooth
259 use doc && dodoc doc/*.txt
263 use udev && udev_reload
264 systemd_reenable bluetooth.service
266 has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp."