#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

build: build-stamp
build-stamp:
	dh_testdir
	$(MAKE) $(if $(findstring noopt,$(DEB_BUILD_OPTIONS)),CFLAGS+=-O0,)
ifneq ($(findstring nocheck,$(DEB_BUILD_OPTIONS)),nocheck)
	$(MAKE) tests
endif
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	$(MAKE) clean
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/<packagename>
	$(MAKE) DESTDIR=`pwd`/debian/tmp install
	install -D -m 0755 kerneloops.init `pwd`/debian/kerneloops-daemon/etc/init.d/kerneloops
	install -D -m 0644 debian/kerneloops.default `pwd`/debian/kerneloops-daemon/etc/default/kerneloops
	dh_install

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installexamples
	dh_installinit -pkerneloops-daemon --name=kerneloops -o -- start 20 2 3 4 5 . stop 20 1 .
#	dh_installdebconf	
#	dh_installman kerneloops.8
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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