#!/usr/bin/make -f
#export DH_VERBOSE=1

%:
	dh $@ --parallel

override_dh_auto_configure:
	dh_auto_configure -- -DGOFIGURE2_INSTALL_LIB_DIR:STRING=lib -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo

override_dh_shlibdeps:
	LD_LIBRARY_PATH=debian/gofigure2/usr/lib/gofigure2 dh_shlibdeps -l/usr/lib/gofigure2

debian/gofigure.1: debian/gofigure.1.in
	help2man --include=debian/gofigure.1.in \
		--output=debian/gofigure.1 --no-info gofigure

VER_FULL = $(shell dpkg-parsechangelog | grep '^Version' | cut -d' ' -f2 | cut -f1 -d-)
UPSTREAM_SRC = GoFigure2-v$(VER_FULL).tar.gz
DEBIAN_SRC_DIR = GoFigure2-v$(VER_FULL)
DEBIAN_SRC_TAR = gofigure2_$(VER_FULL).orig.tar.gz

$(UPSTREAM_SRC):
	wget http://voxel.dl.sourceforge.net/sourceforge/gofigure2/$@

get-orig-source: $(UPSTREAM_SRC)
	#uscan --verbose --force-download --repack --rename
	tar xzf $(UPSTREAM_SRC)
	# save some disk space, removing test data:
	rm -rf $(DEBIAN_SRC_DIR)/Testing/Data
	rm -rf $(DEBIAN_SRC_DIR)/Testing/Sikuli
	GZIP="--best --no-name" tar czf $(DEBIAN_SRC_TAR) $(DEBIAN_SRC_DIR)
	rm -rf $(DEBIAN_SRC_DIR)
