#!/usr/bin/make -f

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

# This has to be exported to make some magic below work.
export DH_OPTIONS

%:
	dh --parallel --with quilt --buildsystem=cmake $@ 

override_dh_auto_configure:
	# cant get mpi to work for now: https://github.com/mariusmuja/flann/issues/10
	dh_auto_configure -- -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_SKIP_RPATH:BOOL=ON -DBUILD_MATLAB_BINDINGS:BOOL=OFF -DBUILD_PYTHON_BINDINGS:BOOL=OFF -DUSE_MPI:BOOL=OFF

override_dh_auto_test:
	# test download material from the net. Removing them.

override_dh_compress:
	dh_compress --exclude=.pdf

VER_MAJOR = 1
VER_MINOR = 6
VER_PATCH = 11
VER_FULL = $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)

UPSTREAM_SRC = flann-$(VER_FULL)-src
DEBIAN_SRC_DIR = flann-$(VER_FULL)
DEBIAN_SRC_TAR = flann_$(VER_FULL).orig.tar.gz

$(UPSTREAM_SRC).zip:
	#uscan --verbose --force-download --repack --rename
	wget -c http://people.cs.ubc.ca/~mariusm/uploads/FLANN/$@

get-orig-source: $(UPSTREAM_SRC).zip
	rm -rf $(DEBIAN_SRC_DIR)
	unzip -q $(UPSTREAM_SRC).zip
	mv $(UPSTREAM_SRC) $(DEBIAN_SRC_DIR)
	rm $(DEBIAN_SRC_DIR)/doc/manual.pdf # will be rebuild from latex
	GZIP="--best --no-name" tar czf $(DEBIAN_SRC_TAR) $(DEBIAN_SRC_DIR)
	rm -rf $(DEBIAN_SRC_DIR)
	rm $(UPSTREAM_SRC).zip
