myCV/Makefile

47 lines
1.6 KiB
Makefile
Raw Permalink Normal View History

# Build CV variants to ./build/<name>.pdf using a dockerised XeLaTeX.
# Run `make` (or `make full`) to build the full CV. Add new targets per variant.
DOCKER_IMAGE := texlive/texlive:latest
BUILD_DIR := build
ENGINE := xelatex
# Run the container with the current dir mounted. UID:GID match avoids root-owned outputs.
# TEXINPUTS prepends ./tex-vendor so altacv.cls (vendored) is found.
DOCKER_RUN = docker run --rm \
-u $(shell id -u):$(shell id -g) \
-v $(CURDIR):/work \
-w /work \
-e TEXINPUTS=.:./tex-vendor: \
$(DOCKER_IMAGE)
.PHONY: all full short clean shell install-hooks
all: full short
# Activate the pre-commit hook that rebuilds every variant on commit.
# Run once after cloning, or after a fresh checkout.
install-hooks:
git config core.hooksPath hooks
@echo "Hooks path set to ./hooks -- pre-commit will rebuild all variants on .tex/.cls/Makefile changes."
# Pattern rule: build/<name>.pdf is built from <name>.tex by running xelatex twice
# (twice to settle cross-references / hyperref).
$(BUILD_DIR)/%.pdf: %.tex preamble.tex $(wildcard chapters/*.tex) $(wildcard chapters/short/*.tex) | $(BUILD_DIR)
$(DOCKER_RUN) $(ENGINE) -interaction=nonstopmode -halt-on-error \
-output-directory=$(BUILD_DIR) $<
$(DOCKER_RUN) $(ENGINE) -interaction=nonstopmode -halt-on-error \
-output-directory=$(BUILD_DIR) $<
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
full: $(BUILD_DIR)/cv-full.pdf
short: $(BUILD_DIR)/cv-short.pdf
# Drop into an interactive TeX-Live shell (handy for debugging).
shell:
docker run --rm -it -u $(shell id -u):$(shell id -g) \
-v $(CURDIR):/work -w /work $(DOCKER_IMAGE) bash
clean:
rm -rf $(BUILD_DIR)