#!/usr/bin/make -f

export DH_GOLANG_INSTALL_EXTRA := \
	internal/data/x86.v0.2.csv \
	internal/data/x86_64.xml \
	internal/opcodesxml/testdata/x86_64.xml \
	tests/thirdparty/packages.json

include /usr/share/dpkg/pkg-info.mk

ifeq ($(filter $(DEB_TARGET_ARCH), amd64),)
export DH_GOLANG_EXCLUDES := \
	examples \
	tests/alloc/upper32 \
	tests/alloc/gp8 \
	tests/alloc/masks \
	tests/cast \
	tests/fixedbugs/issue50 \
	tests/fixedbugs/issue65 \
	tests/fixedbugs/issue68 \
	tests/fixedbugs/issue76 \
	tests/fixedbugs/issue89 \
	tests/fixedbugs/issue100/allocfail \
	tests/fixedbugs/issue100/minrepro \
	tests/fixedbugs/issue122 \
	tests/fmt \
	tests/labels \
	tests/textflag
endif

%:
	dh $@ --buildsystem=golang --with=golang

ifeq ($(filter nocheck, $(DEB_BUILD_OPTIONS)),)
override_dh_auto_test:
	cd obj-$(DEB_HOST_GNU_TYPE)/src/github.com/mmcloughlin/avo/internal/opcodescsv; \
		ln -s ../data testdata
	cd obj-$(DEB_HOST_GNU_TYPE)/src/github.com/mmcloughlin/avo/internal/load; \
		ln -s ../data testdata
	dh_auto_test
endif
