#!/usr/bin/make -f

NAME := Dissertation_Sander

TEX_GRAPHICS_PDF := $(patsubst %, %.pdf, $(basename $(shell find graphics/tex/ -name "*.tex") .tex))

.PHONY: all clean view indent

all: $(TEX_GRAPHICS_PDF)
	@latexmk -lualatex -bibtex -latexoption=-halt-on-error -jobname=$(NAME) main.tex > /dev/null

%.pdf: %.tex
	@latexmk -lualatex -latexoption=-halt-on-error $^ -jobname=$(basename $@ .pdf) > /dev/null

clean:
	@latexmk -c -jobname=$(NAME) main.tex 2> /dev/null
	@find graphics/tex/ ! \( -name '*.tex' -o -name '.gitignore' \) -type f -exec rm -rf {} +
	@rm -rf **/*.aux indent.log

view:
	@evince $(NAME).pdf &

indent:
	@find -type f \( -iname "*.tex" ! -iname "titlepage.tex" \) -exec latexindent -m -s -o={} -l=.indent.yaml {} \;
