#!/usr/bin/make -f
# Samhain debian/rules 
# GNU copyright 20001 to 2003 by Javier Fernandez-Sanguino
# based on
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Modified to use mydefargs by Rainer Wichmann.
#

%:
	dh $@ --with-autoreconf

override_dh_clean:
	[ ! -f Makefile ] || $(MAKE) distclean
	-rm -f samhainrc.install
	-rm -f build-stamp build-server-stamp build-client-stamp
	dh_clean

override_dh_auto_configure:
	@top_srcdir@/configure @mydefargs@

override_dh_auto_build:
	dh_auto_build
	if ! test x$(PASSWORD) = x; then \
		if test -f samhain_setpwd; then \
			./samhain_setpwd samhain new $(PASSWORD); \
			rm samhain; \
			mv samhain.new samhain; \
		fi; \
	fi

override_dh_auto_install:
	$(MAKE) install install-boot DESTDIR=`pwd`/debian/@install_name@

override_dh_install:
	# However, remove the rc.d links
	-rm -rf `pwd`/debian/@install_name@/etc/rc?.d

override_dh_installdocs:
	dh_installdocs
	[ -f debian/@install_name@/usr/share/doc/@install_name@/MANUAL-2_4.html.tar ] && \
		cd debian/@install_name@/usr/share/doc/@install_name@ && \
		tar xf MANUAL-2_4.html.tar && mv MANUAL-2_4 manual.html && \
		rm -f MANUAL-2_4.html.tar
	[ -f debian/@install_name@/usr/share/doc/@install_name@/MANUAL-2_4.pdf ] && \
		cd debian/@install_name@/usr/share/doc/@install_name@ && \
		mv MANUAL-2_4.pdf manual.pdf

override_dh_installchangelogs:
	dh_installchangelogs docs/Changelog

override_dh_installinit:
	dh_installinit --no-start -- defaults 19

override_dh_usrlocal:
	# do nothing

override_dh_fixperms:
	dh_fixperms
	# Fix the permissions
	chmod o-rX `pwd`/debian/@install_name@/@mydataroot@ \
		`pwd`/debian/@install_name@/@myrpmconffile@
	if ! test "x@mylogdir@" = "x/var/log"; then \
		chmod o-rX `pwd`/debian/@install_name@/@mylogdir@; \
	fi

