#!/usr/bin/make -f

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

# Used by debian/libndpi-wireshark.{install,links}. Evaluated when referenced.
WIRESHARK_PLUGINDIR = $(shell pkg-config --variable=plugindir wireshark)
export WIRESHARK_PLUGINDIR

%:
	dh $@

override_dh_auto_configure:
	./autogen.sh
	dh_auto_configure -- --prefix=/usr --disable-gcrypt

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# disable tests with a broken pcap file
	rm -f tests/pcap/nintendo.pcap
	rm -f tests/pcap/skype-conference-call.pcap
	# disable tests that have inconsistent behavior across architecture due
	# to broken sorting in the test code
	rm -f tests/pcap/skype.pcap
	rm -f tests/pcap/skype_no_unknown.pcap
	rm -f tests/pcap/1kxun.pcap
	# disable tests which are broken in 3.4
	# see https://github.com/ntop/nDPI/issues/1119
	rm -r tests/pcap/exe_download.pcap
	rm -r tests/pcap/ftp_failed.pcap
	rm -r tests/pcap/fuzz-2006-06-26-2594.pcap
	# disable tests which require libgcrypt
	# see https://github.com/ntop/nDPI/issues/1117
	rm -r tests/pcap/gquic.pcap
	rm -r tests/pcap/quic-23.pcap
	rm -r tests/pcap/quic-24.pcap
	rm -r tests/pcap/quic-27.pcap
	rm -r tests/pcap/quic-28.pcap
	rm -r tests/pcap/quic-29.pcap
	rm -r tests/pcap/quic-mvfst-22.pcap
	rm -r tests/pcap/quic-mvfst-27.pcap
	rm -r tests/pcap/quic-mvfst-exp.pcap
	rm -r tests/pcap/quic_q50.pcap
	rm -r tests/pcap/quic_t50.pcap
	rm -r tests/pcap/quic_t51.pcap
	#
	cd tests && LD_LIBRARY_PATH=$(CURDIR)/src/lib ./do.sh
endif

override_dh_strip:
	dh_strip --dbgsym-migration='libndpi-dbg (<< 1.8-1~)'


.PHONY: override_dh_auto_configure override_dh_strip
