#!/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 a recent enough kernel to be validated. If the host kernel
# doesn't support creating MPTCP sockets or have the PM not supporting one
# feature or another, the following tests are going to fail. Easier to ignore
# them for the moment.
TESTS = $(notdir $(basename $(wildcard tests/test-*)))
TESTS_KERNEL = \
	test-path-manager \
	test-commands \
	test-mptcpwrap \
	test-start-stop \
	test-network-monitor

%:
	dh $@

# Restrict tests not to depend on some specific kernels
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	make check VERBOSE=1 TESTS='$(filter-out $(TESTS_KERNEL),$(TESTS))'
	make check VERBOSE=1 TESTS='$(TESTS_KERNEL)' || 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
