-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMakefile
More file actions
34 lines (26 loc) · 1.04 KB
/
Copy pathMakefile
File metadata and controls
34 lines (26 loc) · 1.04 KB
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
# Makefile for compiling .tex files
# Define the pdflatex command
PDFLATEX_CMD = pdflatex -interaction=nonstopmode
# Define the compile step for pdflatex
define COMPILE_TEX
cd $(dir $1) && $(PDFLATEX_CMD) $(notdir $1) || { echo "Error: pdflatex failed for $1"; exit 1; }
endef
# Define the bibtex command
BIBTEX_CMD = [ -f $(basename $(notdir $1)).aux ] && bibtex $(basename $(notdir $1)) || echo "No bibtex references found" || { echo "Error: bibtex failed for $1"; exit 1; }
# Define the compile step for bibtex
define COMPILE_BIBTEX
cd $(dir $1) && $(BIBTEX_CMD)
endef
# Default target: Compile all .tex files if no specific target is given
all: $(patsubst %.tex, %.pdf, $(wildcard **/*.tex))
# Rule for compiling .tex to .pdf
%.pdf: %.tex
@echo "Compiling $< to $@"
$(call COMPILE_TEX,$<)
$(call COMPILE_BIBTEX,$<)
$(call COMPILE_TEX,$<)
$(call COMPILE_TEX,$<)
# Clean generated files
clean:
find . -name "*.aux" -o -name "*.log" -o -name "*.pdf" -o -name "*.toc" -o -name "*.out" -o -name "*.bbl" -o -name "*.blg" -exec rm -f {} +
.PHONY: all clean