#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

include /usr/share/dpkg/architecture.mk

%:
	dh $@

# The upstream build can generate four "flavours" which differ by how
# they read keystrokes. Only the x11 and libinput flavours are
# relevant here, the other two are for Microsoft Windows and MacOS.
# The libinput flavour is Linux-only. Build profiles are set up to
# disable each of these.

CONFIGURE_FLAGS = --bindir=/usr/games --enable-tray

ifeq ($(filter pkg.bucklespring.nox11,$(DEB_BUILD_PROFILES)),)
CONFIGURE_FLAGS += --enable-x11
else
CONFIGURE_FLAGS += --disable-x11
endif

ifneq ($(filter pkg.bucklespring.nolibinput,$(DEB_BUILD_PROFILES)),)
CONFIGURE_FLAGS += --disable-libinput
else ifeq ($(DEB_HOST_ARCH_OS),linux)
CONFIGURE_FLAGS += --enable-libinput
else
CONFIGURE_FLAGS += --disable-libinput
endif

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_FLAGS)

# Not enabled by default: annoying keyboard noises should be opt-in.
override_dh_installsystemduser:
	dh_installsystemduser --no-enable
