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

include /usr/share/dpkg/architecture.mk

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
dpkg-buildflags = DEB_BUILD_MAINT_OPTIONS="hardening=+all" dpkg-buildflags

build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp:
	dh_testdir
	cp FAQ.* debian
	cp t.pcre_extract debian
	./configure \
		--build=$(DEB_BUILD_GNU_TYPE) \
		--host=$(DEB_HOST_GNU_TYPE) \
		--prefix=/usr \
		--with-spooldir=/var/spool/news \
		--sysconfdir=/etc/news/leafnode \
		$(shell $(dpkg-buildflags) --export=configure)
	$(MAKE)
	$(MAKE) README-FQDN
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) check
endif
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	if [ -f Makefile ]; then $(MAKE) -i distclean ; fi
	rm -f config.log
	-mv debian/FAQ.* .
	-mv debian/t.pcre_extract .
	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/etc/news/leafnode/config.example
	rm debian/leafnode/etc/news/leafnode/*.dist
	rm debian/leafnode/etc/news/leafnode/UNINSTALL-daemontools
	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
	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 filters.example
	(cd debian/leafnode/usr/share/doc/leafnode/examples ; ln -s ../../../leafnode/config.example . )
	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 2755 debian/leafnode/var/spool/news
	chmod a+x debian/leafnode/etc/news/leafnode/do-fetch-news
	rm debian/leafnode/etc/news/leafnode/filters.example
	dh_installdeb
	dh_perl
	dh_shlibdeps
	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
