# Makefile for lualatex

# Paths and filenames
SRC_DIR  = src
OUT_DIR  = out
MAIN_TEX = $(SRC_DIR)/main.tex
MAIN_PDF = $(OUT_DIR)/main.pdf

# LaTeX and Biber commands

LATEX = lualatex
BIBER = biber

LATEX_OPTS := -output-directory=$(OUT_DIR) -interaction=nonstopmode -shell-escape

.PHONY: default release clean

default: english
release: german english
# Default target
english: 
	sed -r -i 's/usepackage\[[^]]+\]\{babel\}/usepackage[english]{babel}/' $(MAIN_TEX)
	-cd $(SRC_DIR) && latexmk -lualatex -g main.tex
	mv $(MAIN_PDF) $(OUT_DIR)/$(shell date -I)_en_formula_collection.pdf

german:
	sed -r -i 's/usepackage\[[^]]+\]\{babel\}/usepackage[german]{babel}/' $(MAIN_TEX)
	-cd $(SRC_DIR) && latexmk -lualatex -g main.tex
	mv $(MAIN_PDF) $(OUT_DIR)/$(shell date -I)_de_formelsammlung.pdf

# Clean auxiliary and output files
clean:
	rm -r $(OUT_DIR)

# Phony targets
.PHONY: all clean biber

