1SUMMARY = "Linux Bluetooth Stack Userland V5"
2DESCRIPTION = "Linux Bluetooth stack V5 userland components.  These include a system configurations, daemons, tools and system libraries."
3HOMEPAGE = "http://www.bluez.org"
4SECTION = "libs"
5LICENSE = "GPLv2+ & LGPLv2.1+"
6LIC_FILES_CHKSUM = "file://COPYING;md5=12f884d2ae1ff87c09e5b7ccc2c4ca7e \
7                    file://COPYING.LIB;md5=fb504b67c50331fc78734fed90fb0e09 \
8                    file://src/main.c;beginline=1;endline=24;md5=0ad83ca0dc37ab08af448777c581e7ac"
9DEPENDS = "dbus glib-2.0"
10PROVIDES += "bluez-hcidump"
11RPROVIDES:${PN} += "bluez-hcidump"
12
13RCONFLICTS:${PN} = "bluez4"
14
15PACKAGECONFIG ??= "obex-profiles \
16    readline \
17    ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} \
18    a2dp-profiles \
19    avrcp-profiles \
20    network-profiles \
21    hid-profiles \
22    hog-profiles \
23    tools \
24    deprecated \
25    udev \
26"
27PACKAGECONFIG[obex-profiles] = "--enable-obex,--disable-obex,libical"
28PACKAGECONFIG[readline] = "--enable-client,--disable-client,readline,"
29PACKAGECONFIG[testing] = "--enable-testing,--disable-testing"
30PACKAGECONFIG[midi] = "--enable-midi,--disable-midi,alsa-lib"
31PACKAGECONFIG[systemd] = "--enable-systemd,--disable-systemd"
32PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,,cups"
33PACKAGECONFIG[nfc] = "--enable-nfc,--disable-nfc"
34PACKAGECONFIG[sap-profiles] = "--enable-sap,--disable-sap"
35PACKAGECONFIG[a2dp-profiles] = "--enable-a2dp,--disable-a2dp"
36PACKAGECONFIG[avrcp-profiles] = "--enable-avrcp,--disable-avrcp"
37PACKAGECONFIG[network-profiles] = "--enable-network,--disable-network"
38PACKAGECONFIG[hid-profiles] = "--enable-hid,--disable-hid"
39PACKAGECONFIG[hog-profiles] = "--enable-hog,--disable-hog"
40PACKAGECONFIG[health-profiles] = "--enable-health,--disable-health"
41PACKAGECONFIG[sixaxis] = "--enable-sixaxis,--disable-sixaxis"
42PACKAGECONFIG[tools] = "--enable-tools,--disable-tools"
43PACKAGECONFIG[threads] = "--enable-threads,--disable-threads"
44PACKAGECONFIG[deprecated] = "--enable-deprecated,--disable-deprecated"
45PACKAGECONFIG[mesh] = "--enable-mesh --enable-external-ell,--disable-mesh, json-c ell"
46PACKAGECONFIG[btpclient] = "--enable-btpclient --enable-external-ell,--disable-btpclient, ell"
47PACKAGECONFIG[udev] = "--enable-udev,--disable-udev,udev"
48PACKAGECONFIG[manpages] = "--enable-manpages,--disable-manpages,python3-docutils-native"
49
50SRC_URI = "${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \
51           file://init \
52           file://run-ptest \
53           ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'file://0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch', d)} \
54           file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \
55           file://0001-test-gatt-Fix-hung-issue.patch \
56           file://0001-audio-Rename-pause-funciton-to-avoid-shadowing-glibc.patch \
57           "
58S = "${WORKDIR}/bluez-${PV}"
59
60CVE_PRODUCT = "bluez"
61
62inherit autotools pkgconfig systemd update-rc.d ptest gobject-introspection-data
63
64EXTRA_OECONF = "\
65  --enable-test \
66  --enable-datafiles \
67  --enable-library \
68  --without-zsh-completion-dir \
69"
70
71# bluez5 builds a large number of useful utilities but does not
72# install them.  Specify which ones we want put into ${PN}-noinst-tools.
73NOINST_TOOLS_READLINE ??= ""
74NOINST_TOOLS_TESTING ??= ""
75NOINST_TOOLS_BT ??= ""
76NOINST_TOOLS = " \
77    ${@bb.utils.contains('PACKAGECONFIG', 'readline', '${NOINST_TOOLS_READLINE}', '', d)} \
78    ${@bb.utils.contains('PACKAGECONFIG', 'testing', '${NOINST_TOOLS_TESTING}', '', d)} \
79    ${@bb.utils.contains('PACKAGECONFIG', 'tools', '${NOINST_TOOLS_BT}', '', d)} \
80"
81
82do_install:append() {
83	install -d ${D}${INIT_D_DIR}
84	install -m 0755 ${WORKDIR}/init ${D}${INIT_D_DIR}/bluetooth
85
86	install -d ${D}${sysconfdir}/bluetooth/
87	if [ -f ${S}/profiles/network/network.conf ]; then
88		install -m 0644 ${S}/profiles/network/network.conf ${D}/${sysconfdir}/bluetooth/
89	fi
90	if [ -f ${S}/profiles/input/input.conf ]; then
91		install -m 0644 ${S}/profiles/input/input.conf ${D}/${sysconfdir}/bluetooth/
92	fi
93
94	if [ -f ${D}/${sysconfdir}/init.d/bluetooth ]; then
95		sed -i -e 's#@LIBEXECDIR@#${libexecdir}#g' ${D}/${sysconfdir}/init.d/bluetooth
96	fi
97
98	# Install desired tools that upstream leaves in build area
99	for f in ${NOINST_TOOLS} ; do
100		install -m 755 ${B}/$f ${D}/${bindir}
101	done
102
103	# Patch python tools to use Python 3; they should be source compatible, but
104	# still refer to Python 2 in the shebang
105	sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/*
106}
107
108PACKAGES =+ "${PN}-testtools ${PN}-obex ${PN}-noinst-tools"
109
110FILES:${PN} += " \
111    ${libdir}/bluetooth/plugins/*.so \
112    ${systemd_unitdir}/ ${datadir}/dbus-1 \
113    ${libdir}/cups \
114"
115FILES:${PN}-dev += " \
116    ${libdir}/bluetooth/plugins/*.la \
117"
118
119FILES:${PN}-obex = "${libexecdir}/bluetooth/obexd \
120                    ${exec_prefix}/lib/systemd/user/obex.service \
121                    ${systemd_system_unitdir}/obex.service \
122                    ${sysconfdir}/systemd/system/multi-user.target.wants/obex.service \
123                    ${datadir}/dbus-1/services/org.bluez.obex.service \
124                    ${sysconfdir}/dbus-1/system.d/obexd.conf \
125                   "
126SYSTEMD_SERVICE:${PN}-obex = "obex.service"
127
128FILES:${PN}-testtools = "${libdir}/bluez/test/*"
129
130def get_noinst_tools_paths (d, bb, tools):
131    s = list()
132    bindir = d.getVar("bindir")
133    for bdp in tools.split():
134        f = os.path.basename(bdp)
135        s.append("%s/%s" % (bindir, f))
136    return "\n".join(s)
137
138FILES:${PN}-noinst-tools = "${@get_noinst_tools_paths(d, bb, d.getVar('NOINST_TOOLS'))}"
139
140RDEPENDS:${PN}-testtools += "python3-core python3-dbus"
141RDEPENDS:${PN}-testtools += "${@bb.utils.contains('GI_DATA_ENABLED', 'True', 'python3-pygobject', '', d)}"
142
143SYSTEMD_SERVICE:${PN} = "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'bluetooth.service', '', d)}"
144INITSCRIPT_PACKAGES = "${PN}"
145INITSCRIPT_NAME:${PN} = "bluetooth"
146
147do_compile_ptest() {
148	oe_runmake buildtests
149}
150
151do_install_ptest() {
152	cp -r ${B}/unit/ ${D}${PTEST_PATH}
153	rm -f ${D}${PTEST_PATH}/unit/*.o
154}
155
156RDEPENDS:${PN}-ptest:append:libc-glibc = " glibc-gconv-utf-16"
157