#!/usr/bin/make -f
# The Debian and Ubuntu package (a PPA, one day the archive): installed in /usr, updated by apt, so built without
# the updater of the GitHub .deb (LEMURI_SELF_UPDATE). The tests that need neither a display nor Python run here too
# (the backend's modules, on loopback at most; DEB_BUILD_OPTIONS=nocheck skips them); the rest, with an SSH server and
# Python modules that a build machine has not, run in the CI of the repository.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/dpkg/architecture.mk

ifneq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
TESTS = OFF
else
TESTS = ON
endif

%:
	dh $@ --buildsystem=cmake+ninja

override_dh_auto_configure:
	dh_auto_configure -- -DLEMURI_SELF_UPDATE=OFF -DLEMURI_TESTS=$(TESTS) -DLEMURI_TOOLS=OFF

override_dh_auto_test:
ifeq ($(TESTS),ON)
	ctest --test-dir obj-$(DEB_HOST_GNU_TYPE) --output-on-failure --no-tests=error \
	  -R '^(UpdatesTest|StoreTest|BackupTest|MonitoringTest|SharingTest|SshTest|DockTest)$$'
else
	@echo "nocheck: no tests"
endif
