#!/usr/bin/make -f

# Export all hardening flags
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with autoreconf

override_dh_autoreconf:
# "aclocal" fails without "m4" directory
	[ -d 'm4' ] || mkdir 'm4'
	dh_autoreconf
	rmdir --ignore-fail-on-non-empty 'm4'

override_dh_auto_configure: src/gitversion.h.in
	PYTHON_VERSION=3; export PYTHON_VERSION; \
	dh_auto_configure -- \
	--enable-notifications \
	--enable-python-plugins \
	--enable-c-plugins \
	--enable-plugins \
	--enable-omemo \
	--enable-otr \
	--enable-pgp \
	--enable-icons \
	--with-xscreensaver \
	--libdir=/usr/lib/profanity

override_dh_auto_install:
	dh_auto_install
	sed -i "/dependency_libs/ s/'.*'/''/" `find . -name '*.la'`

src/gitversion.h.in:
	echo "#ifndef PROF_GIT_BRANCH" > $@
	echo "#define PROF_GIT_BRANCH \"debian/experimental\"" >> $@
	echo "#endif" >> $@
	echo "#ifndef PROF_GIT_REVISION" >> $@
	echo "#define PROF_GIT_REVISION \"$(dpkg-parsechangelog --show-field Version)\"" >> $@
	echo "#endif" >> $@
