#!/usr/bin/make -f

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

DESTDIR := $(CURDIR)/debian/rvthtool

%:
	dh $@ --parallel -Bbuild

CMAKE_OPTIONS := \
	-DCMAKE_BUILD_TYPE=Release \
	-DSPLIT_DEBUG=OFF \
	-DENABLE_LTO=OFF
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
CMAKE_OPTIONS += -DBUILD_TESTING=ON
endif

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKE_OPTIONS)

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	CTEST_OUTPUT_ON_FAILURE=1 $(MAKE) -C build test
endif

# Remove the extra LICENSE file.
override_dh_auto_install:
	dh_auto_install
	rm $(DESTDIR)/usr/share/doc/rvthtool/LICENSE
