#!/usr/bin/make -f
# -*- makefile -*-

%:
	dh  $@

override_dh_auto_configure:
	# We configure by writing to Makefile.local
	echo 'INSTALL_DIR=debian/openttd-openmsx/usr/share/games/openttd/gm/' >> Makefile.local
	# Don't install the doc files, (upstream installs them into
	# $INSTALL_DIR as well), we'll install those ourselves.
	echo 'BUNDLE_FILES=$$(MAIN_TARGET) $$(MIDI_FILES)' >> Makefile.local
	# Prevent the Makefile from autodetecting unix2dos, it's really
	# not needed
	echo 'UNIX2DOS=' >> Makefile.local

# Point dh_installchangelogs to the upstream changelog
override_dh_installchangelogs:
	dh_installchangelogs docs/changelog.txt

override_dh_auto_test:
	# Check md5sums of files. This isn't really useful (mostly meant
	# for use with opengfx), but we'll have to override dh_auto_test
	# anyway (since make test generates debug output), so we might
	# as well call make check.
	make check

override_dh_auto_build:
	# Override dh_auto_build to include building docs (because we
	# removed $DOC_FILES from $BUNDLE_FILES above, the docs won't
	# be generated by default anymore).
	make all docs

override_dh_auto_clean:
	# Don't use dh_auto_clean. It thinks any target is valid because
	# it generates output (dependency analysis) before erroring out.
	make distclean
	# Remove our additions to Makefile.local
	sed -i "/^INSTALL_DIR=/d" Makefile.local
	sed -i "/^BUNDLE_FILES=/d" Makefile.local
	sed -i "/^UNIX2DOS=/d" Makefile.local
