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)
$(TESTS):
	@../util/testrun $@


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

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