summaryrefslogtreecommitdiff
path: root/Makefile
blob: b4d5ddb60894cc2b22b2400e8fb0305cf932cd42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# 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

# Student info for filenames
STUDENT_ID := 3431709

# Pandoc and LaTeX settings
PANDOC := pandoc
PDF_ENGINE := pdflatex
# Some macOS setups need TeX on PATH explicitly
TEX_PATH := /Library/TeX/texbin

# 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 \
	--citeproc \
	--bibliography=references.bib \
	--csl=ieee.csl

ASSIGNMENTS := 1 2 3

# Derived file lists
PDFS := $(foreach N,$(ASSIGNMENTS),$(STUDENT_ID)-assignment-$(N).pdf)
TARS := $(foreach N,$(ASSIGNMENTS),$(STUDENT_ID)-assignment-$(N).tar.gz)

.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 references.bib ieee.csl
	@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/$*

# 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: graph 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

graph:
	dot -Tpng assignments/2/graph.dot -o assignments/2/graph.png

clean:
	rm -f $(PDFS) $(TARS)