SHELL	= /bin/sh
SRCS	= smtpd.c smtpd_token.c smtpd_check.c smtpd_chat.c smtpd_state.c \
	smtpd_peer.c smtpd_sasl_proto.c smtpd_sasl_glue.c
OBJS	= smtpd.o smtpd_token.o smtpd_check.o smtpd_chat.o smtpd_state.o \
	smtpd_peer.o smtpd_sasl_proto.o smtpd_sasl_glue.o
HDRS	= smtpd_token.h smtpd_check.h smtpd_chat.h smtpd_sasl_proto.h \
	smtpd_sasl_glue.h
TESTSRC	= smtpd_token_test.c
WARN	= -W -Wformat -Wimplicit -Wmissing-prototypes \
	-Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
	-Wunused
DEFS	= -I. -I$(INC_DIR) -D$(SYSTYPE)
CFLAGS	= $(DEBUG) $(OPT) $(DEFS)
TESTPROG= smtpd_token smtpd_check
PROG	= smtpd
INC_DIR	= ../../include
LIBS	= ../../lib/libmaster.a ../../lib/libglobal.a ../../lib/libdns.a ../../lib/libutil.a

.c.o:;	$(CC) $(CFLAGS) -c $*.c

$(PROG): $(OBJS) $(LIBS)
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) $(SYSLIBS)

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

test:	$(TESTPROG)

update: ../../libexec/$(PROG)

../../libexec/$(PROG): $(PROG)
	cp $(PROG) ../../libexec

SMTPD_CHECK_OBJ = smtpd_state.o smtpd_peer.o

smtpd_token: smtpd_token.c $(LIBS)
	$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIBS) $(SYSLIBS)

smtpd_check: smtpd_check.o smtpd_check.c $(SMTPD_CHECK_OBJ) $(LIBS)
	mv $@.o junk
	$(CC) $(CFLAGS) -DTEST -o $@ smtpd_check.c $(SMTPD_CHECK_OBJ) \
		$(LIBS) $(SYSLIBS)
	mv junk $@.o

printfck: $(OBJS) $(PROG)
	rm -rf printfck
	mkdir printfck
	cp *.h printfck
	sed '1,/^# do not edit/!d' Makefile >printfck/Makefile
	set -e; for i in *.c; do printfck -f .printfck $$i >printfck/$$i; done
	cd printfck; make "INC_DIR=../../../include" `cd ..; ls *.o`

lint:
	lint $(DEFS) $(SRCS) $(LINTFIX)

clean:
	rm -f *.o *core $(PROG) $(TESTPROG) junk *.db *.out *.tmp
	rm -rf printfck

tidy:	clean

depend: $(MAKES)
	(sed '1,/^# do not edit/!d' Makefile.in; \
	set -e; for i in [a-z][a-z0-9]*.c; do \
	    $(CC) -E $(DEFS) $(INCL) $$i | sed -n -e '/^# *1 *"\([^"]*\)".*/{' \
	    -e 's//'`echo $$i|sed 's/c$$/o/'`': \1/' -e 'p' -e '}'; \
	done) | grep -v '[.][o][:][ ][/]' >$$$$ && mv $$$$ Makefile.in
	@$(EXPORT) make -f Makefile.in Makefile 1>&2

tests: smtpd_check_test smtpd_check_test2 smtpd_acl_test smtpd_exp_test \
	smtpd_token_test smtpd_check_test4

smtpd_check_test: smtpd_check smtpd_check.in smtpd_check.ref smtpd_check_access
	../postmap/postmap hash:smtpd_check_access
	./smtpd_check <smtpd_check.in >smtpd_check.tmp 2>&1
	diff smtpd_check.ref smtpd_check.tmp
	rm -f smtpd_check.tmp smtpd_check_access.*

smtpd_check_test2: smtpd_check smtpd_check.in2 smtpd_check.ref2 smtpd_check_access
	../postmap/postmap hash:smtpd_check_access
	./smtpd_check <smtpd_check.in2 >smtpd_check.tmp 2>&1
	diff smtpd_check.ref2 smtpd_check.tmp
	rm -f smtpd_check.tmp smtpd_check_access.*

smtpd_check_test4: smtpd_check smtpd_check.in4 smtpd_check.ref4 smtpd_check_access
	../postmap/postmap hash:smtpd_check_access
	./smtpd_check <smtpd_check.in4 >smtpd_check.tmp 2>&1
	diff smtpd_check.ref4 smtpd_check.tmp
	rm -f smtpd_check.tmp smtpd_check_access.*

smtpd_acl_test: smtpd_check smtpd_acl.in smtpd_acl.ref smtpd_check_access
	../postmap/postmap hash:smtpd_check_access
	./smtpd_check <smtpd_acl.in >smtpd_check.tmp 2>&1
	diff smtpd_acl.ref smtpd_check.tmp
	rm -f smtpd_check.tmp smtpd_check_access.*

smtpd_exp_test: smtpd_check smtpd_exp.in smtpd_exp.ref
	../postmap/postmap hash:smtpd_check_access
	./smtpd_check <smtpd_exp.in >smtpd_exp.tmp 2>&1
	diff smtpd_exp.ref smtpd_exp.tmp
	rm -f smtpd_exp.tmp smtpd_check_access.*

smtpd_token_test: smtpd_token smtpd_token.in smtpd_token.ref
	./smtpd_token <smtpd_token.in >smtpd_token.tmp 2>&1
	diff smtpd_token.ref smtpd_token.tmp
	rm -f smtpd_token.tmp

# do not edit below this line - it is generated by 'make depend'
smtpd.o: smtpd.c
smtpd.o: ../../include/sys_defs.h
smtpd.o: ../../include/msg.h
smtpd.o: ../../include/mymalloc.h
smtpd.o: ../../include/vstring.h
smtpd.o: ../../include/vbuf.h
smtpd.o: ../../include/vstream.h
smtpd.o: ../../include/vstring_vstream.h
smtpd.o: ../../include/stringops.h
smtpd.o: ../../include/events.h
smtpd.o: ../../include/smtp_stream.h
smtpd.o: ../../include/valid_hostname.h
smtpd.o: ../../include/dict.h
smtpd.o: ../../include/argv.h
smtpd.o: ../../include/watchdog.h
smtpd.o: ../../include/mail_params.h
smtpd.o: ../../include/record.h
smtpd.o: ../../include/rec_type.h
smtpd.o: ../../include/mail_proto.h
smtpd.o: ../../include/iostuff.h
smtpd.o: ../../include/attr.h
smtpd.o: ../../include/cleanup_user.h
smtpd.o: ../../include/mail_date.h
smtpd.o: ../../include/mail_conf.h
smtpd.o: ../../include/off_cvt.h
smtpd.o: ../../include/debug_peer.h
smtpd.o: ../../include/mail_error.h
smtpd.o: ../../include/name_mask.h
smtpd.o: ../../include/flush_clnt.h
smtpd.o: ../../include/mail_stream.h
smtpd.o: ../../include/mail_queue.h
smtpd.o: ../../include/tok822.h
smtpd.o: ../../include/resolve_clnt.h
smtpd.o: ../../include/verp_sender.h
smtpd.o: ../../include/string_list.h
smtpd.o: ../../include/match_list.h
smtpd.o: ../../include/match_ops.h
smtpd.o: ../../include/quote_822_local.h
smtpd.o: ../../include/quote_flags.h
smtpd.o: ../../include/lex_822.h
smtpd.o: ../../include/namadr_list.h
smtpd.o: ../../include/mail_server.h
smtpd.o: smtpd_token.h
smtpd.o: smtpd.h
smtpd.o: smtpd_check.h
smtpd.o: smtpd_chat.h
smtpd.o: smtpd_sasl_proto.h
smtpd.o: smtpd_sasl_glue.h
smtpd_chat.o: smtpd_chat.c
smtpd_chat.o: ../../include/sys_defs.h
smtpd_chat.o: ../../include/msg.h
smtpd_chat.o: ../../include/argv.h
smtpd_chat.o: ../../include/vstring.h
smtpd_chat.o: ../../include/vbuf.h
smtpd_chat.o: ../../include/vstream.h
smtpd_chat.o: ../../include/stringops.h
smtpd_chat.o: ../../include/line_wrap.h
smtpd_chat.o: ../../include/mymalloc.h
smtpd_chat.o: ../../include/smtp_stream.h
smtpd_chat.o: ../../include/record.h
smtpd_chat.o: ../../include/rec_type.h
smtpd_chat.o: ../../include/mail_proto.h
smtpd_chat.o: ../../include/iostuff.h
smtpd_chat.o: ../../include/attr.h
smtpd_chat.o: ../../include/mail_params.h
smtpd_chat.o: ../../include/mail_addr.h
smtpd_chat.o: ../../include/post_mail.h
smtpd_chat.o: ../../include/cleanup_user.h
smtpd_chat.o: ../../include/mail_error.h
smtpd_chat.o: ../../include/name_mask.h
smtpd_chat.o: smtpd.h
smtpd_chat.o: ../../include/mail_stream.h
smtpd_chat.o: smtpd_chat.h
smtpd_check.o: smtpd_check.c
smtpd_check.o: ../../include/sys_defs.h
smtpd_check.o: ../../include/msg.h
smtpd_check.o: ../../include/vstring.h
smtpd_check.o: ../../include/vbuf.h
smtpd_check.o: ../../include/split_at.h
smtpd_check.o: ../../include/fsspace.h
smtpd_check.o: ../../include/stringops.h
smtpd_check.o: ../../include/valid_hostname.h
smtpd_check.o: ../../include/argv.h
smtpd_check.o: ../../include/mymalloc.h
smtpd_check.o: ../../include/dict.h
smtpd_check.o: ../../include/vstream.h
smtpd_check.o: ../../include/htable.h
smtpd_check.o: ../../include/ctable.h
smtpd_check.o: ../../include/mac_expand.h
smtpd_check.o: ../../include/mac_parse.h
smtpd_check.o: ../../include/dns.h
smtpd_check.o: ../../include/string_list.h
smtpd_check.o: ../../include/match_list.h
smtpd_check.o: ../../include/match_ops.h
smtpd_check.o: ../../include/namadr_list.h
smtpd_check.o: ../../include/domain_list.h
smtpd_check.o: ../../include/mail_params.h
smtpd_check.o: ../../include/canon_addr.h
smtpd_check.o: ../../include/resolve_clnt.h
smtpd_check.o: ../../include/mail_error.h
smtpd_check.o: ../../include/name_mask.h
smtpd_check.o: ../../include/resolve_local.h
smtpd_check.o: ../../include/own_inet_addr.h
smtpd_check.o: ../../include/mail_conf.h
smtpd_check.o: ../../include/maps.h
smtpd_check.o: ../../include/mail_addr_find.h
smtpd_check.o: ../../include/match_parent_style.h
smtpd_check.o: ../../include/strip_addr.h
smtpd_check.o: ../../include/virtual8_maps.h
smtpd_check.o: ../../include/cleanup_user.h
smtpd_check.o: ../../include/record.h
smtpd_check.o: ../../include/rec_type.h
smtpd_check.o: ../../include/mail_proto.h
smtpd_check.o: ../../include/iostuff.h
smtpd_check.o: ../../include/attr.h
smtpd_check.o: ../../include/mail_addr.h
smtpd_check.o: smtpd.h
smtpd_check.o: ../../include/mail_stream.h
smtpd_check.o: smtpd_sasl_glue.h
smtpd_check.o: smtpd_check.h
smtpd_peer.o: smtpd_peer.c
smtpd_peer.o: ../../include/sys_defs.h
smtpd_peer.o: ../../include/msg.h
smtpd_peer.o: ../../include/mymalloc.h
smtpd_peer.o: ../../include/valid_hostname.h
smtpd_peer.o: ../../include/stringops.h
smtpd_peer.o: ../../include/vstring.h
smtpd_peer.o: ../../include/vbuf.h
smtpd_peer.o: smtpd.h
smtpd_peer.o: ../../include/vstream.h
smtpd_peer.o: ../../include/argv.h
smtpd_peer.o: ../../include/mail_stream.h
smtpd_sasl_glue.o: smtpd_sasl_glue.c
smtpd_sasl_glue.o: ../../include/sys_defs.h
smtpd_sasl_glue.o: ../../include/msg.h
smtpd_sasl_glue.o: ../../include/mymalloc.h
smtpd_sasl_glue.o: ../../include/namadr_list.h
smtpd_sasl_glue.o: ../../include/match_list.h
smtpd_sasl_glue.o: ../../include/match_ops.h
smtpd_sasl_glue.o: ../../include/name_mask.h
smtpd_sasl_glue.o: ../../include/mail_params.h
smtpd_sasl_glue.o: ../../include/smtp_stream.h
smtpd_sasl_glue.o: ../../include/vstring.h
smtpd_sasl_glue.o: ../../include/vbuf.h
smtpd_sasl_glue.o: ../../include/vstream.h
smtpd_sasl_glue.o: smtpd.h
smtpd_sasl_glue.o: ../../include/argv.h
smtpd_sasl_glue.o: ../../include/mail_stream.h
smtpd_sasl_glue.o: smtpd_sasl_glue.h
smtpd_sasl_glue.o: smtpd_chat.h
smtpd_sasl_proto.o: smtpd_sasl_proto.c
smtpd_sasl_proto.o: ../../include/sys_defs.h
smtpd_sasl_proto.o: ../../include/msg.h
smtpd_sasl_proto.o: ../../include/mymalloc.h
smtpd_sasl_proto.o: ../../include/mail_params.h
smtpd_sasl_proto.o: ../../include/mail_proto.h
smtpd_sasl_proto.o: ../../include/vstream.h
smtpd_sasl_proto.o: ../../include/vbuf.h
smtpd_sasl_proto.o: ../../include/iostuff.h
smtpd_sasl_proto.o: ../../include/attr.h
smtpd_sasl_proto.o: ../../include/mail_error.h
smtpd_sasl_proto.o: ../../include/name_mask.h
smtpd_sasl_proto.o: smtpd.h
smtpd_sasl_proto.o: ../../include/vstring.h
smtpd_sasl_proto.o: ../../include/argv.h
smtpd_sasl_proto.o: ../../include/mail_stream.h
smtpd_sasl_proto.o: smtpd_token.h
smtpd_sasl_proto.o: smtpd_chat.h
smtpd_sasl_proto.o: smtpd_sasl_proto.h
smtpd_sasl_proto.o: smtpd_sasl_glue.h
smtpd_state.o: smtpd_state.c
smtpd_state.o: ../../include/sys_defs.h
smtpd_state.o: ../../include/events.h
smtpd_state.o: ../../include/mymalloc.h
smtpd_state.o: ../../include/vstream.h
smtpd_state.o: ../../include/vbuf.h
smtpd_state.o: ../../include/name_mask.h
smtpd_state.o: ../../include/msg.h
smtpd_state.o: ../../include/cleanup_user.h
smtpd_state.o: ../../include/mail_params.h
smtpd_state.o: ../../include/mail_error.h
smtpd_state.o: ../../include/mail_proto.h
smtpd_state.o: ../../include/iostuff.h
smtpd_state.o: ../../include/attr.h
smtpd_state.o: smtpd.h
smtpd_state.o: ../../include/vstring.h
smtpd_state.o: ../../include/argv.h
smtpd_state.o: ../../include/mail_stream.h
smtpd_state.o: smtpd_chat.h
smtpd_state.o: smtpd_sasl_glue.h
smtpd_token.o: smtpd_token.c
smtpd_token.o: ../../include/sys_defs.h
smtpd_token.o: ../../include/mymalloc.h
smtpd_token.o: ../../include/mvect.h
smtpd_token.o: smtpd_token.h
smtpd_token.o: ../../include/vstring.h
smtpd_token.o: ../../include/vbuf.h
