summaryrefslogtreecommitdiff
path: root/Makefile
blob: 921ab19289cb093f6301d93a6aa898cb2872d8c8 (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
# Configuration
NAME = my-thesis
MAIN = main.tex
BUILD_DIR = temp

# Do not change below this line
# --------------------------------------------------------------------

.PHONY: pdf clean zip init
SOURCES = $(wildcard *.tex) $(wildcard content/*) $(wildcard style/*) $(wildcard images/*) $(wildcard/appendix/*) $(wildcard main.bib)
ARCHIVE=$(NAME).zip
LATEX=pdflatex -halt-on-error -interaction=nonstopmode -output-directory $(BUILD_DIR) -jobname=$(NAME) $(MAIN) >/dev/null
BIB=bibtex $(BUILD_DIR)/$(NAME)
GLOSSARIES=makeglossaries -d $(BUILD_DIR) $(NAME) >/dev/null

pdf: $(BUILD_DIR)/$(NAME).pdf

# Rule to build the PDF
# Need to run pdflatex three times to get the references right
$(BUILD_DIR)/$(NAME).pdf: $(SOURCES) $(BUILD_DIR)
	@echo "Building PDF..."
	@$(LATEX)
	$(BIB)
	$(GLOSSARIES)
	@$(LATEX)
	$(LATEX)

$(BUILD_DIR):
	mkdir -p $@

# Zip target
zip: $(NAME).zip

$(NAME).zip: $(SOURCES)
	zip -r $(NAME).zip $(SOURCES)

# Clean rule
clean:
	trash -f $$(tr '\n' ' ' < .gitignore)

# Create new project
init: LICENSE

LICENSE:
	@echo -e "*.aux\\n\
*.bbl\\n\
*.brf\\n\
*.nlo\\n\
*.blg\\n\
*.log\\n\
*.fls\\n\
*.fdb_latexmk\\n\
*.toc\\n\
*.lof\\n\
*.lot\\n\
*.out\\n\
*.tdo\\n\
main.synctex.gz\\n\
main.pdf\\n\
.idea\\n\
out\\n\
*.zip\\n\
build\\n\
temp" > .gitignore