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=9bc54b93cd7e17bf03f52513f39f926e"
9DEPENDS = "udev dbus-glib 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"
26PACKAGECONFIG[obex-profiles] = "--enable-obex,--disable-obex,libical"
27PACKAGECONFIG[readline] = "--enable-client,--disable-client,readline,"
28PACKAGECONFIG[testing] = "--enable-testing,--disable-testing"
29PACKAGECONFIG[midi] = "--enable-midi,--disable-midi,alsa-lib"
30PACKAGECONFIG[systemd] = "--enable-systemd,--disable-systemd"
31PACKAGECONFIG[cups] = "--enable-cups,--disable-cups,,cups"
32PACKAGECONFIG[nfc] = "--enable-nfc,--disable-nfc"
33PACKAGECONFIG[sap-profiles] = "--enable-sap,--disable-sap"
34PACKAGECONFIG[a2dp-profiles] = "--enable-a2dp,--disable-a2dp"
35PACKAGECONFIG[avrcp-profiles] = "--enable-avrcp,--disable-avrcp"
36PACKAGECONFIG[network-profiles] = "--enable-network,--disable-network"
37PACKAGECONFIG[hid-profiles] = "--enable-hid,--disable-hid"
38PACKAGECONFIG[hog-profiles] = "--enable-hog,--disable-hog"
39PACKAGECONFIG[health-profiles] = "--enable-health,--disable-health"
40PACKAGECONFIG[sixaxis] = "--enable-sixaxis,--disable-sixaxis"
41PACKAGECONFIG[tools] = "--enable-tools,--disable-tools"
42PACKAGECONFIG[threads] = "--enable-threads,--disable-threads"
43PACKAGECONFIG[deprecated] = "--enable-deprecated,--disable-deprecated"
44PACKAGECONFIG[mesh] = "--enable-mesh,--disable-mesh, json-c"
45
46SRC_URI = "\
47    ${KERNELORG_MIRROR}/linux/bluetooth/bluez-${PV}.tar.xz \
48    file://out-of-tree.patch \
49    file://init \
50    file://run-ptest \
51    ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '', 'file://0001-Allow-using-obexd-without-systemd-in-the-user-sessio.patch', d)} \
52    file://0001-tests-add-a-target-for-building-tests-without-runnin.patch \
53"
54S = "${WORKDIR}/bluez-${PV}"
55
56CVE_PRODUCT = "bluez"
57
58inherit autotools pkgconfig systemd update-rc.d distro_features_check ptest gobject-introspection-data
59
60EXTRA_OECONF = "\
61  --enable-test \
62  --enable-datafiles \
63  --enable-library \
64"
65
66# bluez5 builds a large number of useful utilities but does not
67# install them.  Specify which ones we want put into ${PN}-noinst-tools.
68NOINST_TOOLS_READLINE ??= ""
69NOINST_TOOLS_TESTING ??= ""
70NOINST_TOOLS_BT ??= ""
71NOINST_TOOLS = " \
72    ${@bb.utils.contains('PACKAGECONFIG', 'readline', '${NOINST_TOOLS_READLINE}', '', d)} \
73    ${@bb.utils.contains('PACKAGECONFIG', 'testing', '${NOINST_TOOLS_TESTING}', '', d)} \
74    ${@bb.utils.contains('PACKAGECONFIG', 'tools', '${NOINST_TOOLS_BT}', '', d)} \
75"
76
77do_install_append() {
78	install -d ${D}${INIT_D_DIR}
79	install -m 0755 ${WORKDIR}/init ${D}${INIT_D_DIR}/bluetooth
80
81	install -d ${D}${sysconfdir}/bluetooth/
82	if [ -f ${S}/profiles/network/network.conf ]; then
83		install -m 0644 ${S}/profiles/network/network.conf ${D}/${sysconfdir}/bluetooth/
84	fi
85	if [ -f ${S}/profiles/input/input.conf ]; then
86		install -m 0644 ${S}/profiles/input/input.conf ${D}/${sysconfdir}/bluetooth/
87	fi
88
89	if [ -f ${D}/${sysconfdir}/init.d/bluetooth ]; then
90		sed -i -e 's#@LIBEXECDIR@#${libexecdir}#g' ${D}/${sysconfdir}/init.d/bluetooth
91	fi
92
93	# Install desired tools that upstream leaves in build area
94	for f in ${NOINST_TOOLS} ; do
95		install -m 755 ${B}/$f ${D}/${bindir}
96	done
97
98	# Patch python tools to use Python 3; they should be source compatible, but
99	# still refer to Python 2 in the shebang
100	sed -i -e '1s,#!.*python.*,#!${bindir}/python3,' ${D}${libdir}/bluez/test/*
101}
102
103PACKAGES =+ "${PN}-testtools ${PN}-obex ${PN}-noinst-tools"
104
105FILES_${PN} += " \
106    ${libdir}/bluetooth/plugins/*.so \
107    ${systemd_unitdir}/ ${datadir}/dbus-1 \
108    ${libdir}/cups \
109"
110FILES_${PN}-dev += " \
111    ${libdir}/bluetooth/plugins/*.la \
112"
113
114FILES_${PN}-obex = "${libexecdir}/bluetooth/obexd \
115                    ${exec_prefix}/lib/systemd/user/obex.service \
116                    ${datadir}/dbus-1/services/org.bluez.obex.service \
117                   "
118SYSTEMD_SERVICE_${PN}-obex = "obex.service"
119
120FILES_${PN}-testtools = "${libdir}/bluez/test/*"
121
122def get_noinst_tools_paths (d, bb, tools):
123    s = list()
124    bindir = d.getVar("bindir")
125    for bdp in tools.split():
126        f = os.path.basename(bdp)
127        s.append("%s/%s" % (bindir, f))
128    return "\n".join(s)
129
130FILES_${PN}-noinst-tools = "${@get_noinst_tools_paths(d, bb, d.getVar('NOINST_TOOLS'))}"
131
132RDEPENDS_${PN}-testtools += "python3 python3-dbus"
133RDEPENDS_${PN}-testtools += "${@bb.utils.contains('GI_DATA_ENABLED', 'True', 'python3-pygobject', '', d)}"
134
135SYSTEMD_SERVICE_${PN} = "${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'bluetooth.service', '', d)}"
136INITSCRIPT_PACKAGES = "${PN}"
137INITSCRIPT_NAME_${PN} = "bluetooth"
138
139do_compile_ptest() {
140	oe_runmake buildtests
141}
142
143do_install_ptest() {
144	cp -r ${B}/unit/ ${D}${PTEST_PATH}
145	rm -f ${D}${PTEST_PATH}/unit/*.o
146}
147