#!/usr/bin/make -f
# GNU copyright 1997 to 1999 by Joey Hess.

#export DH_VERBOSE=1
export DH_OPTIONS

include /usr/share/dpkg/pkg-info.mk
BUILD_DATE := $(shell dpkg-parsechangelog --show-field=Date)

%:
	dh $@ --parallel --with python3,bash-completion

override_dh_auto_build:
	dh_auto_build --parallel
	find out -regex '.*\.\(json\|files\|size_and_md5\|cksums\|md5sums\|sha1sums\|sha256sums\)' \
          -exec touch --date='$(BUILD_DATE)' {} \;
	make out/vfs.zip

override_dh_auto_clean:
	dh_auto_clean --parallel
	@if [ "`echo *.deb`" != "*.deb" ]; then \
		echo; \
		echo "*************************************************"; \
		echo "Cannot create source package with these here:"; \
		ls *.deb; \
		echo "*************************************************"; \
		echo; \
		exit 1; \
	fi
	debian/copyright.py

override_dh_install:
	dh_install
	echo 'GAME_PACKAGE_VERSION = """$(DEB_VERSION)"""' > debian/game-data-packager/usr/share/games/game-data-packager/game_data_packager/version.py
	if dpkg-vendor --derives-from Ubuntu; then \
		touch debian/game-data-packager/usr/share/games/game-data-packager/is-ubuntu-derived; \
	fi
	install -D -m755 runtime/doom2-masterlevels.py debian/game-data-packager/usr/games/doom2-masterlevels

override_dh_installdocs:
	dh_installdocs -XTODO
