#!/usr/bin/make -f
# Note that I have to refer to debhelper programs with ./, to make sure
# I run the most current ones. That's also why there is a symlink to the 
# current dh_lib and the current dh_getopt.pl in this debian/ directory.

# If any automatic script generation is done in building this package, 
# be sure to use the new templates from this package.
export DH_AUTOSCRIPTDIR=autoscripts

# Figure out the current debhelper version.
VERSION=$(shell expr "`dpkg-parsechangelog 2>/dev/null`" : \
	'.*Version: \(.*\).*Distribution:')

export DH_VERBOSE=1

test_files=dh_lib

build:
	./dh_testdir $(test_files)
	sed "s/#DEBHELPER_VERSION#/$(VERSION)/" < dh_testversion.in \
		> dh_testversion
	chmod 755 dh_testversion

clean:
	./dh_testdir $(test_files)
	./dh_testroot
	./dh_clean dh_testversion

# Build architecture-dependent files here.
binary-arch: build
# We have nothing to do by default.

# Build architecture-independent files here.
binary-indep: build
	./dh_testdir $(test_files)
	./dh_testroot
	./dh_clean -k
	./dh_installdirs usr/bin usr/lib/debhelper

	find . -perm +111 -maxdepth 1 -type f -not -name "*.pl" \
		-exec install -p {} debian/tmp/usr/bin \;
	cp -a dh_lib dh_getopt.pl debian/tmp/usr/lib/debhelper
	cp -a autoscripts debian/tmp/usr/lib/debhelper

	./dh_installdocs TODO README
	./dh_installexamples examples/*
	./dh_installmenu
	./dh_installmanpages
	./dh_installchangelogs
	./dh_movefiles
	./dh_compress
	./dh_fixperms
	./dh_suidregister
	./dh_installdeb
	./dh_gencontrol
	./dh_du
	./dh_md5sums
	./dh_builddeb

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