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

%:
	dh $@

override_dh_auto_configure:
	dh_auto_build --sourcedirectory=etw

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

override_dh_clean:
	dh_clean
	find . -name "*.o" -delete
	$(RM) etw/etw
	$(RM) README

# 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

