#!/usr/bin/make -f
# export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic

# Some tests require some kernel and network specific features. Because it is
# difficult to support all the different build environments for these unit
# tests, we mark some tests as unstable and ignore their results.
TESTS = $(notdir $(basename $(wildcard tests/test-*)))
TESTS_UNSTABLE = \
	test-commands \
	test-network-monitor

%:
	dh $@

# Force using the MPTCP Upstream kernel implementation
override_dh_auto_configure:
	dh_auto_configure -- \
		--with-kernel=upstream

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	make check VERBOSE=1 TESTS='$(filter-out $(TESTS_UNSTABLE),$(TESTS))'
	make check VERBOSE=1 TESTS='$(TESTS_UNSTABLE)' || true
endif

# Build doc: dedicated target
override_dh_auto_build-indep:
	make doxygen-doc

# We don't want to make shlibs and ldconfig triggers for privates libs, e.g.
# libmptcpwrap, installed in lib/mptcpize, is a lib to be used with LD_PRELOAD
# plugins are installed in lib/mptcpd and are specific to mptcpd
override_dh_makeshlibs:
	dh_makeshlibs -a -X/usr/lib/${DEB_HOST_MULTIARCH}/mptcpd -X/usr/lib/${DEB_HOST_MULTIARCH}/mptcpize
