#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.

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

VERSION = $(DEB_VERSION)_debian
RELEASEDATE = $(shell date --iso-8601 -d @$(SOURCE_DATE_EPOCH))
LDFLAGS := -ldflags="-extldflags -s -w -X main.version=$(VERSION) -X main.date=$(RELEASEDATE)"
ifeq (,$(filter $(DEB_HOST_ARCH), mips mipsel mips64el))
LDFLAGS := -buildmode=pie -ldflags="-extldflags -s -w -X main.version=$(VERSION) -X main.date=$(RELEASEDATE)"
endif

# Perform go generate
export DH_GOLANG_GO_GENERATE := 1

# Add glade files, icons, language files and generate-mos script
export DH_GOLANG_INSTALL_EXTRA := internal/player/glade \
	resources/scripts \
	resources/icons \
	resources/i18n \
	resources/metainfo/com.yktoo.ymuse.metainfo.xml \
	resources/com.yktoo.ymuse.desktop

#export DH_VERBOSE = 1


# See FEATURE AREAS in dpkg-buildflags(1).
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


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


# dh_make generated override targets.
# This is an example for Cmake (see <https://bugs.debian.org/641051>).
#override_dh_auto_configure:
#	dh_auto_configure -- \
#	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

override_dh_auto_build:
	dh_auto_build -- $(LDFLAGS)

override_dh_auto_install:
	dh_auto_install -- --no-source

override_dh_auto_test:
	xvfb-run dh_auto_test