#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk
include /usr/share/gnulib/debian/gnulib-dpkg.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 $@ --without autoreconf --with elpa,vim_addon

# Gnulib auxiliary targets.
gnulib_pull:
	./bootstrap --gnulib-srcdir=$(GNULIB_DEB_DEBIAN_GNULIB) --pull
gnulib_gen:
	./bootstrap --gnulib-srcdir=$(GNULIB_DEB_DEBIAN_GNULIB) --gen

# We're cloning directly from git, so we have to run bootstrap
# ourselves.
execute_before_dh_auto_configure: dh_gnulib_clone gnulib_pull dh_gnulib_patch gnulib_gen

override_dh_auto_configure:
	dh_auto_configure -- $(POKE_CONFIGURE_FLAGS)

execute_after_dh_auto_install:
	rm -v debian/tmp/usr/lib/*/libpoke.la

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
