# MAKEFLAGS := --jobs=$(shell nproc)
# MAKEFLAGS += --output-sync=target

# ======================================================================
# Change this to the base name of the document (without .tex)
DOCUMENT=CTA-LIS-COM-000000-0001_Computing_Glossary_DRAFT

# List of glossary inputs to generate glossary.tex
GLOSSARIES=$(wildcard ../glossary-*.yaml)

# ======================================================================
# Don't edit below this line

INPUTVARS=BIBINPUTS=../computing-latex-class: TEXINPUTS=build:../computing-latex-class:

all: build/$(DOCUMENT).pdf

# dependncies for UML diagrams

# Utilities and options needed to generate the documents
LATEXMK=$(INPUTVARS) latexmk -r ../computing-latex-class/latexmkrc -file-line-error -synctex=1
GLOSS2LATEX=../glossary-to-latex.py
GLOSS2LATEX_OPTS=--source --cross-ref --hide-source "ctao-computing" --validate-with ../schema.yaml --write-excel build/ctao-computing-glossary.xlsx

# the full glossary of everything listed in GLOSSARIES
build/glossary.tex: $(GLOSSARIES) $(GLOSS2LATEX) | build
	$(GLOSS2LATEX) $(GLOSS2LATEX_OPTS) $(GLOSSARIES) > $@

# Main rule to build the document
build/$(DOCUMENT).pdf: FORCE build/glossary.tex
	$(LATEXMK) $(DOCUMENT).tex


# a rule to generate a DOCX (Microsoft Word) document from the source
# in case this is needed for some reason
%.docx: %.tex
	pandoc --default-image-extension=pdf --toc $< -t docx -o $@

build:
	mkdir -p $@

semiclean::
	$(LATEXMK) -c

clean::
	$(RM) -r build

FORCE:

.PHONY: all clean uml semiclean FORCE preview
