
TARGET=article

.PHONY: clean all final pvc draftmode switch-final switch-draft
# This has the effect of causing the rule to be always out-of-date, so that latexmk is always run.
.PHONY: FORCE_MAKE

.DEFAULT: all

all: $(TARGET).pdf

switch-final: config/config.passoptions-final.tex
	cp $< ./config.passoptions.tex

switch-draft: config/config.passoptions-draft.tex
	cp $< ./config.passoptions.tex

$(TARGET).pdf: FORCE_MAKE
	latexmk $(TARGET)

final: clean switch-final FORCE_MAKE
	latexmk -gg $(TARGET)

# a.k.a. preview continuously
pvc: FORCE_MAKE
	latexmk -pvc $(TARGET)

# syntax check only; but latexmk always causes error since pdf is not generated.
draftmode: FORCE_MAKE
	latexmk -pdf- -pvc -f -draftmode $(TARGET)

clean:
	latexmk -C

