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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

CFLAGS += $(CPPFLAGS)
CXXFLAGS += $(CPPFLAGS)

%:
	dh $@


override_dh_auto_build:
	rm -f Cargo.lock
	rm -f 3rd-party/catch*
	ln -sf /usr/include/catch2/catch_all.hpp 3rd-party/catch.hpp
	ln -sf /usr/include/nlohmann/json.hpp 3rd-party/
	dh_auto_build -- CARGO_HOME=debian/cargo_home prefix=/usr all
	make doc

override_dh_auto_install:
	dh_auto_install -- prefix=/usr
	install -m644 debian/config.default $(CURDIR)/debian/newsboat/etc/newsboat/config

override_dh_auto_test:
	-dh_auto_test -- CARGO_HOME=debian/cargo_home
ifeq (,$(filter nocheck, $(DEB_BUILD_OPTIONS)))
	-cd test && LC_ALL=C.UTF-8 TERM=dumb ./test --order rand
	-CARGO_HOME=debian/cargo_home cargo test
endif
