#!/usr/bin/make -f
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.

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

SHELL=/bin/sh

build: build-stamp
build-stamp:
	dh_testdir
	./configure --prefix=/usr \
		--enable-spooldir=/var/spool/news \
		--disable-lua \
	    	--sysconfdir=/etc/news/leafnode \
	    	--with-pam
	$(MAKE)
	$(MAKE) README
	$(MAKE) check
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	[ ! -f Makefile ] || $(MAKE) -i distclean
	rm -f config.log
	rm -f debian/*~
	dh_clean

# Build architecture-independent files here.
binary-indep: build
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build
	dh_testdir
	dh_testroot
	dh_clean
	dh_installdirs 
	$(MAKE) DESTDIR=debian/leafnode/ mandir=/usr/share/man install
	rm debian/leafnode/usr/bin/lsmac.pl
	rm debian/leafnode/usr/share/man/man1/lsmac.1
	mv debian/leafnode/usr/sbin/sendbatch.bash debian/leafnode/usr/bin/sendbatch
	rm debian/leafnode/etc/news/leafnode/*.example
	cp debian/filters debian/leafnode/etc/news/leafnode/
	cp debian/touch_newsgroup debian/leafnode/usr/bin
	cp debian/touch_newsgroup.1 debian/leafnode/usr/share/man/man1	
	cp debian/moderators debian/leafnode/etc/news/leafnode/
	cp debian/bug debian/leafnode/usr/share/bug/leafnode
	chmod +x debian/leafnode/usr/share/bug/leafnode
	dh_installdocs
	cp config.example debian/leafnode/usr/share/leafnode
	cp debian/debian-config debian/leafnode/usr/share/leafnode
	cp debian/do-fetch-news debian/leafnode/etc/news/leafnode/do-fetch-news
	dh_installexamples tools/archivefaq.pl tools/lsmac.pl tools/make_pass.pl filters.example
	(cd debian/leafnode/usr/share/doc/leafnode/examples ; ln -s ../../../leafnode/config.example . )
	mv debian/leafnode/usr/share/man/man5/moderators.5 debian/leafnode/usr/share/man/man5/leafnode-moderators.5
	touch debian/leafnode/etc/news/leafnode/local.groups
	dh_installmenu
	dh_installdebconf
	dh_installcron
	dh_installchangelogs
	dh_installppp
	dh_installlogcheck
	dh_installlogrotate
	dh_strip
	dh_compress
	dh_fixperms
	chown -R news:news debian/leafnode/var/spool/news
	chmod 2775 debian/leafnode/var/spool/news
	chmod a+x debian/leafnode/etc/news/leafnode/do-fetch-news
	dh_installdeb
	dh_shlibdeps
	dh_perl
	dh_gencontrol
	dh_md5sums
	dh_builddeb

source diff:                                                                  
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary
