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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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

DEBVERS        := $(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}')
VERSION        := $(shell echo '$(DEBVERS)' | sed -e 's/^[0-9]*://' -e 's/-.*//')

%:
	dh $@ --with autotools_dev

override_dh_clean:
	find . -name Makefile -delete
	# restore reprof.spec which is removed in the build process
	if [ ! -e reprof.spec ] ; then sed 's/@VERSION@/$(VERSION)/' reprof.spec.in > reprof.spec ; fi
	dh_clean

override_dh_auto_build:
	# Build process somehow removes lib/RG/Reprof.pm
	# make sure it exists to be able to build twice in a row
	dh_auto_build
	if [ ! -e lib/RG/Reprof.pm ] ; then cp lib/RG/Reprof.pm.mk lib/RG/Reprof.pm ; fi
	

override_dh_auto_install:
	# The following will run: perl Build install
	dh_auto_install
	# But we also need this to get the correct script
	DESTDIR=$(CURDIR)/debian/tmp make install

override_dh_compress:
	dh_compress -Xexample.Q
