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

# Use debhelper default for all targets (but some are overridden below).
%:
	dh $@

# 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.
override_dh_auto_clean:
	make clean
	# Remove files autogenerated by make, but not removed by make clean.
	rm -f version.h Makefile.local .rev

# Extract the original SVN version from the Debian version. This ensures
# that nforenum --help outputs a sensible version number.
VERSION=$(shell dpkg-parsechangelog | grep 'Version: ' | sed 's/Version: //')
REV=$(shell echo $(VERSION) | sed 's/^.*\+svn//' | sed 's/-[0-9]*$$//')

override_dh_auto_configure:
	echo "SVNVERSION=echo ${REV}" > Makefile.local
	# Name the binary after the package, since upstream uses the too
	# generic "renum" by default.
	echo "NFORENUM=nforenum" >> Makefile.local

# Upstream does not provide a make install. Additionally, we want to
# rename the binary.
override_dh_auto_install:
	install -d debian/nforenum/usr/bin
	install nforenum debian/nforenum/usr/bin
