SHELL=bash
TARGET=$(subst .tex,.pdf,$(wildcard opdracht*/opdracht*.tex) paper/paper.tex)

all: $(TARGET)

paper/paper.pdf: paper/paper*.tex paper/paper.bib
	cd paper && \
		pdflatex -shell-escape paper && \
		bibtex paper.aux; \
		pdflatex -shell-escape paper && \
		pdflatex -shell-escape paper && \
		cd ..

%.pdf : %.tex
	cd `dirname $<` && \
		pdflatex -shell-escape `basename $<` && \
		bibtex `basename -s .tex $<`.aux; \
		pdflatex -shell-escape `basename $<` && \
		pdflatex -shell-escape `basename $<` && \
		cd ..