#!/usr/bin/make -f
#
# Shorewall firewall (http://www.shorewall.net)
# debianized version

export DH_COMPAT=3

# Include dpatch stuff.
include /usr/share/dpatch/dpatch.make

# shorewall version
#export V=`cat install.sh | grep "^VERSION=" | head -n 1 | cut -f 2 -d "="`

SRWL=$(CURDIR)/debian/shorewall

build: patch build-stamp
#debian/po/templates.pot
build-stamp:
	dh_testdir
# 	there's nothing to compile ;-)
	touch build-stamp

#debian/po/templates.pot: debian/shorewall.templates
#	@debconf-updatepo
#	@podebconf-report-po

clean: clean-patched unpatch

clean-patched:
	dh_testdir
	dh_testroot
	rm -f build-stamp
# 	clean the build directory
	rm -rf $(SRWL)
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	dh_install

# 	Temporary zones are only available to root
	chmod 750 $(SRWL)/var/lib/shorewall
# 	As well as configuration files
	chmod 750 $(SRWL)/etc/shorewall
	chmod 640 $(SRWL)/etc/shorewall/*
# 	set version number
	echo $V > $(SRWL)/usr/share/shorewall/version
#  global configuration has to be fully readable
	chmod 644 $(SRWL)/usr/share/shorewall/*
#  must be executable
	chmod 755 $(SRWL)/usr/share/shorewall/help
	chmod 755 $(SRWL)/usr/share/shorewall/shorewall
	chmod 755 $(SRWL)/usr/share/shorewall/firewall
	chmod 755 $(SRWL)/usr/share/shorewall/functions
	#chmod 755 $(SRWL)/usr/share/shorewall/wait4ifup
	#chmod 755 $(SRWL)/usr/share/shorewall/update-bogons


binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdocs releasenotes.txt COPYING INSTALL README.txt
	#debian/NEWS.Debian 
	dh_installman debian/shorewall.8
	dh_installchangelogs changelog.txt
	dh_installlogrotate
	dh_installinit --no-start -u"start 40 S . stop 89 0 6 ."
	dh_installdebconf
	dh_compress -Xusr/share/doc/shorewall/default-config
	dh_fixperms -Xetc/shorewall -Xvar/lib/shorewall
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch: build install

binary: binary-indep binary-arch

.PHONY: build clean binary-indep binary-arch binary install patch unpatch \
clean-patched
