#!/usr/bin/make -f
#export DH_VERBOSE=1
export DH_OPTIONS
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -lm

%:
	dh $@ --parallel

override_dh_auto_configure:
	$(MAKE) -C etw

override_dh_installdocs:
	cp ./web/EatTheWhistle.txt README
	dh_installdocs


# Adapted from http://wiki.debian.org/SandroTosi/Svn_get-orig-source
PACKAGE = etw
SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
SVN_REVISION := $(shell echo $(SRC_VERSION) | awk -F"+" '{ print $$2 }' | sed 's/svn//' )
TARBALL = $(PACKAGE)_$(SRC_VERSION).orig.tar.gz

get-orig-source:
	rm -rf get-orig-source $(TARBALL)
	mkdir get-orig-source
	svn export -r $(SVN_REVISION) \
	"https://etw.svn.sourceforge.net/svnroot/etw/trunk" \
	get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig
	find get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig \
	                  -name ".cvsignore" -exec rm {} \;
	GZIP='--best --no-name' \
	tar czf $(TARBALL) -C get-orig-source $(PACKAGE)-$(SRC_VERSION).orig
	rm -rf 	get-orig-source
	echo "  "$(TARBALL)" created; move it to the right destination to build the package"


.PHONY: get-orig-source

