summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: ad1446bf2cdc083e3ec3fa9b206e805e183d0639 (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
# LaTeX Makefile
#
# WTFPL, 2016 - 2018 Agathe Porte (MicroJoe) <microjoe@microjoe.org>
#
# Inspirated from
# http://tex.stackexchange.com/questions/40738/how-to-properly-make-a-latex-project
# and my basic Makefile skills.

# Very important variables to set up
PDF=main.pdf
PRINC=main.tex
AUXDIR=build
LATEXMK=source ~/.bashrc && latexmk \
	-auxdir=$(AUXDIR) \
	-outdir=$(AUXDIR) \
	-pdf -pdflatex="pdflatex -interaction=nonstopmode" -use-make

# You want latexmk to *always* run, because make does not have all the info.
# Also, include non-file targets in .PHONY so they are run regardless of any
# file of the given name existing.
.PHONY: $(PDF) all clean live

# Main rule: Construct the PDF
all: $(PDF)

# Live: automatic watch and build of the PDF file
live: $(PRINC) $(SOURCES)
	$(LATEXMK) -pvc $(PRINC)

# Construct the PDF file from sources
$(PDF): $(PRINC) $(SOURCES)
	$(LATEXMK) $(PRINC)

# Remove all the intermediate files
clean:
	@echo Cleaning temporary LaTeX files...
	@rm -rf $(AUXDIR)