#!/usr/bin/make -f

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

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

dep_ver:= $(shell echo $(DEB_VERSION_UPSTREAM) | cut -d '.' -f -2)

ifneq ($(DEB_CCACHE_DIR),)
export PATH:=$(DEB_CCACHE_DIR):${PATH}
endif

%:
	dh $@

override_dh_auto_clean:
	dh_auto_clean
	# remove stamp files
	$(RM) stamp-*
	# remove a socket used for tests
	$(RM) test/gils/socket

clean:
	# remove generated files
	$(RM) doc/*.html doc/manref.xml doc/htmlhelp.hhp doc/toc.hhc \
		doc/*.1 doc/*.8 doc/gils.txt doc/gils.ps \
		test/gils/out test/zsh/test*.zsh.out \
		doc/manref.xml
	# remove autoconf generated files
	find . -name Makefile.in -exec $(RM) {} \;
	$(RM) aclocal.m4 configure config/* m4/libtool.m4 \
		config.guess config.sub m4/lt*.m4
	$(RM) doc/local.ent doc/common/print.dsl idzebra.spec \
		idzebra-config-2.0 Doxyfile win/version.nsi \
		include/idzebra/version.h
	# if this is a git repository, restore removed files that would have
	# been ignored by dpkg-source
	-test -d .git && git checkout -- $$(git status | \
		sed -e '/^#[[:space:]]*deleted:[[:space:]]*/s/^#[[:space:]]*deleted:[[:space:]]*//p;d' | \
		grep -v '^debian/')

override_dh_makeshlibs:
	dh_makeshlibs -a -V 'libidzebra-2.0-0 (>= $(dep_ver))' -X mod-

override_dh_shlibdeps:
	dh_shlibdeps -a -- --warnings=7
