#!/usr/bin/make -f
# build rules for bluez

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/autoreconf.mk
include /usr/share/cdbs/1/class/autotools.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk

LDFLAGS += -Wl,--as-needed

DEB_DH_INSTALLINIT_ARGS = "--name=bluetooth"
DEB_CONFIGURE_EXTRA_FLAGS := LDFLAGS=-Wl,--as-needed \
                             --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
                             --enable-static \
                             --disable-hal \
                             --enable-sap \
                             --enable-health \
                             --enable-gstreamer \
                             --enable-alsa \
                             --enable-usb \
                             --enable-tools \
                             --enable-bccmd \
                             --enable-pcmcia \
                             --enable-hid2hci \
                             --enable-dfutool \
                             --enable-hidd \
                             --enable-pand \
                             --enable-dund \
                             --enable-cups \
                             --enable-test \
                             --enable-datafiles \
                             --enable-debug \
                             --enable-dbusoob \
                             --enable-wiimote \
                             --enable-gatt \
                             --with-telephony=ofono \
                             --with-systemdunitdir=/lib/systemd/system

DEB_DESTDIR := $(CURDIR)/debian/tmp
# for debug pakcages
DEB_DBG_PACKAGES = bluez-dbg libbluetooth3-dbg

TEST_PROGRAM_LIST = simple-agent simple-service test-adapter test-audio test-device \
	test-discovery test-input test-manager test-network test-serial \
	test-service test-telephony

install/bluez::
	install -D -m 0755 $(CURDIR)/debian/bluez_agent.udev \
		$(CURDIR)/debian/bluez/lib/udev/bluez

	install -D -m 0755 $(CURDIR)/test/agent \
		$(CURDIR)/debian/bluez/usr/bin/bluetooth-agent
	for d in $(TEST_PROGRAM_LIST) ; do \
		install -D -m 0755 $(CURDIR)/test/$$d \
			$(CURDIR)/debian/bluez/usr/bin/bluez-$$d ; \
	done

	install -D -m 0644 $(CURDIR)/debian/README.examples \
		$(CURDIR)/debian/bluez/usr/share/doc/bluez/examples/README

binary-install/bluez-gstreamer::
	LD_LIBRARY_PATH="$(CURDIR)/debian/tmp/usr/lib:$(LD_LIBRARY_PATH)" \
		dh_gstscancodecs -pbluez-gstreamer

binary-install/bluez::
	install -D -m 0644 $(CURDIR)/debian/bluetooth-dbus.conf \
		$(CURDIR)/debian/bluez/etc/dbus-1/system.d/bluetooth.conf

common-install-arch::
	dh_python3

clean::
	-rm -f $(CURDIR)/debian/bluez-pcmcia-support.udev
