#!/usr/bin/make -f

export DH_VERBOSE = 1
export GOCACHE=$(CURDIR)/_build
export GOPATH=$(CURDIR)/_build
export GOPROXY=off


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

override_dh_auto_install:
	dh_auto_install -- --no-source

	#generate completion files
	$(CURDIR)/debian/hubble/usr/bin/hubble completion bash >$(CURDIR)/debian/hubble.bash
	$(CURDIR)/debian/hubble/usr/bin/hubble completion zsh >$(CURDIR)/debian/_hubble

override_dh_dwz:

override_dh_installdocs:
	dh_installdocs
	mkdir -p debian/hubble/usr/share/doc/hubble/grpc
	cp vendor/google.golang.org/grpc/NOTICE.txt debian/hubble/usr/share/doc/hubble/grpc
	mkdir -p debian/hubble/usr/share/doc/hubble/yaml.v3
	cp vendor/gopkg.in/yaml.v3/NOTICE debian/hubble/usr/share/doc/hubble/yaml.v3

execute_before_dh_auto_build:
	cp vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb _build/src/github.com/cilium/hubble/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb
	cp -r vendor/github.com/go-openapi/spec/schemas _build/src/github.com/cilium/hubble/vendor/github.com/go-openapi/spec/
	mkdir -p _build/src/github.com/cilium/hubble/vendor/github.com/google/cel-go/cel/templates/
	cp vendor/github.com/google/cel-go/cel/templates/authoring.tmpl _build/src/github.com/cilium/hubble/vendor/github.com/google/cel-go/cel/templates/
