#! /usr/bin/make -f

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

PYVERSIONS=$(shell pyversions -r)

build:	build-stamp

build-stamp:
	dh_testdir
	./configure --prefix /usr
	$(MAKE) all
	touch $@

clean:
	dh_testdir
	[ ! -f Makefile ] || $(MAKE) clean
	rm -f install-stamp build-stamp
	dh_clean

install-stamp: build
	dh_testdir
	./configure --prefix /usr
	$(MAKE) install DESTDIR=$(CURDIR)/debian/sagator/
	rm -f $(CURDIR)/debian/var/spool/vscan
	touch install-stamp

install:	install-stamp

sagator: install
	dh_testdir
	dh_installdirs
	dh_installdocs
	dh_installchangelogs ChangeLog
	for i in smtptest pattern bigtest mimeattach.py; do \
		chmod +x $(CURDIR)/debian/sagator/usr/share/doc/sagator/test/$$i; \
	done
	dh_install
	dh_pycentral
	dh_installman
	dh_compress -X.pdf -X.html -X.css -X.png
	dh_installinit #--no-start -r
	dh_installdebconf
	dh_strip
	dh_fixperms -Xconfig -Xsagator.conf
	dh_md5sums
	dh_installdeb
	dh_gencontrol
	dh_builddeb

# Build architecture independant packages using the common target.
binary-indep: install sagator

# Build architecture dependant packages using the common target.
binary-arch: install

binary: clean binary-indep binary-arch

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