#!/usr/bin/make -f

#export DH_VERBOSE=1

configure: configure-stamp-debian
configure-stamp-debian:
	dh_testdir
	touch $@

build: configure-stamp-debian build-stamp-debian
build-stamp-debian:
	dh_testdir
	$(MAKE) build
	touch $@

clean:
	dh_testdir
	dh_testroot
	rm -f configure-stamp-debian build-stamp-debian
	dh_clean
	$(MAKE) clean

install: DESTDIR=$(CURDIR)/debian/kernel-patch-suspend2
install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	
	$(MAKE) install DESTDIR=$(DESTDIR)

# The Debian 2.6.8 kernel is actually 2.6.8.1
	mv $(DESTDIR)/usr/src/kernel-patches/all/2.6.8{.1,}

# The Debian 2.6.11 kernel is actually 2.6.11.8
#	mv $(DESTDIR)/usr/src/kernel-patches/all/2.6.11{.8,}

# 2.4.29 patches also apply to 2.4.28
	ln -s 2.4.29 $(DESTDIR)/usr/src/kernel-patches/all/2.4.28

	dh_installdirs
	dh_installdocs
	dh_installchangelogs
	dh_install

	chmod 755 $(DESTDIR)/usr/share/bug/kernel-patch-suspend2/script

	install -m644 debian/kernel-patch-suspend2.lintian-overrides \
	  $(DESTDIR)/usr/share/lintian/overrides/kernel-patch-suspend2

binary-arch: build install

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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