#!/usr/bin/make -f

#export DH_VERBOSE=1

%:
	dh $@

override_dh_auto_build:
	cd man ; docbook-to-man blockattack.sgml | gzip -9 > blockattack.6.gz
	cp debian/blockattack.desktop .
	latex debian/block_attack_manual.tex
	dvipdfm block_attack_manual.dvi
	scons prefix=/usr sharedir=/usr/share/games/blockattack

override_dh_auto_clean:
	scons -c

override_dh_auto_install:
	dh_installdirs
	find Game -type f -exec chmod 644 {} \;
	scons prefix=/usr bindir=/usr/games mandir=/usr/share/man sharedir=/usr/share/games/blockattack destdir=$(CURDIR)/debian/blockattack install

override_dh_installchangelogs:
	dh_installchangelogs changelog*

v=1.4.1
p=blockattack
sfp=$(p)/binaries+source/Block Attack $(v)

get-orig-source:
	wget -c "http://downloads.sourceforge.net/project/$(sfp)/$(p)-$(v).tar.gz"
	tar zxf $(p)-$(v).tar.gz
	# Pre-built binaries
	rm $(p)-$(v)/Game/blockattack.i386
	rm $(p)-$(v)/Game/blockattack.x86_64
	rm $(p)-$(v)/Game/blockattack_nonet.i386
	rm $(p)-$(v)/Game/blockattack_nonet.x86_64
	# Pre-built PDF
	rm $(p)-$(v)/block_attack_manual.pdf
	mv $(p)-$(v) $(p)-$(v)+ds1.orig
	tar zcf ../$(p)_$(v)+ds1.orig.tar.gz $(p)-$(v)+ds1.orig
	rm -r $(p)-$(v).tar.gz $(p)-$(v)+ds1.orig
