#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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

# The build embeds and the tests read data files outside testdata (data/english,
# models, platforms/*).
export DH_GOLANG_INSTALL_EXTRA := data internal models platforms scripts

# Upstream's system install (platforms/linux-system) builds lib0c.so and lays
# out the data, icons and shell definitions; it takes the Go binaries from
# SYSBUILD, which is where dh-go puts them.
# The programs report upstream's release, without the +ds part of the package
# version.
UPSTREAM_VERSION := $(firstword $(subst +, ,$(DEB_VERSION_UPSTREAM)))
MAKE_ARGS := PREFIX=/usr VERSION=$(UPSTREAM_VERSION) SYSBUILD=_build/bin SETTINGS=0

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

override_dh_auto_build:
	$(DH_OVERRIDDEN_COMMAND) -- -ldflags '-X main.buildVersion=$(UPSTREAM_VERSION)'
	dh_auto_build --buildsystem=makefile -- build-fcitx5 $(MAKE_ARGS)

# The dictionary and its pairing lock are in the 0c-ime-data source package.
# Upstream's install stops without a manifest, so give it an empty one and do
# not ship it (debian/not-installed).
override_dh_auto_install:
	dh_auto_install --buildsystem=makefile -- $(MAKE_ARGS) DATA=debian/no-dictionary PAIRING_LOCK=debian/no-pairing-lock
