#!/usr/bin/make -f

# Include dpatch stuff.
include /usr/share/dpatch/dpatch.make

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

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

PACKAGE=$(shell dh_listpackages)
ARCH=$(shell dpkg --print-architecture)

build: build-stamp
build-stamp: patch-stamp
	dh_testdir
	$(MAKE)
	touch build-stamp

clean: clean1 unpatch
clean1:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	rm -rf debian/patched
	$(MAKE) clean
	dh_clean
	debconf-updatepo

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs sbin usr/bin usr/lib/$(PACKAGE) usr/share/doc/$(PACKAGE) /usr/share/man/man1 /usr/share/man/man5 /usr/share/man/man8
	dh_install delo/delo sbin
	dh_install t-rex/t-rex usr/bin
	dh_installdirs boot usr/lib/$(PACKAGE)
	dh_install loader/delo.2nd boot
	dh_install t-rex-loader/t-rex-loader usr/lib/$(PACKAGE)
	dh_installchangelogs
	dh_installdocs README TODO kernel-patch/ramdisk_kernel_parameters.patch
	dh_installexamples delo.conf
	dh_installman man/t-rex.1 man/delo.conf.5 man/delo.8
	dh_installdebconf
	dh_installdeb

# Build architecture-independent files here.
binary-indep: build install

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_strip -Xloader -Xdelo.2nd
	dh_compress
	dh_fixperms
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install patch unpatch \
	clean1
