#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
%:
	dh $@

override_dh_auto_build-arch:
	dh_auto_build -- DATA_INSTALL_DIR=/usr/share/games/hannah/ \
	    SCOREDIR=/var/games/hannah/ CXXFLAGS="$(CXXFLAGS)" CFLAGS="$(CFLAGS)" \
	    LDFLAGS="$(LDFLAGS)"

override_dh_auto_build-indep:
	# Avoid building the package for hannah-data
	:

override_dh_auto_clean:
	rm -f *.o hhh

override_dh_auto_install-arch:
	# dh_install cannot rename files
	cp $(CURDIR)/hhh $(CURDIR)/debian/hannah/usr/games/hannah

override_dh_auto_install-indep:
	# Transform the png into an xpm icon
	convert $(CURDIR)/hannah/default/hannah_down1.png $(CURDIR)/debian/hannah-data/usr/share/pixmaps/hannah.xpm

override_dh_fixperms-indep:
	dh_fixperms
	# Fix /var/games/hannah/hiscore.dat permissions
	chgrp games $(CURDIR)/debian/hannah-data/var/games/hannah/hiscore.dat
	chmod 664 $(CURDIR)/debian/hannah-data/var/games/hannah/hiscore.dat

override_dh_fixperms-arch:
	dh_fixperms
	# Make sure the binary belongs to the "games" group and set-gid it.
	chgrp games $(CURDIR)/debian/hannah/usr/games/hannah
	chmod 2755 $(CURDIR)/debian/hannah/usr/games/hannah
