BUILDDIR = build
SRCDIR = src
RESDIR = res
TEMPDIR = tmp

CC = latexmk
CFLAGS = -pdf -shell-escape -halt-on-error


TARGETS = $(BUILDDIR)/thesis.pdf


all: clean precomp $(TARGETS) postcomp

precomp:
	@mkdir -p $(TEMPDIR)
	@cd $(TEMPDIR) && ln -s ../$(SRCDIR)/* .
	@cd $(TEMPDIR) && ln -s ../$(RESDIR)/* .

postcomp:
	@rm -r $(TEMPDIR)

$(BUILDDIR)/thesis.pdf: $(TEMPDIR)/thesis.tex
	$(CC) $(CFLAGS) -output-directory=../$(BUILDDIR) -cd $<

clean:
	rm -rf $(BUILDDIR) $(TEMPDIR)

show:
	okular $(TARGETS) &


.PHONY: all precomp postcomp show clean f
