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

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

# This is the debhelper compatibility version to use.
export DH_COMPAT=4

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

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

build-stamp:	build

clean:
	dh_testdir
	-[ -f Makefile ] && $(MAKE) clean || true
	rm -f build-arch-stamp install-arch-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
	for i in smtptest pattern bigtest mimeattach.py; do \
		chmod +x $(CURDIR)/debian/sagator/usr/share/doc/sagator/test/$$i; \
	done
	dh_install
	dh_installman
	dh_installchangelogs ChangeLog
	dh_compress -X.pdf -X.html -X.css -X.png
	dh_installinit #--no-start -r
	dh_installdebconf
	dh_strip
	dh_md5sums
	dh_installdeb
	dh_gencontrol
	dh_fixperms -Xconfig -Xsagator.conf
	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:	binary-indep binary-arch binary install build
