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

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

include /usr/share/dpkg/pkg-info.mk

%:
	dh $@


PKD  = $(abspath $(dir $(MAKEFILE_LIST)))
PKG  = $(DEB_SOURCE)
VER  = $(DEB_VERSION_UPSTREAM)

SVN_ADDR = https://svn.code.sf.net/p/tercpp/code/trunk/tercpp.0.6
SVN_REV := $(shell echo $(VER) | awk -F"+" '{ print $$2 }' | sed 's/svn//' )

TARBALL = $(PKG)_$(VER).orig.tar.xz
.PHONY: get-orig-source
get-orig-source:
	rm -rf $(CURDIR)/get-orig-source $(TARBALL)
	mkdir $(CURDIR)/get-orig-source
	svn export -r $(SVN_REV) $(SVN_ADDR) $(CURDIR)/get-orig-source/$(PKG)-$(VER).orig
	# remove unneeded files
	cd $(CURDIR)/get-orig-source/$(PKG)-$(VER).orig && $(RM) -r \
		src/tinyxmlparser.cpp \
		src/tinyxmlerror.cpp \
		src/tinyxml.cpp \
		src/tinyxml.h \
		src/tinystr.cpp \
		src/tinystr.h \
		doc/art-servan-schwenk.pdf
	tar cjf $(TARBALL) -C $(CURDIR)/get-orig-source $(PKG)-$(VER).orig
	rm -rf $(CURDIR)/get-orig-source
	echo "  "$(TARBALL)" created; move it to the right destination to build the package"

override_dh_auto_configure:
	dh_auto_configure -- -DCMAKE_BUILD_RPATH_USE_ORIGIN=ON