#!/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-light 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
	# Remove samhain_stealth for light install
	-rm -f `pwd`/debian/@install_name@/@sbindir@/@install_name@_stealth
	# remove samhain_setpwd if not needed
	if ! test x$(PASSWORD) = x; then \
		rm -f `pwd`/debian/@install_name@/@sbindir@/@install_name@_setpwd; \
	fi

override_dh_installdocs:
	# do nothing

override_dh_installchangelogs:
	# do nothing

override_dh_installman:
	# do nothing

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


