TESTS = syntax.scm mail.scm util.scm config.scm progress.scm \
	scmail.scm bayesian-filter.scm mailbox.scm
MAIL  = 1 2 3 4 5 6 7 8
TARGET = bayesian-filter.scm test-rules

all: $(TARGET)

test-rules: test-rules.in
	rm -f test-rules
	gosh ../codeconv.scm test-rules.in > test-rules
	chmod -w test-rules

bayesian-filter.scm: bayesian-filter.scm.in
	rm -f bayesian-filter.scm
	gosh ../codeconv.scm bayesian-filter.scm.in > bayesian-filter.scm
	chmod -w bayesian-filter.scm

check: clean all mh-mailbox maildir-mailbox
	@rm -f test.log
	@for i in $(TESTS); do \
		gosh -I.. $$i >> test.log; \
	done
	@./scmail-commands >> test.log

mh-mailbox:
	@mkdir -p Mail/inbox
	@cp $(MAIL) Mail/inbox

maildir-mailbox:
	@mkdir -p Maildir/cur
	@mkdir -p Maildir/new
	@mkdir -p Maildir/tmp
	@for i in $(MAIL); do \
             suffix=""; \
             test $$i = 1 && suffix=":abc"; \
             test $$i = 2 && suffix=",abc:def"; \
	    cp $$i Maildir/cur/100000000$$i.localhost$$suffix; \
	done

clean:
	@rm -f $(TARGET)
	@rm -rf Mail Maildir test.*

