#! /usr/bin/make -f

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

export DH_PYCENTRAL=nomove
PYVERSIONS=$(shell pyversions -r)

build:	build-stamp

build-stamp:
	dh_testdir
	./configure --prefix=/usr --python=python2
	$(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 --python=python2
	$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp/
	rm -f $(CURDIR)/debian/var/spool/vscan
	touch install-stamp

install:	install-stamp

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

# 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
