#!/usr/bin/make -f
SIZES ?= 16x16 22x22 24x24 32x32 36x36 48x48 64x64 72x72 96x96 128x128 192x192 256x256 512x512 1024x1024

export HOME = $(CURDIR)

%:
	dh $@

override_dh_auto_test:
	DEB_BUILD_OPTIONS=nocheck dh_auto_test

override_dh_auto_build:
	GOPROXY='https://proxy.golang.org,direct' GOFLAGS="{{ .GoFlags }}" sh -c '{{ .GoGenerate }}'
	GOPROXY='https://proxy.golang.org,direct' GOFLAGS="{{ .GoFlags }}" CGO_ENABLED=1 go build -ldflags='-compressdwarf=false' -o out/{{ .AppID }} {{ .GoMain }}
	for icon in 16x16 22x22 24x24 32x32 36x36 48x48 64x64 72x72 96x96 128x128 192x192 256x256 512x512; do cp "{{ .GoMain }}/icon-$${icon}.png" out/icon-$${icon}.png; done

override_dh_auto_install:
	install -D out/{{ .AppID }} $$(pwd)/debian/{{ .AppID }}/usr/bin/{{ .AppID }}
	desktop-file-install --dir=$$(pwd)/debian/{{ .AppID }}/usr/share/applications {{ .GoMain }}/{{ .AppID }}.desktop
	appstreamcli validate {{ .GoMain }}/{{ .AppID }}.metainfo.xml
	for icon in 16x16 22x22 24x24 32x32 36x36 48x48 64x64 72x72 96x96 128x128 192x192 256x256 512x512; do install -D -m 0644 out/icon-$${icon}.png $$(pwd)/debian/{{ .AppID }}/usr/share/icons/hicolor/$${icon}/apps/{{ .AppID }}.png; done
	install -D -m 0644 {{ .GoMain }}/{{ .AppID }}.metainfo.xml $$(pwd)/debian/{{ .AppID }}/usr/share/metainfo/{{ .AppID }}.metainfo.xml
