# file settings
BUILD_DIR 	:= build
DRAFT		:= lfc_draft.pdf
FINAL		:= lfc_final.pdf

# tex settings
TEX := xelatex \
		-interaction=nonstopmode \
		-halt-on-error \
		-output-directory=$(BUILD_DIR)

# automated stuff
_DRAFT := $(BUILD_DIR)/$(DRAFT)
_DRAFT_SRC := $(patsubst %.pdf,%.tex,$(DRAFT))

_FINAL := $(BUILD_DIR)/$(FINAL)
_FINAL_SRC := $(patsubst %.pdf,%.tex,$(FINAL))

# recipes
.PHONY: build_dir count count_draft count_final
all: $(_DRAFT)

$(_DRAFT): $(_DRAFT_SRC) build_dir
	$(TEX) $<

$(_FINAL): $(_FINAL_SRC) build_dir
	$(TEX) $<

count: count_draft count_final

count_draft: $(_DRAFT_SRC)
	texcount $<

count_final: $(_FINAL_SRC)
	texcount $<

build_dir:
	mkdir -p $(BUILD_DIR)