#################################################################
# Configuration							#
#################################################################

# Perl 5 binary
PERL_BIN	= /usr/local/bin/perl5

# Mailbox quota must be expressed in bytes
MAILBOX_QUOTA	= 4096

# Exim user and group
EXIM_USER	= mail
EXIM_GROUP	= mail

# Directory where you want to put scripts
EXIM_SCRIPT_DIR	= /var/exim/scripts

# Directory where mailboxes reside (usually /var/mail or /var/spool/mail)
MAIL_DIR	= /var/mail
MAIL_DIR_BS	= \/var\/mail

# Directory where you want to put secondary mailboxes
SECONDARY_DIR	= /var/mail/secondary

# Location of exim_lock binary and parameters
# Use no parameters if BOTH primary and secondary mailboxes
# reside on local partitions, AND your OS has fcntl(2) system
# call.
# Use "-lockfile" parameter otherwise.
EXIM_LOCK	= /usr/src/libexec/exim/exim_lock -lockfile

# PATH needed to locate the following binaries:
# touch, chmod, awk
# Not normally needed, but I prefer not to assume anything (or at
# least, not to assume too much) about the enironment.
# /bin:/usr/bin will normally suffice.
NEEDED_PATH	= /bin:/usr/bin

#################################################################
# No user-serviceable parts below this point			#
#################################################################

TARGETS	= configure.snippets quota_violation transfer-all transfer-mail
SRCS	= README Makefile \
	  configure.snippets.src quota_violation.src\
	  transfer-all.src transfer-mail.src
TAR_CF	= tar cf -
#TAR_CF	= pax -w

all: ${TARGETS}

tar:
	${TAR_CF} ${SRCS} | gzip >exim-quota.tar.gz

clean:
	-rm -rf ${TARGETS} core *.core

quota_violation: quota_violation.src
	sed -e 's?@@PERL_BIN@@?${PERL_BIN}?' \
	    -e 's?@@MAIL_DIR@@?${MAIL_DIR}?' \
	    -e 's?@@SECONDARY_DIR@@?${SECONDARY_DIR}?' \
	    -e 's?@@MAILBOX_QUOTA@@?${MAILBOX_QUOTA}?' \
	    -e 's?@@NEEDED_PATH@@?${NEEDED_PATH}?' \
		<quota_violation.src >quota_violation
	chmod +x quota_violation

configure.snippets: configure.snippets.src
	sed -e 's?@@MAILBOX_QUOTA@@?${MAILBOX_QUOTA}?' \
	    -e 's?@@EXIM_USER@@?${EXIM_USER}?' \
	    -e 's?@@EXIM_GROUP@@?${EXIM_GROUP}?' \
	    -e 's?@@EXIM_SCRIPT_DIR@@?${EXIM_SCRIPT_DIR}?' \
	    -e 's?@@MAIL_DIR@@?${MAIL_DIR}?' \
	    -e 's?@@SECONDARY_DIR@@?${SECONDARY_DIR}?' \
		<configure.snippets.src >configure.snippets

transfer-all: transfer-all.src
	sed -e 's?@@EXIM_LOCK@@?${EXIM_LOCK}?' \
	    -e 's?@@MAIL_DIR@@?${MAIL_DIR}?' \
	    -e 's?@@MAIL_DIR_BS@@?${MAIL_DIR_BS}?' \
	    -e 's?@@SECONDARY_DIR@@?${SECONDARY_DIR}?' \
	    -e 's?@@EXIM_SCRIPT_DIR@@?${EXIM_SCRIPT_DIR}?' \
	    -e 's?@@EXIM_LOCK@@?${EXIM_LOCK}?' \
	    -e 's?@@NEEDED_PATH@@?${NEEDED_PATH}?' \
		<transfer-all.src >transfer-all
	chmod +x transfer-all

transfer-mail: transfer-mail.src
	sed -e 's?@@PERL_BIN@@?${PERL_BIN}?' \
	    -e 's?@@MAILBOX_QUOTA@@?${MAILBOX_QUOTA}?' \
	    -e 's?@@MAIL_DIR@@?${MAIL_DIR}?' \
	    -e 's?@@SECONDARY_DIR@@?${SECONDARY_DIR}?' \
		<transfer-mail.src >transfer-mail
	chmod +x transfer-mail
