#!/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

%:
	dh $@ --with elpa,vim_addon

# See https://sourceware.org/bugzilla/show_bug.cgi?id=30051 for
# details on why dh_autoreconf can only be executed inside "jitter/".
override_dh_autoreconf:
	dh_autoreconf -Djitter/

override_dh_auto_configure:
	dh_auto_configure -- $(POKE_CONFIGURE_FLAGS)

execute_after_dh_auto_install:
	rm -v \
		debian/tmp/usr/lib/*/libpoke.a \
		debian/tmp/usr/lib/*/libpoke.la \
		debian/tmp/usr/bin/pk-strings \
		debian/tmp/usr/bin/pk-bin2poke \
		debian/tmp/usr/bin/pk-jojopatch

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

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

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