#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export CUDA_HOME=/usr
ifneq (,$(shell command -v nvcc)) # XXX: CUDA
export CC=cuda-gcc
export CXX=cuda-g++
endif

ifneq (,$(filter $(DEB_HOST_ARCH), armel m68k mipsel powerpc riscv64 sh4))
  export DEB_LDFLAGS_MAINT_APPEND += -Wl,--no-as-needed -latomic -Wl,--as-needed
endif

%:
	dh $@ -Scmake

override_dh_auto_configure:
	-$(RM) -rfv third_party/googletest third_party/libuv
	ln -sfv /usr/src/googletest third_party/
ifneq (,$(shell command -v nvcc))
	dh_auto_configure -- -DBUILD_SHARED_LIBS=ON -DTP_BUILD_TESTING=ON -DTP_USE_CUDA=ON
else
	dh_auto_configure -- -DBUILD_SHARED_LIBS=ON -DTP_BUILD_TESTING=ON
endif
