#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
#
# [ Modified - 06/07/2006 ]
#

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

build: build-stamp
build-stamp:
	dh_testdir

	CC=cc CFLAGS=-O2 ./configure --prefix=/usr/lib/zmailer \
		--with-postoffice=/var/spool/postoffice \
		--with-system-malloc \
		--with-mailshare=/etc/zmailer \
		--with-mailvar=/etc/zmailer \
		--with-zconfig=/etc/zmailer/zmailer.conf \
		--with-mailbin=/usr/lib/zmailer \
		--includedir=/usr/lib/zmailer \
		--with-sendmailpath=/usr/sbin/sendmail \
		--with-logdir=/var/log/zmailer \
		--with-rmailpath=/usr/sbin/rmail \
		--with-openssl-include=/usr/include/openssl \
		--with-openssl-lib=/usr/lib \
		--with-embed-perl \
		--with-spf \
		--with-srs

	# Add here commands to compile the package.
	$(MAKE) 

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	# Add here commands to clean up after the build process.
	-$(MAKE) distclean
	rm -f config.status

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	# Add here commands to install the package into debian/zmailer-ssl.
	$(MAKE) install DESTDIR=`pwd`/debian/zmailer-ssl

	touch install-stamp

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

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installexamples
	dh_installmenu
	dh_installinit
	dh_installcron
	dh_installmanpages
	dh_installinfo
	dh_undocumented newfqdnaliases.1
	dh_installchangelogs ChangeLog
	dh_link
	dh_strip
	dh_compress
	dh_fixperms

	rm -f debian/zmailer-ssl/etc/zmailer/ChangeLog
	rm -f debian/zmailer-ssl/etc/zmailer/config.status

	(cd debian/zmailer-ssl/usr/sbin && rm -f rmail ; \
		ln -s ../lib/zmailer/rmail)
	(cd debian/zmailer-ssl/usr/sbin && rm -f sendmail ; \
		ln -s ../lib/zmailer/sendmail)
	(cd debian/zmailer-ssl/usr/bin && rm -f newaliases ; \
		ln -s ../lib/zmailer/newaliases)
	(cd debian/zmailer-ssl/usr/bin && rm -f mailq ; \
		ln -s ../lib/zmailer/mailq)
	(cd debian/zmailer-ssl/usr/bin && rm -f vacation ; \
		ln -s ../lib/zmailer/vacation.sh vacation)
	(cd debian/zmailer-ssl/etc/zmailer/cf/ && cp proto/* ./)

	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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