TEX = pdflatex
ARGS = -halt-on-error

NAME = rapport
TARGET = $(NAME).pdf
DEPS = preambule.tex vm1.tex vm2.tex vm3.tex vm4.tex

RERUN = "(There were undefined references|Rerun to get (cross-references|the bars|outlines) right)"

.PHONY: all clean

all: $(TARGET)

view: $(TARGET)
	xdg-open $<

$(TARGET): $(NAME).tex $(DEPS)
	$(TEX) -jobname=$(NAME) $(ARGS) $<
	@egrep -q $(RERUN) $(NAME).log && ($(TEX) -jobname=$(NAME) $(ARGS) $<); true

clean:
	@rm -f $(NAME).out $(NAME).aux $(NAME).log $(NAME).toc $(NAME).listing $(NAME).pdf
