#!/usr/bin/make -f

SHELL := sh -e

gencontrol_flags := -Vkernel-version=$(KERNEL_RELEASE)
control_files := debian/control

debian/changelog: debian/changelog.in
	sed \
	    -e 's|@VERSION@|$(KDEB_PKGVERSION)|g' \
	    -e 's|@TIMESTAMP@|$(shell LANG=C date)|g' \
	    $< > $@

debian/control: debian/control.in
	sed \
	    -e 's|@KERNEL_VARIANT@|$(KERNEL_VARIANT)|g' \
	    $< > $@

clean: debian/control debian/changelog
	dh_testdir
	dh_testroot
	dh_clean

build-%:
	:

install-%: build-%
	dh_testdir
	dh_testroot
	dh_prep

binary-arch: t=-a
binary-indep: t=-i
binary-%: debian/control install-%
	dh_testdir
	dh_testroot

	dh_installdirs $(t)
	dh_installdocs $(t)
	dh_installchangelogs $(t)
	dh_compress $(t)
	dh_fixperms $(t)
	dh_installdeb $(t)
	dh_gencontrol $(t) -- $(gencontrol_flags)
	dh_md5sums $(t)
	dh_builddeb $(t)

build: build-indep build-arch
binary: binary-indep binary-arch

.PHONY: clean
