#!/usr/bin/make -f
# -*- makefile -*-
#
export DH_VERBOSE=1

USERNAME := $(shell echo $$USER)
GOLDFLAGS := -ldflags '-extldflags "-static"'
GOFLAGS := -buildmode=pie  -mod=vendor -a $(GOLDFLAGS)

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@

ifeq ($(USERNAME), abuild)
override_dh_auto_configure:
	tar xf ../SOURCES/vendor.tar.gz

override_dh_auto_build:
	make all

override_dh_auto_test:
endif

override_dh_fixperms:
	dh_fixperms
	chmod 0644 debian/tmp/etc/okta-auth-validator/pinset.cfg
	chmod 0640 debian/tmp/etc/okta-auth-validator/api.ini

override_dh_auto_install:
	make install DESTDIR=$(CURDIR)/debian/tmp LIB_PREFIX=/usr/lib/$(DEB_HOST_MULTIARCH)
