diff options
| -rw-r--r-- | Makefile | 81 |
1 files changed, 64 insertions, 17 deletions
@@ -1,24 +1,71 @@ -MD_FILE = assignments/1/README.md -PDF_FILE = 3431709-assignment-1.pdf -TAR_FILE = 3431709-assignment-1.tar.gz +# Makefile to build PDFs and tarballs for assignments 1, 2, and 3 +# Usage examples: +# make a1 # build PDF and tarball for assignment 1 +# make pdf2 # build only PDF for assignment 2 +# make tar3 # build only tarball for assignment 3 +# make all # build PDFs and tarballs for all assignments +# make clean # remove generated PDFs and tarballs -all: pdf tarball +# Student info for filenames +STUDENT_ID := 3431709 -pdf: $(PDF_FILE) +# Pandoc and LaTeX settings +PANDOC := pandoc +PDF_ENGINE := pdflatex +# Some macOS setups need TeX on PATH explicitly +TEX_PATH := /Library/TeX/texbin -$(PDF_FILE): $(MD_FILE) - PATH="/Library/TeX/texbin/:$$PATH" pandoc $(MD_FILE) -o $(PDF_FILE) \ - --pdf-engine=pdflatex \ - --variable=header-includes:'\usepackage[utf8]{inputenc}\usepackage[T1]{fontenc}\DeclareUnicodeCharacter{03C1}{\ensuremath{\rho}}\DeclareUnicodeCharacter{2264}{\ensuremath{\leq}}\DeclareUnicodeCharacter{2265}{\ensuremath{\geq}}\DeclareUnicodeCharacter{2080}{\ensuremath{_0}}\DeclareUnicodeCharacter{2248}{\ensuremath{\approx}}\DeclareUnicodeCharacter{2212}{\ensuremath{-}}\DeclareUnicodeCharacter{03B1}{\ensuremath{\alpha}}\DeclareUnicodeCharacter{03B2}{\ensuremath{\beta}}\DeclareUnicodeCharacter{03BB}{\ensuremath{\lambda}}\DeclareUnicodeCharacter{03BC}{\ensuremath{\mu}}\DeclareUnicodeCharacter{03A3}{\ensuremath{\Sigma}}' \ - --toc \ - --number-sections +# Common Pandoc args (unicode support + ToC + numbered sections) +PANDOC_ARGS := \ + --pdf-engine=$(PDF_ENGINE) \ + --variable=header-includes:'\usepackage[utf8]{inputenc}\usepackage[T1]{fontenc}\DeclareUnicodeCharacter{03C1}{\ensuremath{\rho}}\DeclareUnicodeCharacter{2264}{\ensuremath{\leq}}\DeclareUnicodeCharacter{2265}{\ensuremath{\geq}}\DeclareUnicodeCharacter{2080}{\ensuremath{_0}}\DeclareUnicodeCharacter{2248}{\ensuremath{\approx}}\DeclareUnicodeCharacter{2212}{\ensuremath{-}}\DeclareUnicodeCharacter{03B1}{\ensuremath{\alpha}}\DeclareUnicodeCharacter{03B2}{\ensuremath{\beta}}\DeclareUnicodeCharacter{03BB}{\ensuremath{\lambda}}\DeclareUnicodeCharacter{03BC}{\ensuremath{\mu}}\DeclareUnicodeCharacter{03A3}{\ensuremath{\Sigma}}' \ + --toc \ + --number-sections -tarball: $(TAR_FILE) +ASSIGNMENTS := 1 2 3 -$(TAR_FILE): $(PDF_FILE) - tar -czvf $(TAR_FILE) assignments/1 +# Derived file lists +PDFS := $(foreach N,$(ASSIGNMENTS),$(STUDENT_ID)-assignment-$(N).pdf) +TARS := $(foreach N,$(ASSIGNMENTS),$(STUDENT_ID)-assignment-$(N).tar.gz) -clean: - rm -f $(PDF_FILE) $(TAR_FILE) +.PHONY: all pdfs tarballs clean \ + a1 a2 a3 \ + pdf1 pdf2 pdf3 \ + tar1 tar2 tar3 + +all: pdfs tarballs + +pdfs: $(PDFS) + +tarballs: $(TARS) + +# Pattern rule to build a PDF for an assignment N from assignments/N/README.md +$(STUDENT_ID)-assignment-%.pdf: assignments/%/README.md + @echo "[Pandoc] Building $@ from $<" + @PATH="$(TEX_PATH):$$PATH" $(PANDOC) $< -o $@ $(PANDOC_ARGS) + +# Pattern rule to build a tarball for an assignment N +$(STUDENT_ID)-assignment-%.tar.gz: $(STUDENT_ID)-assignment-%.pdf + @echo "[Tar] Packaging assignments/$* into $@" + @tar -czvf $@ assignments/$* -rebuild: clean all +# Convenience targets per assignment +pdf1: $(STUDENT_ID)-assignment-1.pdf +pdf2: $(STUDENT_ID)-assignment-2.pdf +pdf3: $(STUDENT_ID)-assignment-3.pdf + +a1: pdf1 tar1 +a2: pdf2 tar2 +a3: pdf3 tar3 + +tar1: $(STUDENT_ID)-assignment-1.tar.gz + @true + +tar2: $(STUDENT_ID)-assignment-2.tar.gz + @true + +tar3: $(STUDENT_ID)-assignment-3.tar.gz + @true + +clean: + rm -f $(PDFS) $(TARS) |
