#!/usr/bin/make -f
#
# debian/rules for kernel-source.
#
# GNU copyright 1997 to 1999 by Joey Hess.
# Copyright (c) 1999-2004 Herbert Xu <herbert@gondor.apana.org.au>
# Copyright (c) 2004 Jens Schmalzing <jensen@debian.org>
#

# This is the debhelper compatability version to use.
export DH_COMPAT=4

KERNEL_VERSION=2.6.20
KERNEL_ABI=15
KERNEL_ABI_VERSION=$(KERNEL_VERSION)-$(KERNEL_ABI)

control_files := debian/control.common $(shell LC_ALL=C ls -d debian/control.d/*)

SHELL := sh -e

build:
	dh_testdir

clean: debian/control
	dh_testdir
	dh_testroot
	dh_clean

debian/control: $(control_files) debian/rules
	rm -f debian/control.tmp
	for i in $(control_files); do \
		cat $$i | sed -e \
		  's/@@KVERS@@/$(KERNEL_ABI_VERSION)/g' >> \
		  debian/control.tmp; \
		echo >> debian/control.tmp; \
	done
	rm -f $@
	mv debian/control.tmp $@

install: build
	dh_testdir
	dh_testroot
	dh_clean -k

# Build architecture-independent files here.
binary-indep: debian/control install
	dh_testdir
	dh_testroot

#	dh_installdirs -i
#	dh_installdocs -i
#	dh_installchangelogs -i
#	dh_compress -i
#	dh_fixperms -i
#	dh_installdeb -i
#	dh_gencontrol -i -- \
#		-Vkernel-abi-version=$(KERNEL_ABI_VERSION)
#	dh_md5sums -i
#	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: debian/control install
	dh_testdir
	dh_testroot

	dh_installdirs -s
	dh_installdocs -s
	dh_installchangelogs -s
	dh_compress -s
	dh_fixperms -s
	dh_installdeb -s
	dh_gencontrol -s
	dh_md5sums -s
	dh_builddeb -s

binary: binary-indep binary-arch

.PHONY: build clean binary-indep binary-arch binary install
