#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/dpkg/pkg-info.mk

MODULE		 = bbswitch
MODSRCPKG	 = $(MODULE)-source

%:
	dh $@ --buildsystem=none

execute_after_dh_install:
	# bbswitch-dkms
	dh_install -p$(MODULE)-dkms Makefile bbswitch.c usr/src/$(MODULE)-$(DEB_VERSION_UPSTREAM)/
	# bbswitch-source (for use with module-assistant)
# Install the module source.
	dh_install -p$(MODSRCPKG) Makefile bbswitch.c usr/src/modules/$(MODULE)/
# Install the debian directory into the module source.
	dh_install -p$(MODSRCPKG) debian/copyright debian/changelog debian/modules/* usr/src/modules/$(MODULE)/debian/
# Pack the module source.
	tar c \
		-C debian/$(MODSRCPKG)/usr/src \
		--numeric-owner --owner=0 --group=0 \
		--mode=a=rX,u+w \
		--sort=name \
		--mtime='@$(SOURCE_DATE_EPOCH)' \
		--clamp-mtime \
		--remove-files \
		modules | xz -9 > debian/$(MODSRCPKG)/usr/src/$(MODULE).tar.xz
	tar tfv debian/$(MODSRCPKG)/usr/src/$(MODULE).tar.xz

override_dh_installchangelogs:
	dh_installchangelogs NEWS
