#!/usr/bin/make -f

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

export GOPATH=$(shell pwd)/.go
export DEB_BUILD_OPTIONS=crossbuildcanrunhostbinaries

export GOARCH := $(shell if [ $(DEB_TARGET_ARCH) = "i386" ]; then echo "386"; elif [ $(DEB_TARGET_ARCH) = "armhf" ]; then echo "arm"; else echo  $(DEB_TARGET_ARCH); fi)

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

override_dh_auto_clean:
	rm -rf build/
	rm -rf obj-$(DEB_TARGET_GNU_TYPE)/
	dh_auto_clean

override_dh_auto_test:
	# disabled

override_dh_auto_install:
	dh_auto_install -- --no-source

# only with full debian dependencies:
override_dh_golang:

# not needed with golang, fails with cross compiling
# override_dh_makeshlibs:

override_dh_auto_build:
	echo $(DEB_VERSION) > VERSION
	go build -o build/aptly
