ECL=ecl

all: output.ecl/ansi.log output.ecl/regressions.log

.PHONY: do-ansi do-regressions do-quicklisp cleanup clean-sources update

output.ecl/ansi.log: config.lsp
	$(MAKE) do-ansi
output.ecl/regressions.log: config.lsp
	$(MAKE) do-regressions

do-ansi: ansi-tests config.lsp
	$(ECL) -norc -load config.lsp -eval '(ecl-tests::run-ansi-tests)' -eval '(ext:quit)' < /dev/null
do-regressions: regressions config.lsp
	$(ECL) -norc -load config.lsp -eval '(ecl-tests::run-regressions-tests)' -eval '(ext:quit)' < /dev/null
do-quicklisp: quicklisp config.lsp
	$(ECL) -norc -load config.lsp -eval '(ecl-tests::run-quicklisp-tests)' -eval '(ext:quit)' < /dev/null

#
# Create directories
#
ansi-tests: config.lsp
	$(ECL) -norc -load config.lsp -eval '(ecl-tests::ensure-ansi-tests)' -eval '(ext:quit)' < /dev/null
regressions: config.lsp
	$(ECL) -norc -load config.lsp -eval '(ecl-tests::ensure-regressions)' -eval '(ext:quit)' < /dev/null
quicklisp: config.lsp
	$(ECL) -norc -load config.lsp -eval '(ecl-tests::ensure-quicklisp)' -eval '(ext:quit)' < /dev/null

#
# Test other implementations
#
test-sbcl:
	TEST_NAME=sbcl TEST_IMAGE=sbcl $(MAKE) do-ansi
test-clisp:
	TEST_NAME=clisp TEST_IMAGE=clisp $(MAKE) do-ansi
test-dx86cl64:
	TEST_NAME=dx86cl64 TEST_IMAGE=ccl $(MAKE) do-ansi

#
# Cleanup
#
clean:
	rm -rf output*
clean-sources:
	test -f config.lsp.in || rm -rf bugs
	rm -rf ansi-tests quicklisp
distclean: clean-sources clean
	rm -rf cache

update: clean-sources
	$(MAKE) ansi-tests regressions quicklisp

