SHELL	= /bin/sh

# For now, just hard-coded rules for daemons, commands, config files.

DAEMONS	=  bounce.8.html cleanup.8.html defer.8.html error.8.html local.8.html \
	lmtp.8.html master.8.html pickup.8.html pipe.8.html qmgr.8.html \
	showq.8.html smtp.8.html smtpd.8.html trivial-rewrite.8.html \
	oqmgr.8.html spawn.8.html flush.8.html virtual.8.html qmqpd.8.html \
	trace.8.html verify.8.html proxymap.8.html anvil.8.html \
	scache.8.html discard.8.html tlsmgr.8.html postscreen.8.html \
	dnsblog.8.html tlsproxy.8.html
COMMANDS= mailq.1.html newaliases.1.html postalias.1.html postcat.1.html \
	postconf.1.html postfix.1.html postkick.1.html postlock.1.html \
	postlog.1.html postdrop.1.html postmap.1.html postmulti.1.html \
	postqueue.1.html postsuper.1.html sendmail.1.html \
	smtp-source.1.html smtp-sink.1.html \
	qmqp-source.1.html qmqp-sink.1.html \
	qshape.1.html
CONFIG	= access.5.html aliases.5.html canonical.5.html relocated.5.html \
	transport.5.html virtual.5.html pcre_table.5.html regexp_table.5.html \
	cidr_table.5.html tcp_table.5.html header_checks.5.html \
	ldap_table.5.html mysql_table.5.html pgsql_table.5.html \
	memcache_table.5.html \
	master.5.html nisplus_table.5.html generic.5.html bounce.5.html \
	postfix-wrapper.5.html sqlite_table.5.html
OTHER	= postfix-manuals.html
AWK	= awk '{ print; if (NR == 2) print ".pl 9999\n.ll 65" }'
MAN2HTML = man2html -t "Postfix manual - `IFS=.; set \`echo $@\`; echo \"$$1($$2)\"`"

update:	$(DAEMONS) $(COMMANDS) $(CONFIG) $(OTHER)

clean:
	echo clean

tidy:	clean

clobber:
	rm -f $(DAEMONS) $(COMMANDS) $(CONFIG)

bounce.8.html: ../src/bounce/bounce.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

defer.8.html: bounce.8.html
	rm -f $@
	ln $? $@

discard.8.html: ../src/discard/discard.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

dnsblog.8.html: ../src/dnsblog/dnsblog.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

error.8.html: ../src/error/error.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

flush.8.html: ../src/flush/flush.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

cleanup.8.html: ../src/cleanup/cleanup.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

anvil.8.html: ../src/anvil/anvil.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

scache.8.html: ../src/scache/scache.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

lmtp.8.html: smtp.8.html
	rm -f $@
	ln $? $@

local.8.html: ../src/local/local.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

master.8.html: ../src/master/master.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

oqmgr.8.html: ../src/oqmgr/qmgr.c
	PATH=../mantools:$$PATH; \
	srctoman $? | sed -e 's/qmgr[^_]/o&/' \
			  -e 's/qmgr$$/o&/' \
			  -e 's/QMGR[^_]/O&/' | \
	    $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

pickup.8.html: ../src/pickup/pickup.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

pipe.8.html: ../src/pipe/pipe.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postscreen.8.html: ../src/postscreen/postscreen.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

proxymap.8.html: ../src/proxymap/proxymap.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

qmgr.8.html: ../src/qmgr/qmgr.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

qmqpd.8.html: ../src/qmqpd/qmqpd.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

showq.8.html: ../src/showq/showq.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

spawn.8.html: ../src/spawn/spawn.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

smtp.8.html: ../src/smtp/smtp.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

smtpd.8.html: ../src/smtpd/smtpd.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

tlsproxy.8.html: ../src/tlsproxy/tlsproxy.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

virtual.8.html: ../src/virtual/virtual.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

tlsmgr.8.html: ../src/tlsmgr/tlsmgr.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

trace.8.html: bounce.8.html
	rm -f $@
	ln $? $@

trivial-rewrite.8.html: ../src/trivial-rewrite/trivial-rewrite.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

verify.8.html: ../src/verify/verify.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postalias.1.html: ../src/postalias/postalias.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postcat.1.html: ../src/postcat/postcat.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postconf.1.html: ../src/postconf/postconf.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postdrop.1.html: ../src/postdrop/postdrop.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postfix.1.html: ../src/postfix/postfix.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postkick.1.html: ../src/postkick/postkick.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postlock.1.html: ../src/postlock/postlock.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postlog.1.html: ../src/postlog/postlog.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postmap.1.html: ../src/postmap/postmap.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postmulti.1.html: ../src/postmulti/postmulti.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postqueue.1.html: ../src/postqueue/postqueue.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postsuper.1.html: ../src/postsuper/postsuper.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

sendmail.1.html: ../src/sendmail/sendmail.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

mailq.1.html: sendmail.1.html
	rm -f $@
	ln $? $@

newaliases.1.html: sendmail.1.html
	PATH=../mantools:$$PATH; \
	rm -f $@
	ln $? $@

smtp-source.1.html: ../src/smtpstone/smtp-source.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

smtp-sink.1.html: ../src/smtpstone/smtp-sink.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

qmqp-source.1.html: ../src/smtpstone/qmqp-source.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

qmqp-sink.1.html: ../src/smtpstone/qmqp-sink.c
	PATH=../mantools:$$PATH; \
	srctoman $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

qshape.1.html: ../auxiliary/qshape/qshape.pl
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

access.5.html: ../proto/access
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

aliases.5.html: ../proto/aliases
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

bounce.5.html: ../proto/bounce
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

canonical.5.html: ../proto/canonical
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

cidr_table.5.html: ../proto/cidr_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

header_checks.5.html: ../proto/header_checks
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

generic.5.html: ../proto/generic
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

ldap_table.5.html: ../proto/ldap_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

master.5.html: ../proto/master
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

memcache_table.5.html: ../proto/memcache_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

mysql_table.5.html: ../proto/mysql_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

sqlite_table.5.html: ../proto/sqlite_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

nisplus_table.5.html: ../proto/nisplus_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

pcre_table.5.html: ../proto/pcre_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

pgsql_table.5.html: ../proto/pgsql_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

regexp_table.5.html: ../proto/regexp_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

relocated.5.html: ../proto/relocated
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

tcp_table.5.html: ../proto/tcp_table
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

transport.5.html: ../proto/transport
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

virtual.5.html: ../proto/virtual
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postfix-wrapper.5.html: ../proto/postfix-wrapper
	PATH=../mantools:$$PATH; \
	srctoman - $? | $(AWK) | nroff -man | uniq | $(MAN2HTML) | postlink >$@

postfix-manuals.html: ../src/postfix/postfix.c ../mantools/makemanidx
	PATH=../mantools:$$PATH; \
	makemanidx ../src/postfix/postfix.c | postlink >$@
