Skip to content

Commit b2fc02b

Browse files
committed
Refactor Makefile for improved structure and clarity
1 parent a954656 commit b2fc02b

1 file changed

Lines changed: 43 additions & 18 deletions

File tree

‎Makefile‎

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,65 @@
1-
CC = xelatex
2-
BIB = biber
3-
EXAMPLES_DIR = examples
4-
DRAFT_DIR = examples/draft
1+
# ===========================
2+
# Configuration
3+
# ===========================
4+
CC := xelatex
5+
BIB := biber
56

6-
# Find all CV source files
7-
CV_SRCS = $(shell find $(EXAMPLES_DIR)/cv* -name '*.tex')
7+
EXAMPLES_DIR := examples
8+
DRAFT_DIR := examples/draft
89

9-
# Output PDFs
10-
CV_PDFS = cv.pdf cv-jp.pdf
11-
COVER_LETTER_PDFS = coverletter.pdf coverletter-jp.pdf
12-
ALL_PDFS = $(CV_PDFS) $(COVER_LETTER_PDFS)
10+
# ===========================
11+
# File lists (derived from base names)
12+
# ===========================
13+
# CV base names - each has: name.tex, name/ folder, name.pdf (output)
14+
CV_NAMES := cv cv-jp
1315

16+
# Cover letter base names
17+
COVER_NAMES := coverletter coverletter-jp
18+
19+
# Temporary file extensions to clean
20+
TEMP_EXTS := aux bbl bcf blg log out run.xml
21+
22+
# Derived file lists
23+
CV_PDFS := $(addsuffix .pdf, $(CV_NAMES))
24+
COVER_PDFS := $(addsuffix .pdf, $(COVER_NAMES))
25+
ALL_PDFS := $(CV_PDFS) $(COVER_PDFS)
26+
27+
# ===========================
28+
# Phony targets
29+
# ===========================
1430
.PHONY: all examples clean draft draft-clean
1531

16-
# Build both examples and draft (if present)
32+
# ===========================
33+
# Default target
34+
# ===========================
1735
all: examples draft clean draft-clean
1836

1937
examples: $(ALL_PDFS)
2038

21-
# CV documents (need bibliography compilation)
22-
$(CV_PDFS): %.pdf: $(EXAMPLES_DIR)/%.tex $(CV_SRCS)
39+
# ===========================
40+
# Build rules
41+
# ===========================
42+
# CV PDFs require biber for bibliography processing
43+
# Each CV only depends on files in its own directory
44+
$(CV_PDFS): %.pdf: $(EXAMPLES_DIR)/%.tex
2345
$(CC) -output-directory=$(EXAMPLES_DIR) $<
2446
$(BIB) $(EXAMPLES_DIR)/$*
2547
$(CC) -output-directory=$(EXAMPLES_DIR) $<
2648
$(CC) -output-directory=$(EXAMPLES_DIR) $<
2749

28-
# Cover letters (simple compilation)
29-
$(COVER_LETTER_PDFS): %.pdf: $(EXAMPLES_DIR)/%.tex
50+
# Cover letters are simpler - single pass
51+
$(COVER_PDFS): %.pdf: $(EXAMPLES_DIR)/%.tex
3052
$(CC) -output-directory=$(EXAMPLES_DIR) $<
3153

54+
# ===========================
55+
# Cleanup
56+
# ===========================
3257
clean:
33-
@for ext in aux bbl bcf blg log out run.xml; do \
34-
rm -f $(EXAMPLES_DIR)/*.$${ext}; \
35-
done
58+
@rm -f $(addprefix $(EXAMPLES_DIR)/*., $(TEMP_EXTS))
3659

60+
# ===========================
3761
# Draft targets (only if draft directory exists)
62+
# ===========================
3863
draft:
3964
@if [ -d $(DRAFT_DIR) ] && [ -f $(DRAFT_DIR)/Makefile ]; then \
4065
$(MAKE) -C $(DRAFT_DIR); \

0 commit comments

Comments
 (0)