#!/usr/bin/make -f

export DH_VERBOSE=1

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DEB_VERSION ?= $(shell dpkg-parsechangelog -SVersion)

GOLANG_NATIVE_VERSION := $(shell dpkg-query --showformat='${Version}' --show golang 2>/dev/null || echo 0)
ifneq (ok,$(dpkg --compare-versions $(GOLANG_NATIVE_VERSION) ge 2:1.13 && echo ok))
	export GODIR := /usr/lib/go-1.13
	export PATH := $(GODIR)/bin:$(PATH)
endif

%:
	dh $@ --with=systemd --warn-missing

override_dh_auto_configure:
	dh_auto_configure -- -DBUILD_ID=$(DEB_VERSION) -DWEBEXT_INSTALL_LIBDIR=lib

override_dh_auto_install:
	dh_auto_install
	rm -rf debian/mozillavpn/etc/opt/chrome

override_dh_installsystemd:
	dh_installsystemd linux/mozillavpn.service

override_dh_systemd_start:
	dh_systemd_start linux/mozillavpn.service

override_dh_systemd_enable:
	dh_systemd_enable linux/mozillavpn.service

override_dh_clean:
	rm -rf addons/generated/ translations/generated/
	dh_clean
