TESTS= $(wildcard *.tst)

TEXINPUTS= $(notdir $(shell ../util/inputlist < text.tex))
TEXINPUTS+= $(notdir $(shell ../util/inputlist < exercises.tex))
TEXINPUTS+= $(notdir $(shell ../util/inputlist < solutions.tex))

all: $(TEXINPUTS) $(TESTS)

.PHONY: texinputs
texinputs:  $(TEXINPUTS)

.PHONY: check
check: $(TESTS)


.PHONY: $(TESTS)
# special rules for elevator.tst
#$(TESTS):
#	@../util/testrun $@

elevator.tst: *.mms
	@../util/testgen elevator.tst
	@../util/mmixal -b 1000 -l 1-elevator.tst.mml 1-elevator.tst.mms
	@../util/mmix 1-elevator.tst.mmo > actions.txt
	@diff -q actions.txt donsactions.txt

%.tex: %.mms
	echo mmstotex  $< 
	../util/mmstotex < $< > $@

clean:
	@rm -f *.mmo *.mml *.tst.mms *~
	@for i in $(basename $(TEXINPUTS)) ; do \
	  if [ -f $$i.mms ] ; then  \
	    rm -f $$i.tex ; \
	  fi ; \
	done