-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (60 loc) · 2.11 KB
/
Makefile
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
include Makefile.config
################################################################################
############################# Constant variables ###############################
##### Shell
SHELL = /bin/bash
##### Current directory. it's the directory containing the makefile.
CURRENT_DIR = $(shell pwd)
##### Compilers
PDFLATEX = pdflatex
DVILUATEX = dviluatex
BIBTEX = bibtex
CC_WITH_OPTIONS = \
TEXINPUTS="$(SRC_DIR):$(RES_DIR):$(THEME_DIR):$(LIB_DIR):codes:$(BUILD_DIR):" \
TEXMFOUTPUTS="$(OUTPUT_DIR)" \
$(CC) \
-output-directory=$(OUTPUT_DIR) \
-shell-escape
################################################################################
################################################################################
############################### Rules ##########################################
all: $(NAME)
abstract:
$(PDFLATEX) -output-directory=$(OUTPUT_DIR) $(SRC_DIR)/abstract.tex
cp $(OUTPUT_DIR)/abstract.pdf $(CURRENT_DIR)/abstract.pdf
$(OUTPUT_DIR):
mkdir -p $@
$(NAME): $(OUTPUT_DIR) clean-symlink
$(CC_WITH_OPTIONS) $@.tex
ifeq ($(USE_BIB),true)
cd $(OUTPUT_DIR) && \
BIBINPUTS="$(CURRENT_DIR)/$(BIB_DIR)" \
BSTINPUT="$(CURRENT_DIR)/$(BIB_DIR)" \
TEXMFOUTPUTS="./" \
$(CC_BIB) \
$(NAME) && \
cd $(CURRENT_DIR)
$(CC_WITH_OPTIONS) $@.tex
else
endif
$(CC_WITH_OPTIONS) $@.tex
cp $(OUTPUT_DIR)/$@.pdf $(CURRENT_DIR)/$@.pdf
zip: fclean $(NAME)
$(MAKE) clean
zip -r $(NAME).zip $(OUTPUT_DIR)/* -x *.git*
clean-symlink:
-$(RM) $(CURRENT_DIR)/$(NAME).pdf
clean:
$(RM) $(OUTPUT_DIR)/$(NAME).{out,aux,toc,log,tex.backup,nav,snm,bbl,blg}
$(RM) $(OUTPUT_DIR)/abstract.{out,aux,toc,log,tex.backup,nav,snm,bbl,blg}
$(RM) $(OUTPUT_DIR)/texput.log
# $(OUTPUT_DIR) is only removed when the directory is empty (never be the case
# if it's the project root directory).
fclean: clean clean-symlink
$(RM) $(OUTPUT_DIR)/$(NAME).{pdf,zip,dvi}
-rmdir $(OUTPUT_DIR)
$(RM) $(CURRENT_DIR)/$(NAME).pdf
$(RM) $(OUTPUT_DIR)/abstract.pdf
re: fclean $(NAME)
################################################################################
.PHONY: all $(NAME) zip clean fclean re