#!/usr/bin/make -f

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

export DESTDIR=$(shell pwd)/debian/check

configure: configure-stamp
configure-stamp:
	dh_testdir
	 ./configure --prefix=/usr --enable-plain-docdir
	touch configure-stamp

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

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp
	-$(MAKE) distclean
	# hack!
	rm -f debian/files
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(MAKE) install 
	# fix the installation
	rm -f debian/check/usr/share/doc/check/tutorial.sgml
	rm -f debian/check/usr/share/doc/check/ChangeLog
	rm -f debian/check/usr/share/doc/check/*.html
	mkdir debian/check/usr/share/doc/check/tutorial
	cp doc/*.html debian/check/usr/share/doc/check/tutorial
	rm debian/check/usr/share/doc/check/COPYING
	
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs -XTODO
	dh_installexamples
	# fix the example setup
	rm -rf debian/check/usr/share/doc/check/examples/Makefile*
	rm -rf debian/check/usr/share/doc/check/examples/configure*
	cp debian/example_makefile debian/check/usr/share/doc/check/examples/Makefile
	dh_installchangelogs ChangeLog
	dh_link
	dh_strip
	dh_compress -XMakefile
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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