#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

# More hardening
export DEB_BUILD_MAINT_OPTIONS	:= hardening=+bindnow

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		--prefix=/usr \
		--includedir=/usr/include/c_icap \
		--sysconfdir=/etc/c-icap \
		--localstatedir=/var \
		--libexecdir=/usr/lib/c_icap

override_dh_auto_install:
	mkdir -p debian/tmp/etc/c-icap
	dh_auto_install
	# install clamav pattern update script
	mkdir -p debian/libc-icap-mod-virus-scan/etc/clamav/onupdateexecute.d/
	cp debian/libc-icap-mod-virus-scan.pattern-update \
		debian/libc-icap-mod-virus-scan/etc/clamav/onupdateexecute.d/libc-icap-mod-virus-scan
	chmod 0755 debian/libc-icap-mod-virus-scan/etc/clamav/onupdateexecute.d/libc-icap-mod-virus-scan

override_dh_fixperms:
	dh_fixperms
	# config permissions
	chmod 0644 debian/libc-icap-mod-virus-scan/etc/c-icap/*
	chmod 0644 debian/libc-icap-mod-urlcheck/etc/c-icap/*
	# template permissions
	chmod 0644 debian/libc-icap-mod-urlcheck/usr/share/c_icap/templates/srv_url_check/*/*
	chmod 0644 debian/libc-icap-mod-virus-scan/usr/share/c_icap/templates/virus_scan/*/*
