#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk
export DH_GOLANG_INSTALL_EXTRA=config/default_styleset contrib/aerc.desktop

# Installation paths
export DESTDIR=$(CURDIR)/debian/aerc
export PREFIX=/usr

# Go options
export GO111MODULE=off
export GOPROXY=off
export GOCACHE=$(CURDIR)/_build/go-build
export GOPATH=$(CURDIR)/_build
export GOFLAGS=-tags=notmuch -buildmode=pie

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

override_dh_auto_configure:
	dh_auto_configure
	cp Makefile _build/src/git.sr.ht/~rjarry/aerc/
	cp -r doc filters templates _build/src/git.sr.ht/~rjarry/aerc/
	cp config/*.conf* _build/src/git.sr.ht/~rjarry/aerc/config/

override_dh_auto_build:
	cd _build/src/git.sr.ht/~rjarry/aerc && $(MAKE) LDFLAGS="-extldflags -Wl,-z,now -s -w -X 'main.Version=$(DEB_VERSION_UPSTREAM)'"


override_dh_auto_install:
	cd _build/src/git.sr.ht/~rjarry/aerc && $(MAKE) install
