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 \
	nqmgr.8.html spawn.8.html flush.8.html virtual.8.html qmqpd.8.html \
	proxymap.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 sendmail.1.html \
	postqueue.1.html postsuper.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

AWK	= awk '{ print; if (NR == 1) print ".pl 9999" }'

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

Makefile: Makefile.in
	(set -e; echo "# DO NOT EDIT"; $(OPTS) $(SHELL) ../src/makedefs; cat $?) >$@

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 -s $? $@

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 >$@

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

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 >$@

nqmgr.8.html: ../src/nqmgr/qmgr.c
	PATH=../mantools:$$PATH; \
	srctoman $? | sed -e 's/qmgr[^_]/n&/' \
			  -e 's/qmgr$$/n&/' \
			  -e 's/QMGR[^_]/N&/' | \
	    $(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 >$@

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 >$@

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

trivial-rewrite.8.html: ../src/trivial-rewrite/trivial-rewrite.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 >$@

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
	PATH=../mantools:$$PATH; \
	rm -f $@
	ln -s $? $@

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

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 >$@

canonical.5.html: ../proto/canonical
	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 >$@

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 >$@

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 >$@
