TARGET = tank

SOURCE_ALT = Alt/$(TARGET).alt

SOURCE_SPE = Acheck/$(TARGET).spe

GRAPHS = Valve.pdf\
	Valve-quot.pdf\
	ValvePerfect.pdf\
	ValvePerfect-quot.pdf\
	Tank-quot.pdf\
	ControllerPermissive-quot.pdf\
	Bug_System.pdf\
	Bug_SystemControlled.pdf\
	Bug_SystemPerfect.pdf\
	Bug_SystemPerfectControlled.pdf\
	Bug_SystemVupPerfect.pdf\
	Bug_SystemVupPerfectControlled.pdf\
	Bug_SystemVdownPerfect.pdf\
	Bug_SystemVdownPerfectControlled.pdf\

SUBDIRS = Acheck Alt

all: sources slides-fr.pdf

clean:
	for d in $(SUBDIRS); do \
		$(MAKE) -C $$d $@ || exit 1;\
	done
	rm -f *.dvi *.log *.aux *.toc *.bbl *.blg *.out *.snm *.nav *~ *.core

cleanAll:
	for d in $(SUBDIRS); do \
		$(MAKE) -C $$d $@ || exit 1;\
	done
	rm -f *.dvi *.log *.aux *.toc *.bbl *.blg *.out *.snm *.nav *~ *.core
	rm -f *.dot *.prop *.res *.validate *.validation *.validation-spe $(TARGET).time $(GRAPHS) $(TARGET).pdf slides-fr.pdf

sources : 
	for d in $(SUBDIRS); do \
		$(MAKE) -C $$d all || exit 1;\
	done

$(TARGET).time: $(SOURCE_ALT) $(SOURCE_SPE)
	uname -mps > $(TARGET).time
	/usr/bin/time -p arc -b $(SOURCE_ALT) $(SOURCE_SPE) 2>> $(TARGET).time
	$(MAKE) $(GRAPHS)

$(TARGET).pdf: $(TARGET).time $(GRAPHS) $(SOURCE_TEX)
	pdflatex $(TARGET) && pdflatex $(TARGET)

slides.pdf: slides.tex $(TARGET).time slides-$(TARGET).tex
	pdflatex $*.tex && pdflatex $*.tex

slides-fr.pdf: slides-fr.tex $(TARGET).time slides-$(TARGET)-fr.tex
	pdflatex $*.tex && pdflatex $*.tex

.SUFFIXES: .dot .pdf .tex

.dot.pdf: $*.dot
	dot -Tpdf $*.dot -o $*.pdf

.tex.pdf: $*.tex
	pdflatex $*.tex && pdflatex $*.tex $*-$(TARGET).tex
