#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

include /usr/share/dpkg/default.mk

DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEBVERS := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2 | cut -d- -f1)
VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/[+-].*//' -e 's/~//g')

override_dh_dkms:
	dh_dkms -V $(VERSION)

%:
	dh $@ --with dkms

DKMS_WIFI_SRC_DIR := $(CURDIR)/debian/oem-wifi-realtek-8821ce-lp1767920-4.15-dkms/usr/src/oem-wifi-realtek-8821ce-lp1767920-4.15-dkms-$(VERSION)
DKMS_BT_SRC_DIR := $(CURDIR)/debian/oem-bt-realtek-rtk-btusb-lp1767920-4.15-dkms/usr/src/oem-bt-realtek-rtk-btusb-lp1767920-4.15-dkms-$(VERSION)

override_dh_auto_install:
	install -d $(DKMS_BT_SRC_DIR)
	install -d $(DKMS_WIFI_SRC_DIR)
	cp -a bt/* $(DKMS_BT_SRC_DIR)
	cp -a wifi/* $(DKMS_WIFI_SRC_DIR)
	dh_auto_install


# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
#override_dh_auto_configure:
#	dh_auto_configure -- #	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

