# Build targets for the resume.
#
# Single content source: resume.yaml
#
# Two flavors:
#   short    -> condensed, single-page (default outputs)
#   full     -> detailed, longer (Detailed.* outputs)
#
#   make            -> short PDF
#   make odt        -> short ODT
#   make docx       -> short DOCX
#   make short      -> short PDF + ODT + DOCX
#   make detailed   -> detailed PDF + ODT + DOCX
#   make all        -> short and detailed in every format
#   make clean      -> remove TeX aux files
#   make distclean  -> also remove every generated PDF/ODT/DOCX/TEX

YAML := resume.yaml

# Short (condensed) outputs
TEX  := MikeEberlein_Resume.tex
PDF  := MikeEberlein_Resume.pdf
ODT  := MikeEberlein_Resume.odt
DOCX := MikeEberlein_Resume.docx

# Detailed outputs
TEX_D  := MikeEberlein_Resume_Detailed.tex
PDF_D  := MikeEberlein_Resume_Detailed.pdf
ODT_D  := MikeEberlein_Resume_Detailed.odt
DOCX_D := MikeEberlein_Resume_Detailed.docx

# Every artifact is .PHONY so `make` always rebuilds from resume.yaml — same
# effect as `make -B`. Resume builds are fast; correctness > caching.
.PHONY: all short detailed pdf odt docx clean distclean \
        $(TEX) $(PDF) $(ODT) $(DOCX) \
        $(TEX_D) $(PDF_D) $(ODT_D) $(DOCX_D)

all: short detailed
short: $(PDF) $(ODT) $(DOCX)
detailed: $(PDF_D) $(ODT_D) $(DOCX_D)
pdf: $(PDF)
odt: $(ODT)
docx: $(DOCX)

# ---------- short ----------
$(TEX): $(YAML) render_tex.py
	python3 render_tex.py --level=short --output=$(TEX)

$(PDF): $(TEX)
	pdflatex -interaction=nonstopmode -halt-on-error $(TEX)
	pdflatex -interaction=nonstopmode -halt-on-error $(TEX)

$(ODT): $(YAML) render_odt.py
	python3 render_odt.py --level=short --output=$(ODT)

$(DOCX): $(ODT)
	soffice --headless --convert-to docx $(ODT)

# ---------- detailed ----------
$(TEX_D): $(YAML) render_tex.py
	python3 render_tex.py --level=full --output=$(TEX_D)

$(PDF_D): $(TEX_D)
	pdflatex -interaction=nonstopmode -halt-on-error $(TEX_D)
	pdflatex -interaction=nonstopmode -halt-on-error $(TEX_D)

$(ODT_D): $(YAML) render_odt.py
	python3 render_odt.py --level=full --output=$(ODT_D)

$(DOCX_D): $(ODT_D)
	soffice --headless --convert-to docx $(ODT_D)

# ---------- maintenance ----------
clean:
	rm -f *.aux *.log *.out *.toc *.fls *.fdb_latexmk *.synctex.gz

distclean: clean
	rm -f $(PDF) $(ODT) $(DOCX) $(TEX) $(PDF_D) $(ODT_D) $(DOCX_D) $(TEX_D)
