#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
include /usr/share/dpkg/pkg-info.mk
# 0.4.1's Makefile leaves CPPFLAGS out of the compile line, which drops _FORTIFY_SOURCE.
export DEB_CFLAGS_MAINT_APPEND := $(shell dpkg-buildflags --get CPPFLAGS)

%:
	dh $@

override_dh_auto_build:
	dh_auto_build -- build/t-code

override_dh_auto_install:
	dh_auto_install -- PREFIX=/usr
	desktop-file-validate debian/t-code-ide/usr/share/applications/io.github.suacayipkisi.tcode.desktop

# The other tests open windows and need a display.
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	@echo "Debian checks: verifying installed binary"
	build/t-code --version | grep -qx 't-code $(DEB_VERSION_UPSTREAM)'
	@echo "Debian checks: compiling headless tests"
	$(MAKE) build/test-searchmatch build/test-detect build/test-linediff
	@echo "Debian checks: running searchmatch"
	build/test-searchmatch
	@echo "Debian checks: running detect"
	build/test-detect
	@echo "Debian checks: running linediff"
	build/test-linediff
endif
