#!/usr/bin/make -f

#export DH_VERBOSE := 1
#export DH_GOLANG_GO_GENERATE := 1
export DH_GOLANG_EXCLUDES := benchmark xds cmd security/authorization interop/client \
                             credentials/tls/certprovider/meshca/internal/meshca_experimental \
			     security/advancedtls
export DH_GOLANG_INSTALL_EXTRA = $(shell find . -name '*.sh')

export PATH := $(CURDIR)/debian:$(PATH)
export CURDIR := $(CURDIR)

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

#override_dh_auto_configure:
#	dh_auto_configure
### Build integrity: remove generated .pb.go files whenever possible:
#	-find _build \
#            -not -path '*/binarylog/grpc_binarylog_v1/*' \
#            -not -path '*/reflection/*' \
#            -type f -name '*.pb.go' -delete -printf 'removed %p\n'

override_dh_auto_test:
	-DH_GOLANG_EXCLUDES="$(DH_GOLANG_EXCLUDES) internal/resolver/dns internal/proto/grpc_service_config" \
	dh_auto_test -- -short

override_dh_auto_install:
	dh_auto_install -- --no-binaries
	cp $(CURDIR)/credentials/google/xds.go $(CURDIR)/debian/golang-google-grpc-dev/usr/share/gocode/src/google.golang.org/grpc/credentials/google/
	cp $(CURDIR)/internal/xds_handshake_cluster.go $(CURDIR)/debian/golang-google-grpc-dev/usr/share/gocode/src/google.golang.org/grpc/internal/
