#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

D = $(CURDIR)/debian/deal

configure: configure-stamp
configure-stamp:
	dh_testdir
	touch configure-stamp

build-indep:

build build-arch: build-stamp
build-stamp: configure-stamp
	dh_testdir
	$(MAKE) EXTRA_LDFLAGS="$(shell dpkg-buildflags --get LDFLAGS)" \
		EXTRA_CFLAGS="$(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)"
	touch build-stamp

clean:
	dh_testdir
	touch Make.dep
	$(MAKE) clean
	dh_clean makecounttable counttable.c build-stamp configure-stamp
	# test suite leftovers
	rm -f test.out correct.out

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	install -m 755 deal $D/usr/games/deal
	install -m 644 deal.tcl $D/usr/share/deal/deal.tcl
	install -m 644 input/* $D/usr/share/deal/input
	install -m 644 format/* $D/usr/share/deal/format
	install -m 644 lib/* $D/usr/share/deal/lib
	
	install -m 644 html/*.* $D/usr/share/doc/deal/html
	install -m 644 html/graphics/* $D/usr/share/doc/deal/html/graphics
	install -m 644 html/ex/* $D/usr/share/doc/deal/html/ex

binary-indep:

binary binary-arch: build install
	dh_installchangelogs CHANGES
	dh_installdocs
	dh_installman debian/deal.6
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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