export SATHER_HOME=$(shell cd ..;pwd)
export LOCALE=en_NZ
export SATHER_ENV=$(SATHER_HOME)/resources/$(LOCALE)/bin/LIBCHARS

#CS_OPT=-chk -verbose -only_reachable -pretty -debug
CS_OPT=-chk -debug -verbose -pretty
CS_OPT_CONC=-chk -debug -verbose -pretty -linux/smp
SACOMP=$(SATHER_HOME)/bin/sacomp

default: do_test do_std_chans do_all

do_%: test_%
	./test_$(*) 2>&1 | tee test_$(*).output

test_test: FORCE
	$(SACOMP) test.module -o test_test -main TEST_TEST $(CS_OPT) -only_C
	$(MAKE) CFLAGS="-I. -g" -C test_test.code

test_std_chans: FORCE
	$(SACOMP) test.module -o test_std_chans -main TEST_STD_CHANS $(CS_OPT) -only_C
	$(MAKE) CFLAGS="-I. -g" -C test_std_chans.code

test_all: FORCE
	$(SACOMP) test.module -o test_all -main TEST_ALL $(CS_OPT) -only_C
	$(MAKE) CFLAGS="-I. -g" -C test_all.code

test_conc: FORCE
	$(SACOMP) test.module -o test_conc -main TEST_LL_LOCK $(CS_OPT_CONC) -only_C
	$(MAKE) CFLAGS="-I. -g" -C test_conc.code

test_minimal: FORCE
	$(SACOMP) test.module -o test_minimal -main TEST_MINIMAL $(CS_OPT) -only_C
	$(MAKE) CFLAGS="-I. -g" -C test_minimal.code

FORCE:

clean:
	rm -rf test_test.code test_std_chans.code
	rm -rf test_conc.code test_all.code test_minimal.code
	rm -f test_test test_std_chans test_all test_minimal
	rm -f *.output
