#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export CCACHE_DIR=$(CURDIR)/ccache
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	DEBUG_OPTS += --enable-debug
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --datarootdir=/usr/share/games --bindir=/usr/games --libdir=/usr/lib/bzflag-server $(DEBUG_OPTS)

override_dh_auto_install:
	dh_installchangelogs ChangeLog
ifneq (,$(findstring bzflag-server, $(shell dh_listpackages)))
	dh_installinit -pbzflag-server --name=bzflag
endif
	dh_auto_install

override_dh_installsystemd:
	dh_installsystemd --name=bzflag

override_dh_install:
	# Fix #728167 and install bzfquery to /usr/games
	cp misc/bzfquery.pl misc/bzfquery
	dh_install
	# Remove the DejaVu.License file installed by the wildcard in
	# bzflag-data.install
	$(RM) debian/bzflag-data/usr/share/games/bzflag/fonts/DejaVu.License
	$(RM) debian/bzflag-data/usr/share/games/bzflag/fonts/readme
	$(RM) misc/bzfquery

override_dh_fixperms:
	dh_fixperms
ifneq (,$(findstring bzflag-server, $(shell dh_listpackages)))
	chown -R games:games debian/bzflag-server/var/log/bzflag
endif
