#!/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

# Avoid calculatin differences in timing that make the build
# fail on i386 (see https://bugs.debian.org/981771)
ifneq (,$(filter $(DEB_HOST_ARCH), i386))
    export DEB_CFLAGS_MAINT_APPEND += -ffloat-store
endif

# 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

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
	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
