#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
export DH_GOPKG := github.com/containernetworking/plugins
BUILDDIR := $(shell pwd)
DESTDIR := $(BUILDDIR)/debian/tmp
ifneq (,$(wildcard /usr/lib/go-1.15/bin/go))
        GO_BINARY := /usr/lib/go-1.15/bin/go
else ifneq (,$(wildcard /usr/lib/go-1.14/bin/go))
        GO_BINARY := /usr/lib/go-1.14/bin/go
else
        GO_BINARY := /usr/bin/go
endif
GO := GOPATH=$(BUILDDIR) GO111MODULE=off $(GO_BINARY)
UPSTREAM_TAG=v0.9.1

%:
	dh $@ --buildsystem=golang --with=golang --builddirectory=$(BUILDDIR)

override_dh_clean:
	dh_clean
	rm -rf $(BUILDDIR)/src $(BUILDDIR)/obj-*-linux-gnu $(BUILDDIR)/bin $(BUILDDIR)/gopath

override_dh_auto_configure:
	dh_auto_configure -O--buildsystem=golang
	# Include vendored dependencies
	cp -rp $(BUILDDIR)/vendor $(BUILDDIR)/src
	mkdir -p $(BUILDDIR)/src/$(DH_GOPKG)
	#rsync -a $(BUILDDIR)/* $(BUILDDIR)/src/$(DH_GOPKG) --exclude src

override_dh_auto_build:
	GO=$(GO_BINARY) ./build_linux.sh

override_dh_auto_install:
	install -dp $(DESTDIR)/opt/cni/bin
	install -p -m 755 $(BUILDDIR)/bin/* $(DESTDIR)/opt/cni/bin

override_dh_auto_test:

