# Main Makefile
LATEX = -max_print_line=1024 lualatex
LATEX_OPT := -shell-escape -interaction=nonstopmode -synctex=1 --recorder

#bibtex
BIBTEX := biber
BIBTEX_OPT :=




exclude := python-typing.tex
tex := $(wildcard *.tex)
tex := $(filter-out $(exclude), $(tex))
pdf := $(tex:.tex=.pdf)



all: $(pdf) 


%.pdf: %.tex $(exclude)
	$(LATEX) $(LATEX_OPT) $<
	if [ -f $(<:.tex=.bcf) ]; then touch $(<); $(BIBTEX) $(BIBTEX_OPT) $(<:.tex=); fi
	$(LATEX) $(LATEX_OPT) $<
	$(LATEX) $(LATEX_OPT) $<
	latexmk -c $<


clean:
	rm -fv *.aux *.out *.bbl *.blg *.pytxcode *.toc *.loe *.thm *.nav *.bcf *.tdo *.log *.run.xml *.snm *.vrb *.synctex.gz *.fls
	rm -rfv _minted-*

clean-latexmk:
	rm -rfv *.fdb_latexmk
	latexmk -C
	rm -rf latexmkrc

clean-target:
	rm -f *.pdf *.dvi

clean-all:
	make clean
	make clean-latexmk
	make clean-target