#!/usr/bin/make -f

export DH_GOLANG_INSTALL_EXTRA := $(wildcard fuzzing/*/corpus)

# Determine major and minor go version, e. g. 1.24
# This is only needed to support go 1.24 in testing,
# can be removed once go 1.26 has migrated.
goversion := $(shell go env GOVERSION | sed -e "s/^go//" | cut -d. -f1-2)
ifeq ($(goversion),1.24)
# Experimental package needed for running the test suite in go 1.24
export GOEXPERIMENT := synctest
endif

# Unclear why this is necessary, it should be the default.
export GODEBUG := asynctimerchan=0

execute_after_dh_auto_configure:
	find _build -name sys_conn_oob_test.go -print -delete

# Work around unpackaged github.com/quic-go/go-ossfuzz-seeds
SRCDIR=./_build/src/github.com/quic-go/quic-go
execute_before_dh_auto_build:
	find|grep frame_sorter_test.go
	rm -fv \
		$(SRCDIR)/frame_sorter_test.go \
		$(SRCDIR)/internal/wire/header_test.go \
		$(SRCDIR)/internal/wire/frame_parser_test.go \
		$(SRCDIR)/internal/wire/transport_parameter_test.go \
		$(SRCDIR)/internal/handshake/handshake_fuzz_test.go \
		$(SRCDIR)/http3/headers_test.go \
		$(SRCDIR)/http3/frames_test.go

execute_after_dh_auto_test:
	find _build -name keylog.txt -print -delete

# Skip some flaky tests
SKIP='TestHTTP3StreamPriority'
override_dh_auto_test:
	-dh_auto_test $(DH_BUILD_OPTS) -- \
		-run=$(SKIP)
	dh_auto_test $(DH_BUILD_OPTS) -- \
		-skip=$(SKIP)

override_dh_auto_install:
	dh_auto_install -- --no-binaries

%:
	dh $@ --builddirectory=_build --buildsystem=golang
