#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND = -DBUILD_DATE='"$(shell date --utc --date=@${SOURCE_DATE_EPOCH} +%Y-%m-%d)"'

%:
	dh $@ --with bash-completion

override_dh_auto_install:
	dh_auto_install --max-parallel=1 -- \
		SETUP_BINARIES=crispy-setup \
		DOC_FILES="README.md" \
		execgamesdir=/usr/games \
		appdatadir=/usr/share/metainfo
	# avoid clashing with chocolate-doom (contents is currently identical)
	mv debian/crispy-doom/usr/share/man/man5/default.cfg.5 \
	   debian/crispy-doom/usr/share/man/man5/crispy_default.cfg.5
	mv debian/crispy-doom/usr/share/man/man5/heretic.cfg.5 \
	   debian/crispy-doom/usr/share/man/man5/crispy_heretic.cfg.5
	# superfluous docs
	rm debian/crispy-doom/usr/share/doc/crispy-doom/CMDLINE.doom \
	      debian/crispy-doom/usr/share/doc/crispy-doom/INSTALL.doom \
	      debian/crispy-doom/usr/share/doc/crispy-doom/NOT-BUGS.md
	rm -rf debian/crispy-doom/usr/share/doc/crispy-heretic
	find 'debian/' -name 'crispy-server*' -delete
