# =============================================================================
# Makefile — Differential Equations Handbook
# =============================================================================

TARGET = main
TEX    = pdflatex
BIBTEX = bibtex

.PHONY: all quick clean view distclean

## all: Full build with nomenclature indexing and 3-pass pdflatex
all:
	$(TEX) -interaction=nonstopmode $(TARGET).tex
	@if [ -f $(TARGET).nlo ]; then \
		makeindex -s nomencl.ist -o $(TARGET).nls $(TARGET).nlo; \
	fi
	$(TEX) -interaction=nonstopmode $(TARGET).tex
	$(TEX) -interaction=nonstopmode $(TARGET).tex

## quick: Single pdflatex pass for rapid iteration
quick:
	$(TEX) -interaction=nonstopmode $(TARGET).tex

## clean: Remove all auxiliary files
clean:
	rm -f $(TARGET).aux $(TARGET).log $(TARGET).out $(TARGET).toc \
	      $(TARGET).lof $(TARGET).lot $(TARGET).nls $(TARGET).nlo \
	      $(TARGET).vrb $(TARGET).synctex.gz $(TARGET).fls $(TARGET).out \
	      $(TARGET).blg $(TARGET).bbl $(TARGET).run.xml

## view: Open the resulting PDF
view:
	xdg-open $(TARGET).pdf

## distclean: Clean + remove PDF
distclean: clean
	rm -f $(TARGET).pdf
