#!/usr/bin/make -f

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

# Jitter-generated code won't work with LTO.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=-lto

# The configure flags we use for poke.
POKE_CONFIGURE_FLAGS = \
	--disable-rpath \
	--disable-hserver \
	--disable-gui

%:
	dh $@ --with elpa,vim_addon

override_dh_auto_configure:
	dh_auto_configure -- $(POKE_CONFIGURE_FLAGS)

override_dh_auto_install:
	dh_auto_install
	rm -v \
		debian/tmp/usr/lib/*/libpoke.a \
		debian/tmp/usr/lib/*/libpoke.la \
		debian/tmp/usr/bin/pk-elfextractor \
		debian/tmp/usr/bin/pk-strings \
		debian/tmp/usr/bin/pk-bin2poke

PKGEL_VERSION = $(subst +dfsg,,$(DEB_VERSION_UPSTREAM))

override_dh_elpa:
	sed "s@%VERSION%@\"$(PKGEL_VERSION)\"@" \
		debian/poke-pkg.el.in \
		> debian/tmp/usr/share/emacs/site-lisp/poke-pkg.el
	dh_elpa

override_dh_auto_clean:
ifneq (,$(wildcard ./Makefile))
	dh_auto_clean
endif
