#!/usr/bin/make -f

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh ${@}

override_dh_auto_configure:
	dh_auto_configure -- --enable-debug=info --enable-ipv6 --with-rusnet
	# make reproducible build: replace dates with ones from debian/changelog
	CHANGELOG_DATE="`grep -m1 '^ --' debian/changelog|sed s/^.*\>\ \ //`"; \
	COMPILETIME=`LANG=C LC_TIME=C LC_ALL=C date -u -d "$$CHANGELOG_DATE"`; \
	GENDATE=`LANG=C LC_TIME=C LC_ALL=C date +'%B %Y' -u -d "$$CHANGELOG_DATE"`; \
	sed -i "s/#define COMPILETIME .*$$/#define COMPILETIME \"$$COMPILETIME\"/" config.h; \
	sed -i "s/.TH \"FoxEye\" 1 \"[^\"]*\"/.TH \"FoxEye\" 1 \"$$GENDATE\"/" doc/foxeye.1

override_dh_install:
	dh_install
	dh_missing --fail-missing
	mv debian/foxeye/usr/share/doc/foxeye-* debian/foxeye/usr/share/doc/foxeye

override_dh_makeshlibs:
	# modules are not shared libs so disable processing for them
	dh_makeshlibs -X/foxeye/

override_dh_shlibdeps:
	dh_shlibdeps -lusr/lib/$(DEB_HOST_MULTIARCH)/foxeye
