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

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

DEB_BUILD_ARCH     ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)

ifneq (,$(filter $(DEB_BUILD_ARCH),mips mipsel))
	export DEB_CXXFLAGS_MAINT_APPEND = --param ggc-min-expand=20
endif

CMAKE_FLAGS = \
	-DCMAKE_BUILD_TYPE:STRING=None \
	-DBUILD_MATLAB_BINDINGS:BOOL=OFF \
	-DBUILD_PYTHON_BINDINGS:BOOL=OFF \
	-DUSE_MPI:BOOL=ON \
	-DUSE_OPENMP:BOOL=ON \
	-DFLANN_LIB_INSTALL_DIR:STRING="lib/$(DEB_HOST_MULTIARCH)" \
	-DBUILD_CUDA_LIB:BOOL=OFF

%:
	dh $@ --parallel

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKE_FLAGS)

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

override_dh_compress:
	dh_compress --exclude=.pdf

# Let's be smart with building doc
override_dh_auto_build-indep:
	$(MAKE) -C obj-* doc

# No tests needed for docs
override_dh_auto_test-indep:

get-orig-source:
	uscan --verbose --force-download --repack --rename
