#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh $@

override_dh_auto_configure:
	# We configure by writing to Makefile.local
	echo "INSTALL_DIR=debian/openttd-opengfx/usr/share/games/openttd/data/" >> Makefile.local
	# Force nforenum to store its datafiles in ./.renum instead of
	# trying ~/.renum
	echo "NFORENUM_FLAGS=-D." >> Makefile.local

override_dh_auto_build:
	# Docs are not built by default
	make all docs

override_dh_auto_test:
	# Check if the md5 sums of the resulting grf files match. This
	# ensures no problems will arise in online play, which uses both
	# version info and md5 sums of files. We don't use dh_auto_test
	# here, because "make test" is also supported, but gives debug
	# output.
	make check

override_dh_auto_clean:
	# Don't use dh for clean. Since the upstream Makefile generates
	# dependency information before any error messages, dh_auto_clean
	# sometimes thinks make distclean is supported, while it isn't.
	# Use clean instead of mrproper, since the latter removes the md5
	# sums from the source tarball (but clean doesn't remove enough...).
	# Next upstream release should have a distclean target that works
	# entirely.
	make clean
	# Remove our additions to Makefile.local
	sed -i "/^INSTALL_DIR=/d" Makefile.local
	sed -i "/^NFORENUM_FLAGS=/d" Makefile.local
	# Clean up the stuff nforenum leaves around.
	rm -rf .renum

override_dh_installchangelogs:
	dh_installchangelogs docs/changelog.txt
